Skip to content

Commit 6927be1

Browse files
d-e-s-odanielocfb
authored andcommitted
Replace vmlinux crate with vmlinux.h repository
Switch to using the centrally-managed vmlinux.h repository [0] for pulling in vmlinux.h headers used for development purposes. Doing so means that the burden of management of these headers is no longer with this repository and that a bunch of data is outsourced as well. [0] https://github.com/libbpf/vmlinux.h Signed-off-by: Daniel Müller <[email protected]>
1 parent f436463 commit 6927be1

File tree

28 files changed

+79
-705345
lines changed

28 files changed

+79
-705345
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ homepage = "https://github.com/libbpf/libbpf-rs"
88

99
[workspace]
1010
members = [
11-
"vmlinux",
1211
"libbpf-cargo",
1312
"libbpf-rs",
1413
"examples/bpf_query",

examples/capable/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "LGPL-2.1-only OR BSD-2-Clause"
77

88
[build-dependencies]
99
libbpf-cargo = { path = "../../libbpf-cargo" }
10-
vmlinux = { path = "../../vmlinux" }
10+
vmlinux = { version = "0.0", git = "https://github.com/libbpf/vmlinux.h.git", rev = "a9c092aa771310bf8b00b5018f7d40a1fdb6ec82" }
1111

1212
[dependencies]
1313
anyhow = "1.0.4"

examples/runqslower/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "LGPL-2.1-only OR BSD-2-Clause"
77

88
[build-dependencies]
99
libbpf-cargo = { path = "../../libbpf-cargo" }
10-
vmlinux = { path = "../../vmlinux" }
10+
vmlinux = { version = "0.0", git = "https://github.com/libbpf/vmlinux.h.git", rev = "a9c092aa771310bf8b00b5018f7d40a1fdb6ec82" }
1111

1212
[dependencies]
1313
anyhow = "1.0"

examples/tc_port_whitelist/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "LGPL-2.1-only OR BSD-2-Clause"
77

88
[build-dependencies]
99
libbpf-cargo = { path = "../../libbpf-cargo" }
10-
vmlinux = { path = "../../vmlinux" }
10+
vmlinux = { version = "0.0", git = "https://github.com/libbpf/vmlinux.h.git", rev = "a9c092aa771310bf8b00b5018f7d40a1fdb6ec82" }
1111

1212
[dependencies]
1313
anyhow = "1.0"

examples/tcp_ca/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "LGPL-2.1-only OR BSD-2-Clause"
77

88
[build-dependencies]
99
libbpf-cargo = { path = "../../libbpf-cargo" }
10-
vmlinux = { path = "../../vmlinux" }
10+
vmlinux = { version = "0.0", git = "https://github.com/libbpf/vmlinux.h.git", rev = "a9c092aa771310bf8b00b5018f7d40a1fdb6ec82" }
1111

1212
[dependencies]
1313
clap = { version = "4.0.32", features = ["derive"] }

examples/tcp_option/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ license = "LGPL-2.1-only OR BSD-2-Clause"
66

77
[build-dependencies]
88
libbpf-cargo = { path = "../../libbpf-cargo" }
9-
vmlinux = { path = "../../vmlinux" }
9+
vmlinux = { version = "0.0", git = "https://github.com/libbpf/vmlinux.h.git", rev = "a9c092aa771310bf8b00b5018f7d40a1fdb6ec82" }
1010

1111
[dependencies]
1212
anyhow = "1.0"

examples/tproxy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name = "proxy"
1010

1111
[build-dependencies]
1212
libbpf-cargo = { path = "../../libbpf-cargo" }
13-
vmlinux = { path = "../../vmlinux" }
13+
vmlinux = { version = "0.0", git = "https://github.com/libbpf/vmlinux.h.git", rev = "a9c092aa771310bf8b00b5018f7d40a1fdb6ec82" }
1414

1515
[dependencies]
1616
anyhow = "1.0"

libbpf-cargo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ clap = { version = "4.0.32", features = ["derive"] }
4242

4343
[dev-dependencies]
4444
goblin = "0.6"
45-
vmlinux = { path = "../vmlinux" }
45+
vmlinux = { version = "0.0", git = "https://github.com/libbpf/vmlinux.h.git", rev = "a9c092aa771310bf8b00b5018f7d40a1fdb6ec82" }

libbpf-rs/build.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::io::ErrorKind;
99
use std::io::Result;
1010
use std::ops::Deref as _;
1111
use std::path::Path;
12+
use std::path::PathBuf;
1213
use std::process::Command;
1314
use std::process::Output;
1415
use std::process::Stdio;
@@ -66,13 +67,19 @@ where
6667
}
6768

6869

69-
fn run_impl<C, A, S>(command: C, args: A, stdout: Stdio) -> Result<Output>
70+
fn run_impl<C, A, S>(command: C, args: A, stdout: Stdio, cwd: Option<&Path>) -> Result<Output>
7071
where
7172
C: AsRef<OsStr>,
7273
A: IntoIterator<Item = S> + Clone,
7374
S: AsRef<OsStr>,
7475
{
75-
let output = Command::new(command.as_ref())
76+
let mut builder = Command::new(command.as_ref());
77+
78+
if let Some(cwd) = cwd {
79+
builder.current_dir(cwd);
80+
}
81+
82+
let output = builder
7683
.stdin(Stdio::null())
7784
.stdout(stdout)
7885
.env_clear()
@@ -100,10 +107,23 @@ where
100107
A: IntoIterator<Item = S> + Clone,
101108
S: AsRef<OsStr>,
102109
{
103-
let _output = run_impl(command, args, Stdio::null())?;
110+
let cwd = None;
111+
let _output = run_impl(command, args, Stdio::null(), cwd)?;
104112
Ok(())
105113
}
106114

115+
/// Run a command and capture its output.
116+
fn output<C, A, S, P>(command: C, args: A, cwd: P) -> Result<Vec<u8>>
117+
where
118+
C: AsRef<OsStr>,
119+
A: IntoIterator<Item = S> + Clone,
120+
S: AsRef<OsStr>,
121+
P: AsRef<Path>,
122+
{
123+
let output = run_impl(command, args, Stdio::piped(), Some(cwd.as_ref()))?;
124+
Ok(output.stdout)
125+
}
126+
107127
fn adjust_mtime(path: &Path) -> Result<()> {
108128
// Note that `OUT_DIR` is only present at runtime.
109129
let out_dir = env::var("OUT_DIR").unwrap();
@@ -199,7 +219,13 @@ where
199219
fn prepare_test_files(crate_root: &Path) {
200220
let bin_dir = crate_root.join("tests").join("bin");
201221
let src_dir = bin_dir.join("src");
202-
let include = crate_root.join("../vmlinux/include").join(ARCH);
222+
let include_root = output(
223+
"cargo",
224+
["run", "--quiet"],
225+
crate_root.parent().unwrap().join("vmlinux-include"),
226+
)
227+
.unwrap();
228+
let include = PathBuf::from(&String::from_utf8(include_root).unwrap().trim_end()).join(ARCH);
203229

204230
with_bpf_headers(|bpf_hdr_dir| {
205231
for result in read_dir(&src_dir).unwrap() {

0 commit comments

Comments
 (0)