Skip to content

Commit 8b8d76f

Browse files
committed
ci: bindings launch helper
1 parent bc92574 commit 8b8d76f

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

Cargo.lock

+8-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xtask/src/main.rs

+26
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ enum Opts {
2626
#[arg(long)]
2727
fix: bool,
2828
},
29+
TestCBindings {
30+
#[arg(long, default_value = "x86_64-unknown-linux-gnu")]
31+
target: String,
32+
args: Vec<String>,
33+
},
2934
}
3035

3136
fn main() -> Result<()> {
@@ -73,5 +78,26 @@ fn main() -> Result<()> {
7378
cmd!(sh, "cargo fmt {fmt_check...}").run()?;
7479
Ok(())
7580
}
81+
Opts::TestCBindings { target, args } => {
82+
cmd!(
83+
sh,
84+
"cargo build -p libjsonnet --target={target} --release --no-default-features --features=interop-common,interop-threading"
85+
)
86+
.run()?;
87+
let built = format!("./target/{target}/release/libjsonnet.a");
88+
let c_bindings = "./bindings/c/";
89+
let test_file = "libjsonnet_test_file";
90+
cmd!(sh, "cp {built} {c_bindings}").run()?;
91+
sh.change_dir(c_bindings);
92+
93+
// TODO: Pass target to gcc?
94+
cmd!(sh, "gcc -c {test_file}.c").run()?;
95+
cmd!(sh, "gcc -o {test_file} -lc -lm {test_file}.o libjsonnet.a").run()?;
96+
let sh = Shell::new()?;
97+
98+
cmd!(sh, "{c_bindings}{test_file} {args...}").run()?;
99+
100+
Ok(())
101+
}
76102
}
77103
}

0 commit comments

Comments
 (0)