-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
26 lines (21 loc) · 898 Bytes
/
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
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
/// Put the linker script somewhere the linker can find it.
fn main() {
let out_dir = env::var("OUT_DIR").expect("No out dir");
let dest_path = Path::new(&out_dir);
let mut f = File::create(&dest_path.join("memory.x"))
.expect("Could not create file");
f.write_all(include_bytes!("memory.x"))
.expect("Could not write file");
let mut f = File::create(&dest_path.join("regions.ld"))
.expect("Could not create file");
f.write_all(include_bytes!(concat!(env!("BUILD_DIR"), "/software/include/generated/regions.ld")))
.expect("Could not write file");
println!("cargo:rustc-link-search={}", dest_path.display());
println!("cargo:rerun-if-changed=regions.ld");
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rerun-if-changed=build.rs");
}