Skip to content

Commit

Permalink
riscv-rt: build: use cfg-check directives in build script
Browse files Browse the repository at this point in the history
Uses new lint checks for `cfg` variables.

Requires bumping the MSRV to `1.77.0`.
  • Loading branch information
rmsyn committed May 5, 2024
1 parent d6eb294 commit ae01f6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion riscv-rt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "riscv-rt"
version = "0.13.0"
rust-version = "1.60"
rust-version = "1.77.0"
repository = "https://github.com/rust-embedded/riscv"
authors = ["The RISC-V Team <[email protected]>"]
categories = ["embedded", "no-std"]
Expand Down
5 changes: 5 additions & 0 deletions riscv-rt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ fn parse_target(target: &str, cargo_flags: &str) -> (u32, HashSet<char>) {
}

fn main() {
println!("cargo::rustc-check-cfg=cfg(riscv)");

let target = env::var("TARGET").unwrap();
let cargo_flags = env::var("CARGO_ENCODED_RUSTFLAGS").unwrap();
let _name = env::var("CARGO_PKG_NAME").unwrap();
Expand All @@ -87,10 +89,12 @@ fn main() {
// generate the linker script and expose the ISA width
let arch_width = match bits {
32 => {
println!("cargo::rustc-check-cfg=cfg(riscv32)");
println!("cargo:rustc-cfg=riscv32");
4
}
64 => {
println!("cargo::rustc-check-cfg=cfg(riscv64)");
println!("cargo:rustc-cfg=riscv64");
8
}
Expand All @@ -100,6 +104,7 @@ fn main() {

// expose the ISA extensions
for ext in &extensions {
println!("cargo::rustc-check-cfg=cfg(riscv{ext})");
println!("cargo:rustc-cfg=riscv{}", ext);
}
}
Expand Down

0 comments on commit ae01f6e

Please sign in to comment.