tiny_os/build.rs
2023-09-06 22:51:24 +08:00

24 lines
604 B
Rust

fn main() {
println!("cargo:rerun-if-changed=build.rs");
struct TargetConfiguration {
target: &'static str,
lds: &'static str,
}
const TARGET_CONFIGURATIONS: &[TargetConfiguration] = &[TargetConfiguration {
target: "riscv64",
lds: "src/arch/riscv/boot/linker64.ld",
}];
let target = std::env::var("TARGET").unwrap();
for cfg in TARGET_CONFIGURATIONS {
if target.starts_with(cfg.target) {
println!("cargo:rustc-link-arg=-T{}", cfg.lds);
return;
}
}
panic!("Unsupported target: {}", target);
}