diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 882de747..920c0026 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -3,6 +3,7 @@ name = "xtask" version = "0.1.0" edition = "2021" publish = false +build = "build.rs" [lints] workspace = true diff --git a/xtask/build.rs b/xtask/build.rs new file mode 100644 index 00000000..6fdc47bf --- /dev/null +++ b/xtask/build.rs @@ -0,0 +1,7 @@ +fn main() { + println!( + "cargo:rustc-env=TARGET_PLATFORM={}", + &std::env::var("TARGET").unwrap() + ); + println!("cargo:rerun-if-changed-env=TARGET"); +} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 49571efb..e21533c6 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -16,7 +16,7 @@ enum Opts { callgrind: bool, #[arg(long)] cachegrind: bool, - #[arg(long, default_value = "x86_64-unknown-linux-gnu")] + #[arg(long, default_value = env!("TARGET_PLATFORM"))] target: String, args: Vec, }, @@ -26,9 +26,13 @@ enum Opts { #[arg(long)] fix: bool, }, + /// Build and run test file from `bindings/c` TestCBindings { - #[arg(long, default_value = "x86_64-unknown-linux-gnu")] + #[arg(long, default_value = env!("TARGET_PLATFORM"))] target: String, + /// Which bindings file to build and run + #[arg(long, default_value = "libjsonnet_test_file")] + test_file: String, args: Vec, }, } @@ -78,7 +82,11 @@ fn main() -> Result<()> { cmd!(sh, "cargo fmt {fmt_check...}").run()?; Ok(()) } - Opts::TestCBindings { target, args } => { + Opts::TestCBindings { + target, + test_file, + args, + } => { cmd!( sh, "cargo build -p libjsonnet --target={target} --release --no-default-features --features=interop-common,interop-threading" @@ -86,7 +94,6 @@ fn main() -> Result<()> { .run()?; let built = format!("./target/{target}/release/libjsonnet.a"); let c_bindings = "./bindings/c/"; - let test_file = "libjsonnet_test_file"; cmd!(sh, "cp {built} {c_bindings}").run()?; sh.change_dir(c_bindings);