File tree 3 files changed +7
-38
lines changed 3 files changed +7
-38
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ aya-bpf = { path = "../../bpf/aya-bpf" }
9
9
aya-log-ebpf = { path = " ../../bpf/aya-log-ebpf" }
10
10
11
11
[build-dependencies ]
12
+ which = { workspace = true }
12
13
xtask = { path = " ../../xtask" }
13
14
14
15
[[bin ]]
Original file line number Diff line number Diff line change 1
- use std:: { env, path :: PathBuf } ;
1
+ use std:: env;
2
2
3
- use xtask:: { create_symlink_to_binary, AYA_BUILD_INTEGRATION_BPF } ;
3
+ use which:: which;
4
+ use xtask:: AYA_BUILD_INTEGRATION_BPF ;
4
5
5
6
/// Building this crate has an undeclared dependency on the `bpf-linker` binary. This would be
6
7
/// better expressed by [artifact-dependencies][bindeps] but issues such as
@@ -24,12 +25,7 @@ fn main() {
24
25
. unwrap_or_default ( ) ;
25
26
26
27
if build_integration_bpf {
27
- let out_dir = env:: var_os ( "OUT_DIR" ) . unwrap ( ) ;
28
- let out_dir = PathBuf :: from ( out_dir) ;
29
- let bpf_linker_symlink = create_symlink_to_binary ( & out_dir, "bpf-linker" ) . unwrap ( ) ;
30
- println ! (
31
- "cargo:rerun-if-changed={}" ,
32
- bpf_linker_symlink. to_str( ) . unwrap( )
33
- ) ;
28
+ let bpf_linker = which ( "bpf-linker" ) . unwrap ( ) ;
29
+ println ! ( "cargo:rerun-if-changed={}" , bpf_linker. to_str( ) . unwrap( ) ) ;
34
30
}
35
31
}
Original file line number Diff line number Diff line change 1
1
use anyhow:: { bail, Context as _, Result } ;
2
- use std:: {
3
- fs,
4
- path:: { Path , PathBuf } ,
5
- process:: Command ,
6
- } ;
7
- use which:: which;
2
+ use std:: process:: Command ;
8
3
9
4
pub const AYA_BUILD_INTEGRATION_BPF : & str = "AYA_BUILD_INTEGRATION_BPF" ;
10
5
pub const LIBBPF_DIR : & str = "xtask/libbpf" ;
@@ -18,26 +13,3 @@ pub fn exec(cmd: &mut Command) -> Result<()> {
18
13
}
19
14
Ok ( ( ) )
20
15
}
21
-
22
- // Create a symlink in the out directory to work around the fact that cargo ignores anything
23
- // in `$CARGO_HOME`, which is also where `cargo install` likes to place binaries. Cargo will
24
- // stat through the symlink and discover that the binary has changed.
25
- //
26
- // This was introduced in https://github.com/rust-lang/cargo/commit/99f841c.
27
- //
28
- // TODO(https://github.com/rust-lang/cargo/pull/12369): Remove this when the fix is available.
29
- pub fn create_symlink_to_binary ( out_dir : & Path , binary_name : & str ) -> Result < PathBuf > {
30
- let binary = which ( binary_name) . unwrap ( ) ;
31
- let symlink = out_dir. join ( binary_name) ;
32
- match fs:: remove_file ( & symlink) {
33
- Ok ( ( ) ) => { }
34
- Err ( err) => {
35
- if err. kind ( ) != std:: io:: ErrorKind :: NotFound {
36
- return Err ( err) . context ( format ! ( "failed to remove symlink {}" , symlink. display( ) ) ) ;
37
- }
38
- }
39
- }
40
- std:: os:: unix:: fs:: symlink ( binary, & symlink)
41
- . with_context ( || format ! ( "failed to create symlink {}" , symlink. display( ) ) ) ?;
42
- Ok ( symlink)
43
- }
You can’t perform that action at this time.
0 commit comments