Skip to content

Commit

Permalink
Port recent libbpf-cargo build.rs changes to libbpf-rs
Browse files Browse the repository at this point in the history
For testing purposes, libbpf-rs also maintains a build script that can
be used to generate files necessary for running the test suite. Port
over commit 704543e ("Use runtime CARGO_CFG_TARGET_ARCH in
build-script") as well as commit abc9eeb ("Fix __TARGET_ARCH_xx
define for riscv64,loongarch64,sparc64,mips64") from libbpf-cargo to
libbpf-rs' build script.

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o committed Oct 7, 2024
1 parent abc9eeb commit 7659ada
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libbpf-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,17 @@ fn prepare_test_files(crate_root: &Path) {
let obj = Path::new(&src).with_extension("o");
let src = src_dir.join(&src);
let dst = bin_dir.join(obj);
let arch = option_env!("CARGO_CFG_TARGET_ARCH").unwrap_or(ARCH);
let arch = env::var("CARGO_CFG_TARGET_ARCH");
let arch = arch.as_deref().unwrap_or(ARCH);
let arch = match arch {
"x86_64" => "x86",
"aarch64" => "arm64",
"powerpc64" => "powerpc",
"s390x" => "s390",
"riscv64" => "riscv",
"loongarch64" => "loongarch",
"sparc64" => "sparc",
"mips64" => "mips",
x => x,
};

Expand Down

0 comments on commit 7659ada

Please sign in to comment.