mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
boot1 contains all the ideas up to and including the console. however, the actual file transfer bits are yet to be implemented. onward!
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
// NOTE: Adapted from cortex-m/build.rs
|
|
use std::env;
|
|
use std::fs;
|
|
use std::io::Write;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() {
|
|
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
let target = env::var("TARGET").unwrap();
|
|
|
|
let linker_file_path = if target.starts_with("riscv") {
|
|
println!("cargo:rustc-link-search={}", out_dir.display());
|
|
#[cfg(feature = "bao1x")]
|
|
let p = PathBuf::from("src/platform/bao1x/link.x");
|
|
|
|
println!("cargo:rerun-if-changed={}", p.clone().into_os_string().into_string().unwrap());
|
|
println!("cargo:rustc-link-arg=-Tlink.x");
|
|
|
|
p
|
|
} else {
|
|
unreachable!("unsupported target");
|
|
};
|
|
|
|
println!("{}", out_dir.join("link.x").display());
|
|
// Put the linker script somewhere the linker can find it
|
|
std::fs::OpenOptions::new()
|
|
.create(true)
|
|
.write(true)
|
|
.truncate(true)
|
|
.open(out_dir.join("link.x"))
|
|
.unwrap()
|
|
.write_all(fs::read_to_string(linker_file_path).expect("linker file read").as_bytes())
|
|
.unwrap();
|
|
println!("cargo:rustc-link-search={}", out_dir.display());
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-changed=link.x");
|
|
}
|