forked from mitmproxy/mitmproxy_rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
22 lines (19 loc) · 758 Bytes
/
Copy pathbuild.rs
File metadata and controls
22 lines (19 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#[cfg(target_os = "linux")]
use anyhow::{anyhow, Context as _};
#[cfg(target_os = "linux")]
use aya_build::cargo_metadata;
#[cfg(not(target_os = "linux"))]
fn main() {}
/// Based on https://github.com/aya-rs/aya-template/blob/main/%7B%7Bproject-name%7D%7D/build.rs
#[cfg(target_os = "linux")]
fn main() -> anyhow::Result<()> {
let cargo_metadata::Metadata { packages, .. } = cargo_metadata::MetadataCommand::new()
.no_deps()
.exec()
.context("MetadataCommand::exec")?;
let ebpf_package = packages
.into_iter()
.find(|cargo_metadata::Package { name, .. }| name == "mitmproxy-linux-ebpf")
.ok_or_else(|| anyhow!("mitmproxy-linux-ebpf package not found"))?;
aya_build::build_ebpf([ebpf_package])
}