Skip to content

Commit

Permalink
Change build script to correctly check target arch
Browse files Browse the repository at this point in the history
  • Loading branch information
gememma committed Oct 29, 2024
1 parent c8ade79 commit 92adb73
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mirrord/cli/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
use std::process::exit;

fn main() {
Expand All @@ -10,8 +9,12 @@ fn main() {
);
};

#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
if std::env::var("MIRRORD_LAYER_FILE_MACOS_ARM64").is_err() {
// this check uses cargo env vars instead of conditional compilation due to cfg! not respecting
// the target flag on a build
if std::env::var("MIRRORD_LAYER_FILE_MACOS_ARM64").is_err()
&& std::env::var("CARGO_CFG_TARGET_ARCH").is_ok_and(|t| t.eq("aarch64"))
&& std::env::var("CARGO_CFG_TARGET_OS").is_ok_and(|t| t.eq("macos"))
{
println!("cargo::warning=No environment variable 'MIRRORD_LAYER_FILE_MACOS_ARM64' found - it should contain the path to the mirrord layer compiled for the `aarch64-apple-darwin` target");
exit(1);
};
Expand Down

0 comments on commit 92adb73

Please sign in to comment.