build.rs 532 B

123456789101112131415161718
  1. // NOTE: Adapted from cortex-m/build.rs
  2. use std::env;
  3. use std::fs::File;
  4. use std::io::Write;
  5. use std::path::PathBuf;
  6. fn main() {
  7. // Put the linker script somewhere the linker can find it
  8. let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
  9. File::create(out.join("link.x"))
  10. .unwrap()
  11. .write_all(include_bytes!("link.x"))
  12. .unwrap();
  13. println!("cargo:rustc-link-search={}", out.display());
  14. println!("cargo:rerun-if-changed=build.rs");
  15. println!("cargo:rerun-if-changed=link.x");
  16. }