|
|
|
@ -1,6 +1,4 @@
|
|
|
|
|
use std::env;
|
|
|
|
|
|
|
|
|
|
use which::which;
|
|
|
|
|
use xtask::AYA_BUILD_INTEGRATION_BPF;
|
|
|
|
|
|
|
|
|
|
/// Building this crate has an undeclared dependency on the `bpf-linker` binary. This would be
|
|
|
|
@ -25,7 +23,31 @@ fn main() {
|
|
|
|
|
.unwrap_or_default();
|
|
|
|
|
|
|
|
|
|
if build_integration_bpf {
|
|
|
|
|
let bpf_linker = which("bpf-linker").unwrap();
|
|
|
|
|
println!("cargo:rerun-if-changed={}", bpf_linker.to_str().unwrap());
|
|
|
|
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
|
|
|
|
let out_dir = std::path::PathBuf::from(out_dir);
|
|
|
|
|
|
|
|
|
|
let bpf_linker = 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 = env::var_os("PATH");
|
|
|
|
|
let path = path.as_ref();
|
|
|
|
|
let paths = std::iter::once(bin_dir).chain(path.into_iter().flat_map(env::split_paths));
|
|
|
|
|
let path = env::join_paths(paths).unwrap();
|
|
|
|
|
println!("cargo:rustc-env=PATH={}", path.to_str().unwrap());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|