tiny_os/build.rs

31 lines
760 B
Rust
Raw Normal View History

2023-09-06 22:51:24 +08:00
fn main() {
println!("cargo:rerun-if-changed=build.rs");
2023-09-23 21:43:39 +08:00
struct TargetConfig {
2023-09-06 22:51:24 +08:00
target: &'static str,
2024-02-01 19:12:56 +08:00
lds: &'static str,
2023-09-06 22:51:24 +08:00
}
2023-09-23 21:43:39 +08:00
const TARGET_LDS: &[TargetConfig] = &[
TargetConfig {
target: "riscv64",
2024-02-01 19:12:56 +08:00
lds: "src/arch/riscv/linker.ld",
2023-09-23 21:43:39 +08:00
},
TargetConfig {
target: "riscv32",
2024-02-01 19:12:56 +08:00
lds: "src/arch/riscv/linker.ld",
2023-09-23 21:43:39 +08:00
},
];
2023-09-06 22:51:24 +08:00
let target = std::env::var("TARGET").unwrap();
2023-09-23 21:43:39 +08:00
for cfg in TARGET_LDS {
2023-09-06 22:51:24 +08:00
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);
}