Skip to content

Commit

Permalink
riscv: build: make cfg variables more robust
Browse files Browse the repository at this point in the history
Change which Cargo `CFG` environment variables are used to select the
custom `cfg` variables.

See
#204 (comment)
for discussion.
  • Loading branch information
rmsyn committed May 4, 2024
1 parent a9d3e33 commit 60ff795
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions riscv/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::env;

fn main() {
let target = env::var("TARGET").unwrap();
let target = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap();

if target.starts_with("riscv32") {
if target.contains("riscv") && ptr_width == "32" {
println!("cargo:rustc-cfg=riscv");
println!("cargo:rustc-cfg=riscv32");
} else if target.starts_with("riscv64") {
} else if target.contains("riscv") && ptr_width == "64" {
println!("cargo:rustc-cfg=riscv");
println!("cargo:rustc-cfg=riscv64");
}
Expand Down

0 comments on commit 60ff795

Please sign in to comment.