diff --git a/src/libboard_artiq/build.rs b/src/libboard_artiq/build.rs index 3ffec0ca..ba3b31b8 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(None); + build_zynq::cfg(); } diff --git a/src/libbuild_zynq/lib.rs b/src/libbuild_zynq/lib.rs index 17d93076..d0a10605 100644 --- a/src/libbuild_zynq/lib.rs +++ b/src/libbuild_zynq/lib.rs @@ -4,22 +4,7 @@ use std::io::Write; use std::io::{BufRead, BufReader}; use std::path::PathBuf; -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); - } - - +pub fn cfg() { // Handle rustc-cfg file let cfg_path = "../../build/rustc-cfg"; println!("cargo:rerun-if-changed={}", cfg_path); diff --git a/src/runtime/build.rs b/src/runtime/build.rs index 0e83abbd..32e3fc72 100644 --- a/src/runtime/build.rs +++ b/src/runtime/build.rs @@ -1,5 +1,20 @@ +use std::env; +use std::fs::File; +use std::path::PathBuf; + extern crate build_zynq; fn main() { - build_zynq::cfg(Some("link.x")); + // 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()); + + // 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"); + build_zynq::cfg(); } diff --git a/src/satman/build.rs b/src/satman/build.rs index e2e75b7a..d16dad7e 100644 --- a/src/satman/build.rs +++ b/src/satman/build.rs @@ -1,5 +1,20 @@ +use std::env; +use std::fs::File; +use std::path::PathBuf; + extern crate build_zynq; fn main() { - build_zynq::cfg(Some("satman.ld")); + // Put the linker script somewhere the linker can find it + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("satman.ld")) + .unwrap() + .write_all(include_bytes!("satman.ld")) + .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=satman.ld"); + build_zynq::cfg(); }