Pentatube controller in Rust with Blackpill STM32F103

build.rs 571B

123456789101112131415161718
  1. use std::env;
  2. use std::fs::File;
  3. use std::io::Write;
  4. use std::path::PathBuf;
  5. fn main() {
  6. // Put the linker script somewhere the linker can find it
  7. let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
  8. File::create(out.join("memory.x"))
  9. .unwrap()
  10. .write_all(include_bytes!("memory.x"))
  11. .unwrap();
  12. println!("cargo:rustc-link-search={}", out.display());
  13. // Only re-run the build script when memory.x is changed,
  14. // instead of when any part of the source code changes.
  15. println!("cargo:rerun-if-changed=memory.x");
  16. }