-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
45 lines (37 loc) · 1.3 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const MAKEFILE_INNER: &str = "Makefile.inner";
const DEFMT_LOG: &str ="debug";
fn main() {
// Detect when IDE is running us:
// - Rust Rover:
// __CFBundleIdentifier=com.jetbrains.rustrover-EAP
//
#[allow(non_snake_case)]
let _IDE_RUN = std::env::var("__CFBundleIdentifier").is_ok();
// make stuff
//
let st = std::process::Command::new("make")
.arg("-f").arg(MAKEFILE_INNER)
.arg("tmp/libsome.a")
.arg("src/some.rs")
.output()
.expect("could not spawn `make`") // shown if 'make' not found on PATH
.status;
assert!(st.success(), "[ERROR]: Running 'make' failed"); // shown if 'make' returns a non-zero
// Link arguments
{
#[allow(unused_mut)]
let mut link_args: Vec<&str> = vec!( // 'mut' in case we wish to conditionally add stuff
"-Tlinkall.x",
"-Tdefmt.x" // required by 'defmt'
);
link_args.iter().for_each(|s| {
println!("cargo::rustc-link-arg={}", s);
});
}
println!("cargo:rustc-link-search=tmp");
println!("cargo:rustc-link-lib=static=some");
// Steer 'defmt' default log level, but allow overrides.
if option_env!("DEFMT_LOG").is_none() {
println!("cargo:rustc-env=DEFMT_LOG={}", DEFMT_LOG);
}
}