From 522bea7e1cecf1a4bd47c8852b7e198bcceb5670 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 26 Jul 2021 14:38:43 +0200 Subject: [PATCH] reverted build script with linker file arg. Hybrid solution. --- src/libboard_artiq/build.rs | 2 +- src/libbuild_zynq/lib.rs | 17 +---------------- src/runtime/build.rs | 17 ++++++++++++++++- src/satman/build.rs | 17 ++++++++++++++++- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/libboard_artiq/build.rs b/src/libboard_artiq/build.rs index 3ffec0c..ba3b31b 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 17d9307..d0a1060 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 0e83abb..32e3fc7 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 e2e75b7..d16dad7 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(); }