reverted build script with linker file arg. Hybrid solution.

drtio_port
mwojcik 2021-07-26 14:38:43 +02:00
parent 2c3091e792
commit 522bea7e1c
4 changed files with 34 additions and 19 deletions

View File

@ -1,5 +1,5 @@
extern crate build_zynq;
fn main() {
build_zynq::cfg(None);
build_zynq::cfg();
}

View File

@ -4,22 +4,7 @@ use std::io::Write;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
pub fn cfg(linker_script: Option<str>) {
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);

View File

@ -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();
}

View File

@ -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();
}