2023-09-06 22:51:24 +08:00
|
|
|
fn main() {
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
|
|
|
|
struct TargetConfiguration {
|
|
|
|
target: &'static str,
|
|
|
|
lds: &'static str,
|
|
|
|
}
|
|
|
|
|
|
|
|
const TARGET_CONFIGURATIONS: &[TargetConfiguration] = &[TargetConfiguration {
|
|
|
|
target: "riscv64",
|
2023-09-23 20:30:01 +08:00
|
|
|
lds: "src/arch/riscv/linker64.ld",
|
2023-09-06 22:51:24 +08:00
|
|
|
}];
|
|
|
|
|
|
|
|
let target = std::env::var("TARGET").unwrap();
|
|
|
|
for cfg in TARGET_CONFIGURATIONS {
|
|
|
|
if target.starts_with(cfg.target) {
|
2023-09-23 20:30:01 +08:00
|
|
|
println!("cargo:rerun-if-changed={}", cfg.lds);
|
2023-09-06 22:51:24 +08:00
|
|
|
println!("cargo:rustc-link-arg=-T{}", cfg.lds);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
panic!("Unsupported target: {}", target);
|
|
|
|
}
|