diff --git a/src/libboard_artiq/build.rs b/src/libboard_artiq/build.rs index ba3b31b8..3ffec0ca 100644 --- a/src/libboard_artiq/build.rs +++ b/src/libboard_artiq/build.rs @@ -1,5 +1,5 @@ extern crate build_zynq; fn main() { - build_zynq::cfg(); + build_zynq::cfg(None); } diff --git a/src/libbuild_zynq/lib.rs b/src/libbuild_zynq/lib.rs index 3386cd16..17d93076 100644 --- a/src/libbuild_zynq/lib.rs +++ b/src/libbuild_zynq/lib.rs @@ -4,18 +4,21 @@ use std::io::Write; use std::io::{BufRead, BufReader}; use std::path::PathBuf; -fn cfg() { - // Put the linker script somewhere the linker can find it - let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); - File::create(out.join("link.x")) - .unwrap() - .write_all(include_bytes!("link.x")) - .unwrap(); - println!("cargo:rustc-link-search={}", out.display()); +pub fn cfg(linker_script: Option) { + if let Some(script_file) = &linker_script { + // Put the linker script somewhere the linker can find it + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join(script_file)) + .unwrap() + .write_all(include_bytes!(script_file)) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + + // Only re-run the build script when link.x is changed, + // instead of when any part of the source code changes. + println!("cargo:rerun-if-changed={}". script_file); + } - // Only re-run the build script when link.x is changed, - // instead of when any part of the source code changes. - println!("cargo:rerun-if-changed=link.x"); // Handle rustc-cfg file let cfg_path = "../../build/rustc-cfg"; diff --git a/src/runtime/build.rs b/src/runtime/build.rs index ba3b31b8..0e83abbd 100644 --- a/src/runtime/build.rs +++ b/src/runtime/build.rs @@ -1,5 +1,5 @@ extern crate build_zynq; fn main() { - build_zynq::cfg(); + build_zynq::cfg(Some("link.x")); } diff --git a/src/satman/build.rs b/src/satman/build.rs index ba3b31b8..e2e75b7a 100644 --- a/src/satman/build.rs +++ b/src/satman/build.rs @@ -1,5 +1,5 @@ extern crate build_zynq; fn main() { - build_zynq::cfg(); + build_zynq::cfg(Some("satman.ld")); }