mirror of
https://github.com/h3xduck/TripleCross.git
synced 2025-12-21 09:13:07 +08:00
Setup development environment with libbpf
This commit is contained in:
23
external/libbpf-bootstrap/examples/rust/tracecon/build.rs
vendored
Normal file
23
external/libbpf-bootstrap/examples/rust/tracecon/build.rs
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
use std::fs::create_dir_all;
|
||||
use std::path::Path;
|
||||
|
||||
use libbpf_cargo::SkeletonBuilder;
|
||||
|
||||
const SRC: &str = "./src/bpf/tracecon.bpf.c";
|
||||
|
||||
fn main() {
|
||||
// It's unfortunate we cannot use `OUT_DIR` to store the generated skeleton.
|
||||
// Reasons are because the generated skeleton contains compiler attributes
|
||||
// that cannot be `include!()`ed via macro. And we cannot use the `#[path = "..."]`
|
||||
// trick either because you cannot yet `concat!(env!("OUT_DIR"), "/skel.rs")` inside
|
||||
// the path attribute either (see https://github.com/rust-lang/rust/pull/83366).
|
||||
//
|
||||
// However, there is hope! When the above feature stabilizes we can clean this
|
||||
// all up.
|
||||
create_dir_all("./src/bpf/.output").unwrap();
|
||||
let skel = Path::new("./src/bpf/.output/tracecon.skel.rs");
|
||||
SkeletonBuilder::new(SRC)
|
||||
.generate(&skel)
|
||||
.expect("bpf compilation failed");
|
||||
println!("cargo:rerun-if-changed={}", SRC);
|
||||
}
|
||||
Reference in New Issue
Block a user