forked from M-Labs/artiq-zynq
experimental: build script with linker file arg
This commit is contained in:
parent
8b780ec83b
commit
2c3091e792
|
@ -1,5 +1,5 @@
|
|||
extern crate build_zynq;
|
||||
|
||||
fn main() {
|
||||
build_zynq::cfg();
|
||||
build_zynq::cfg(None);
|
||||
}
|
||||
|
|
|
@ -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<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);
|
||||
}
|
||||
|
||||
// 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";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extern crate build_zynq;
|
||||
|
||||
fn main() {
|
||||
build_zynq::cfg();
|
||||
build_zynq::cfg(Some("link.x"));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extern crate build_zynq;
|
||||
|
||||
fn main() {
|
||||
build_zynq::cfg();
|
||||
build_zynq::cfg(Some("satman.ld"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue