2020-06-30 17:19:09 +08:00
|
|
|
fn main() {
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
libc::compile();
|
|
|
|
}
|
|
|
|
|
|
|
|
mod libc {
|
|
|
|
use std::path::Path;
|
|
|
|
pub fn compile() {
|
|
|
|
let cfg = &mut cc::Build::new();
|
2020-07-02 11:36:38 +08:00
|
|
|
cfg.no_default_flags(true);
|
|
|
|
cfg.compiler("clang");
|
2020-06-30 17:19:09 +08:00
|
|
|
cfg.cpp(false);
|
|
|
|
cfg.warnings(false);
|
|
|
|
|
|
|
|
cfg.flag("-nostdlib");
|
|
|
|
cfg.flag("-ffreestanding");
|
|
|
|
cfg.flag("-fno-PIC");
|
|
|
|
cfg.flag("-isystem../include");
|
|
|
|
cfg.flag("-fno-stack-protector");
|
|
|
|
cfg.flag("--target=armv7-none-eabihf");
|
2020-07-02 11:36:38 +08:00
|
|
|
cfg.flag("-O2");
|
2020-06-30 17:19:09 +08:00
|
|
|
|
|
|
|
cfg.flag("-std=c99");
|
|
|
|
cfg.flag("-fstrict-aliasing");
|
|
|
|
cfg.flag("-funwind-tables");
|
|
|
|
cfg.flag("-fvisibility=hidden");
|
|
|
|
cfg.flag("-U_FORTIFY_SOURCE");
|
|
|
|
cfg.define("_FORTIFY_SOURCE", Some("0"));
|
|
|
|
|
2020-07-02 11:36:38 +08:00
|
|
|
let sources = vec![
|
2020-06-30 17:19:09 +08:00
|
|
|
"printf.c"
|
|
|
|
];
|
|
|
|
|
2020-07-02 11:36:38 +08:00
|
|
|
let root = Path::new("./");
|
|
|
|
for src in sources {
|
2020-06-30 17:19:09 +08:00
|
|
|
println!("cargo:rerun-if-changed={}", src);
|
|
|
|
cfg.file(root.join("src").join(src));
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg.compile("printf");
|
|
|
|
}
|
|
|
|
}
|