File tree 3 files changed +19
-4
lines changed
3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ name = "xtask"
3
3
version = " 0.1.0"
4
4
edition = " 2021"
5
5
publish = false
6
+ build = " build.rs"
6
7
7
8
[lints ]
8
9
workspace = true
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ println ! (
3
+ "cargo:rustc-env=TARGET_PLATFORM={}" ,
4
+ & std:: env:: var( "TARGET" ) . unwrap( )
5
+ ) ;
6
+ println ! ( "cargo:rerun-if-changed-env=TARGET" ) ;
7
+ }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ enum Opts {
16
16
callgrind : bool ,
17
17
#[ arg( long) ]
18
18
cachegrind : bool ,
19
- #[ arg( long, default_value = "x86_64-unknown-linux-gnu" ) ]
19
+ #[ arg( long, default_value = env! ( "TARGET_PLATFORM" ) ) ]
20
20
target : String ,
21
21
args : Vec < String > ,
22
22
} ,
@@ -26,9 +26,13 @@ enum Opts {
26
26
#[ arg( long) ]
27
27
fix : bool ,
28
28
} ,
29
+ /// Build and run test file from `bindings/c`
29
30
TestCBindings {
30
- #[ arg( long, default_value = "x86_64-unknown-linux-gnu" ) ]
31
+ #[ arg( long, default_value = env! ( "TARGET_PLATFORM" ) ) ]
31
32
target : String ,
33
+ /// Which bindings file to build and run
34
+ #[ arg( long, default_value = "libjsonnet_test_file" ) ]
35
+ test_file : String ,
32
36
args : Vec < String > ,
33
37
} ,
34
38
}
@@ -78,15 +82,18 @@ fn main() -> Result<()> {
78
82
cmd ! ( sh, "cargo fmt {fmt_check...}" ) . run ( ) ?;
79
83
Ok ( ( ) )
80
84
}
81
- Opts :: TestCBindings { target, args } => {
85
+ Opts :: TestCBindings {
86
+ target,
87
+ test_file,
88
+ args,
89
+ } => {
82
90
cmd ! (
83
91
sh,
84
92
"cargo build -p libjsonnet --target={target} --release --no-default-features --features=interop-common,interop-threading"
85
93
)
86
94
. run ( ) ?;
87
95
let built = format ! ( "./target/{target}/release/libjsonnet.a" ) ;
88
96
let c_bindings = "./bindings/c/" ;
89
- let test_file = "libjsonnet_test_file" ;
90
97
cmd ! ( sh, "cp {built} {c_bindings}" ) . run ( ) ?;
91
98
sh. change_dir ( c_bindings) ;
92
99
You can’t perform that action at this time.
0 commit comments