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;
|
extern crate build_zynq;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
build_zynq::cfg();
|
build_zynq::cfg(None);
|
||||||
}
|
}
|
||||||
|
@ -4,18 +4,21 @@ use std::io::Write;
|
|||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn cfg() {
|
pub fn cfg(linker_script: Option<str>) {
|
||||||
|
if let Some(script_file) = &linker_script {
|
||||||
// Put the linker script somewhere the linker can find it
|
// Put the linker script somewhere the linker can find it
|
||||||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
File::create(out.join("link.x"))
|
File::create(out.join(script_file))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(include_bytes!("link.x"))
|
.write_all(include_bytes!(script_file))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("cargo:rustc-link-search={}", out.display());
|
println!("cargo:rustc-link-search={}", out.display());
|
||||||
|
|
||||||
// Only re-run the build script when link.x is changed,
|
// Only re-run the build script when link.x is changed,
|
||||||
// instead of when any part of the source code changes.
|
// instead of when any part of the source code changes.
|
||||||
println!("cargo:rerun-if-changed=link.x");
|
println!("cargo:rerun-if-changed={}". script_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handle rustc-cfg file
|
// Handle rustc-cfg file
|
||||||
let cfg_path = "../../build/rustc-cfg";
|
let cfg_path = "../../build/rustc-cfg";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
extern crate build_zynq;
|
extern crate build_zynq;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
build_zynq::cfg();
|
build_zynq::cfg(Some("link.x"));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
extern crate build_zynq;
|
extern crate build_zynq;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
build_zynq::cfg();
|
build_zynq::cfg(Some("satman.ld"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user