-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration-ebpf: artifact dependency bpf-linker
- integration-ebpf -[artifact-dependency]-> bpf-linker. - integration-ebpf: remove manual rebuild-if-changed=bpf-linker. - integration-ebpf: make bpf-linker availble to rustc in build.rs. - 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.
- Loading branch information
Showing
10 changed files
with
38 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
use std::{env, path::PathBuf}; | ||
|
||
use xtask::{create_symlink_to_binary, AYA_BUILD_INTEGRATION_BPF}; | ||
use std::{env, fs, path::PathBuf}; | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-env-changed={}", AYA_BUILD_INTEGRATION_BPF); | ||
let out_dir = env::var_os("OUT_DIR").unwrap(); | ||
let out_dir = PathBuf::from(out_dir); | ||
|
||
let build_integration_bpf = env::var(AYA_BUILD_INTEGRATION_BPF) | ||
.as_deref() | ||
.map(str::parse) | ||
.map(Result::unwrap) | ||
.unwrap_or_default(); | ||
let bpf_linker = env::var("CARGO_BIN_FILE_BPF_LINKER").unwrap(); | ||
|
||
if build_integration_bpf { | ||
let out_dir = env::var_os("OUT_DIR").unwrap(); | ||
let out_dir = PathBuf::from(out_dir); | ||
let bpf_linker_symlink = create_symlink_to_binary(&out_dir, "bpf-linker").unwrap(); | ||
println!( | ||
"cargo:rerun-if-changed={}", | ||
bpf_linker_symlink.to_str().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"); | ||
fs::create_dir_all(&bin_dir).unwrap(); | ||
let bpf_linker_symlink = bin_dir.join("bpf-linker"); | ||
match 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()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,3 @@ proc-macro2 = "1" | |
quote = "1" | ||
syn = "2" | ||
tempfile = "3" | ||
which = { version = "4.4.0", default-features = false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters