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>) {
|
||||||
// Put the linker script somewhere the linker can find it
|
if let Some(script_file) = &linker_script {
|
||||||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
// Put the linker script somewhere the linker can find it
|
||||||
File::create(out.join("link.x"))
|
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
.unwrap()
|
File::create(out.join(script_file))
|
||||||
.write_all(include_bytes!("link.x"))
|
.unwrap()
|
||||||
.unwrap();
|
.write_all(include_bytes!(script_file))
|
||||||
println!("cargo:rustc-link-search={}", out.display());
|
.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
|
// 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