Skip to content

Commit 6bd66a2

Browse files
Merge #93
93: Rerun the build script if the bin/{}.a archive has changed r=Disasm a=SimonSapin This PR also includes some drive-by cleanup commits, but the last one is what’s significant. This bit me when trying to make changes to `asm.S` and rebuilding with `./assemble.sh`. (By the way, I get ``Assembler messages: Fatal error: invalid -march= option: `rv32i'`` when running that script on Arch Linux despite installing a GNU toolchain for RISC-V. Instead I’m now using an Ubuntu 20.04 container to run it, since that’s what CI does for `./check-blobs.sh`.) Co-authored-by: Simon Sapin <simon.sapin@exyr.org>
2 parents 3f7e297 + 17e0aa2 commit 6bd66a2

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

riscv-rt/build.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ extern crate riscv_target;
44
use riscv_target::Target;
55
use std::env;
66
use std::fs;
7-
use std::io::Write;
87
use std::path::PathBuf;
98

109
fn main() {
@@ -15,26 +14,15 @@ fn main() {
1514
if target.starts_with("riscv") {
1615
let mut target = Target::from_target_str(&target);
1716
target.retain_extensions("imfdc");
17+
let archive = format!("bin/{}.a", target.to_string());
1818

19-
let target = target.to_string();
20-
21-
fs::copy(
22-
format!("bin/{}.a", target),
23-
out_dir.join(format!("lib{}.a", name)),
24-
)
25-
.unwrap();
26-
19+
fs::copy(&archive, out_dir.join(format!("lib{}.a", name))).unwrap();
20+
println!("cargo:rerun-if-changed={}", archive);
2721
println!("cargo:rustc-link-lib=static={}", name);
28-
println!("cargo:rustc-link-search={}", out_dir.display());
2922
}
3023

3124
// Put the linker script somewhere the linker can find it
32-
fs::File::create(out_dir.join("link.x"))
33-
.unwrap()
34-
.write_all(include_bytes!("link.x"))
35-
.unwrap();
25+
fs::write(out_dir.join("link.x"), include_bytes!("link.x")).unwrap();
3626
println!("cargo:rustc-link-search={}", out_dir.display());
37-
38-
println!("cargo:rerun-if-changed=build.rs");
3927
println!("cargo:rerun-if-changed=link.x");
4028
}

0 commit comments

Comments
 (0)