mirror of https://github.com/aya-rs/aya
integration-ebpf: artifact dependency bpf-linker
Replace the manual dependency machinery in integration-test/build.rs with: - integration-ebpf -[artifact-dependency]-> bpf-linker. - integration-test -[build-dependency]-> integration-ebpf. - integration-ebpf: build.rs that makes bpf-linker available to rustc. - integration-ebpf: lib.rs (empty) creates a lib target, allows dep from integration-test. - xtask: filter for test binaries now that the build also produces the bpf-linker binary. - github: remove `cargo install bpf-linker` and commentary about cache invalidation. - integration-test: remove bpf-linker installation instructions.reviewable/pr676/r1
parent
b28d4c34ee
commit
13d47b8aff
@ -0,0 +1,12 @@
|
||||
# We have this so that one doesn't need to manually pass
|
||||
# --target=bpfel-unknown-none -Z build-std=core when running cargo
|
||||
# check/build/doc etc.
|
||||
#
|
||||
# NB: this file gets loaded only if you run cargo from this directory, it's
|
||||
# ignored if you run from the workspace root. See
|
||||
# https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure
|
||||
[build]
|
||||
target = ["bpfeb-unknown-none", "bpfel-unknown-none"]
|
||||
|
||||
[unstable]
|
||||
build-std = ["core"]
|
@ -0,0 +1,28 @@
|
||||
fn main() {
|
||||
let out_dir = std::env::var_os("OUT_DIR").unwrap();
|
||||
let out_dir = std::path::PathBuf::from(out_dir);
|
||||
|
||||
let bpf_linker = std::env::var("CARGO_BIN_FILE_BPF_LINKER").unwrap();
|
||||
|
||||
// There seems to be no way to pass `-Clinker={}` to rustc from here.
|
||||
//
|
||||
// We assume rustc is going to look for `bpf-linker` on the PATH, so we can create a symlink and
|
||||
// put it on the PATH.
|
||||
let bin_dir = out_dir.join("bin");
|
||||
std::fs::create_dir_all(&bin_dir).unwrap();
|
||||
let bpf_linker_symlink = bin_dir.join("bpf-linker");
|
||||
match std::fs::remove_file(&bpf_linker_symlink) {
|
||||
Ok(()) => {}
|
||||
Err(err) => {
|
||||
if err.kind() != std::io::ErrorKind::NotFound {
|
||||
panic!("failed to remove symlink: {err}")
|
||||
}
|
||||
}
|
||||
}
|
||||
std::os::unix::fs::symlink(bpf_linker, bpf_linker_symlink).unwrap();
|
||||
let path = std::env::var_os("PATH");
|
||||
let path = path.as_ref();
|
||||
let paths = std::iter::once(bin_dir).chain(path.into_iter().flat_map(std::env::split_paths));
|
||||
let path = std::env::join_paths(paths).unwrap();
|
||||
println!("cargo:rustc-env=PATH={}", path.to_str().unwrap());
|
||||
}
|
@ -0,0 +1 @@
|
||||
#![no_std]
|
Loading…
Reference in New Issue