fix(ci): attempt to fix m1 compilation problem
This commit is contained in:
		
							parent
							
								
									0afa3f4208
								
							
						
					
					
						commit
						82d1b2f4e1
					
				| 
						 | 
					@ -17,10 +17,10 @@
 | 
				
			||||||
 * along with espanso.  If not, see <https://www.gnu.org/licenses/>.
 | 
					 * along with espanso.  If not, see <https://www.gnu.org/licenses/>.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use std::path::{PathBuf};
 | 
					use std::path::PathBuf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(not(target_os = "windows"))]
 | 
					#[cfg(not(target_os = "windows"))]
 | 
				
			||||||
use std::path::{Path};
 | 
					use std::path::Path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(not(target_os = "linux"))]
 | 
					#[cfg(not(target_os = "linux"))]
 | 
				
			||||||
const WX_WIDGETS_ARCHIVE_NAME: &str = "wxWidgets-3.1.5.zip";
 | 
					const WX_WIDGETS_ARCHIVE_NAME: &str = "wxWidgets-3.1.5.zip";
 | 
				
			||||||
| 
						 | 
					@ -89,17 +89,21 @@ fn build_native() {
 | 
				
			||||||
      ])
 | 
					      ])
 | 
				
			||||||
      .spawn()
 | 
					      .spawn()
 | 
				
			||||||
      .expect("failed to execute nmake");
 | 
					      .expect("failed to execute nmake");
 | 
				
			||||||
    if !handle.wait().expect("unable to wait for nmake command").success() {
 | 
					    if !handle
 | 
				
			||||||
 | 
					      .wait()
 | 
				
			||||||
 | 
					      .expect("unable to wait for nmake command")
 | 
				
			||||||
 | 
					      .success()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
      panic!("nmake returned non-zero exit code!");
 | 
					      panic!("nmake returned non-zero exit code!");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Make sure wxWidgets is compiled
 | 
					  // Make sure wxWidgets is compiled
 | 
				
			||||||
  if !out_wx_dir
 | 
					  if !out_wx_dir
 | 
				
			||||||
      .join("build")
 | 
					    .join("build")
 | 
				
			||||||
      .join("msw")
 | 
					    .join("msw")
 | 
				
			||||||
      .join("vc_mswu_x64")
 | 
					    .join("vc_mswu_x64")
 | 
				
			||||||
      .is_dir()
 | 
					    .is_dir()
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    panic!("wxWidgets is not compiled correctly, missing 'build/msw/vc_mswu_x64' directory")
 | 
					    panic!("wxWidgets is not compiled correctly, missing 'build/msw/vc_mswu_x64' directory")
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -164,52 +168,72 @@ fn build_native() {
 | 
				
			||||||
    let build_dir = out_wx_dir.join("build-cocoa");
 | 
					    let build_dir = out_wx_dir.join("build-cocoa");
 | 
				
			||||||
    std::fs::create_dir_all(&build_dir).expect("unable to create build-cocoa directory");
 | 
					    std::fs::create_dir_all(&build_dir).expect("unable to create build-cocoa directory");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let target_arch = match std::env::var("CARGO_CFG_TARGET_ARCH").expect("unable to read target arch").as_str() {
 | 
					    let target_arch = match std::env::var("CARGO_CFG_TARGET_ARCH")
 | 
				
			||||||
 | 
					      .expect("unable to read target arch")
 | 
				
			||||||
 | 
					      .as_str()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
      "x86_64" => "x86_64",
 | 
					      "x86_64" => "x86_64",
 | 
				
			||||||
      "aarch64" => "arm64",
 | 
					      "aarch64" => "arm64",
 | 
				
			||||||
      arch => panic!("unsupported arch {}", arch),
 | 
					      arch => panic!("unsupported arch {}", arch),
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Because of a configuration problem on the GitHub CI pipeline, we need
 | 
					    let mut handle = if std::env::var("CI").unwrap_or_default() == "true" {
 | 
				
			||||||
    // to set the target architecture manually.
 | 
					      // Because of a configuration problem on the GitHub CI pipeline, we need
 | 
				
			||||||
    // See: https://github.com/actions/virtual-environments/issues/3288#issuecomment-830207746
 | 
					      // to compile for both architectures manually, as well as setting some flags.
 | 
				
			||||||
    let xcode_sdk_path = Command::new("xcrun").args(&["--sdk", "macosx", "--show-sdk-path"]).output().expect("unable to obtain XCode sdk path");
 | 
					      // See: https://github.com/actions/virtual-environments/issues/3288#issuecomment-830207746
 | 
				
			||||||
    let xcode_sdk_path = String::from_utf8_lossy(&xcode_sdk_path.stdout);
 | 
					      let xcode_sdk_path = Command::new("xcrun")
 | 
				
			||||||
    let xcode_sdk_path = xcode_sdk_path.trim();
 | 
					        .args(&["--sdk", "macosx", "--show-sdk-path"])
 | 
				
			||||||
 | 
					        .output()
 | 
				
			||||||
 | 
					        .expect("unable to obtain XCode sdk path");
 | 
				
			||||||
 | 
					      let xcode_sdk_path = String::from_utf8_lossy(&xcode_sdk_path.stdout);
 | 
				
			||||||
 | 
					      let xcode_sdk_path = xcode_sdk_path.trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if xcode_sdk_path.is_empty() {
 | 
					      if xcode_sdk_path.is_empty() {
 | 
				
			||||||
      panic!("could not query XCode sdk path");
 | 
					        panic!("could not query XCode sdk path");
 | 
				
			||||||
    }
 | 
					      }
 | 
				
			||||||
 | 
					      println!("Using SDK path: {}", xcode_sdk_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    println!("Using SDK path: {}", xcode_sdk_path);
 | 
					      let configure_cxx_flags = format!(
 | 
				
			||||||
 | 
					        "-isysroot {} -isystem {} -DSTDC_HEADERS=1 -DHAVE_FCNTL_H -arch arm64 -arch x86_64",
 | 
				
			||||||
 | 
					        xcode_sdk_path, xcode_sdk_path
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let configure_cxx_flags = format!("-isysroot {} -isystem {} -DSTDC_HEADERS=1 -DHAVE_FCNTL_H -arch {}", xcode_sdk_path, xcode_sdk_path, target_arch);
 | 
					      Command::new(out_wx_dir.join("configure"))
 | 
				
			||||||
 | 
					        .current_dir(build_dir.to_string_lossy().to_string())
 | 
				
			||||||
 | 
					        .args(&["--disable-shared", "--without-libtiff"])
 | 
				
			||||||
 | 
					        .env("CXXFLAGS", &configure_cxx_flags)
 | 
				
			||||||
 | 
					        .spawn()
 | 
				
			||||||
 | 
					        .expect("failed to execute configure")
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      Command::new(out_wx_dir.join("configure"))
 | 
				
			||||||
 | 
					        .current_dir(build_dir.to_string_lossy().to_string())
 | 
				
			||||||
 | 
					        .args(&[
 | 
				
			||||||
 | 
					          "--disable-shared",
 | 
				
			||||||
 | 
					          "--without-libtiff",
 | 
				
			||||||
 | 
					          &format!("--enable-macosx_arch={}", target_arch),
 | 
				
			||||||
 | 
					        ])
 | 
				
			||||||
 | 
					        .spawn()
 | 
				
			||||||
 | 
					        .expect("failed to execute configure")
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let mut handle = Command::new(out_wx_dir.join("configure"))
 | 
					    if !handle
 | 
				
			||||||
      .current_dir(
 | 
					      .wait()
 | 
				
			||||||
        build_dir.to_string_lossy().to_string()
 | 
					      .expect("unable to wait for configure command")
 | 
				
			||||||
      )
 | 
					      .success()
 | 
				
			||||||
      .args(&[
 | 
					    {
 | 
				
			||||||
        "--disable-shared",
 | 
					 | 
				
			||||||
        "--without-libtiff",
 | 
					 | 
				
			||||||
      ])
 | 
					 | 
				
			||||||
      .env("CXXFLAGS", &configure_cxx_flags)
 | 
					 | 
				
			||||||
      .spawn()
 | 
					 | 
				
			||||||
      .expect("failed to execute configure");
 | 
					 | 
				
			||||||
    if !handle.wait().expect("unable to wait for configure command").success() {
 | 
					 | 
				
			||||||
      panic!("configure returned non-zero exit code!");
 | 
					      panic!("configure returned non-zero exit code!");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let mut handle = Command::new("make")
 | 
					    let mut handle = Command::new("make")
 | 
				
			||||||
      .current_dir(
 | 
					      .current_dir(build_dir.to_string_lossy().to_string())
 | 
				
			||||||
        build_dir.to_string_lossy().to_string()
 | 
					      .args(&["-j8"])
 | 
				
			||||||
      )
 | 
					 | 
				
			||||||
      .args(&[
 | 
					 | 
				
			||||||
        "-j8",
 | 
					 | 
				
			||||||
      ])
 | 
					 | 
				
			||||||
      .spawn()
 | 
					      .spawn()
 | 
				
			||||||
      .expect("failed to execute make");
 | 
					      .expect("failed to execute make");
 | 
				
			||||||
    if !handle.wait().expect("unable to wait for make command").success() {
 | 
					    if !handle
 | 
				
			||||||
 | 
					      .wait()
 | 
				
			||||||
 | 
					      .expect("unable to wait for make command")
 | 
				
			||||||
 | 
					      .success()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
      panic!("make returned non-zero exit code!");
 | 
					      panic!("make returned non-zero exit code!");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -355,7 +379,8 @@ fn build_native() {
 | 
				
			||||||
  // Make sure wxWidgets is installed
 | 
					  // Make sure wxWidgets is installed
 | 
				
			||||||
  if std::process::Command::new("wx-config")
 | 
					  if std::process::Command::new("wx-config")
 | 
				
			||||||
    .arg("--version")
 | 
					    .arg("--version")
 | 
				
			||||||
    .output().is_err()
 | 
					    .output()
 | 
				
			||||||
 | 
					    .is_err()
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    panic!("wxWidgets is not installed, as `wx-config` cannot be exectued")
 | 
					    panic!("wxWidgets is not installed, as `wx-config` cannot be exectued")
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user