#ebpf #programs #building #elf #typical #build #skeletons

build-bpf

Tools for building ELFs and Skeletons for typical (e)BPF programs

5 releases

0.2.0 Aug 24, 2024
0.1.3 Aug 22, 2024
0.1.2 Aug 18, 2024
0.1.1 Aug 18, 2024
0.1.0 Aug 18, 2024

#901 in Unix APIs

46 downloads per month
Used in flaregun

MIT license

12KB
278 lines

build-bpf

Tools for building ELFs and Skeletons for typical (e)BPF programs.

Usage for a project which wants to build BPF targets in src/bpf/*.bpf.c.

// build.rs
fn main() {
    build_bpf::guess_targets().for_each(|target| target.must_build());
}

To symlink the generated (Rust) Skeleton files, you can do something like this:

// build.rs
fn main() {
    let ln_to = |target: &build_bpf::BuildBpf| {
        format!(
            "{}/src/skel_{}.rs",
            std::env::var("CARGO_MANIFEST_DIR").unwrap(),
            target.bpf_prog_name()
        )
    };
    build_bpf::guess_targets().for_each(|target| {
        target.must_build().must_sym_link_skel_to(&ln_to(&target));
    });
}

Having the generated Skeleton files around can, instead of digging through target/..., can be useful during development.

Dependencies

~15–26MB
~454K SLoC