| 14 | use std::path::PathBuf; |
| 15 | |
| 16 | fn main() { |
| 17 | // Put `memory.x` in our output directory and ensure it's |
| 18 | // on the linker search path. |
| 19 | let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); |
| 20 | File::create(out.join("memory.x")) |
| 21 | .unwrap() |
| 22 | .write_all(include_bytes!("memory.x")) |
| 23 | .unwrap(); |
| 24 | println!("cargo:rustc-link-search={}", out.display()); |
| 25 | |
| 26 | // By default, Cargo will re-run a build script whenever |
| 27 | // any file in the project changes. By specifying `memory.x` |
| 28 | // here, we ensure the build script is only re-run when |
| 29 | // `memory.x` is changed. |
| 30 | println!("cargo:rerun-if-changed=memory.x"); |
| 31 | } |