#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

#887 in Unix APIs

Download history 164/week @ 2024-08-16 207/week @ 2024-08-23 24/week @ 2024-08-30 8/week @ 2024-09-06 11/week @ 2024-09-13 19/week @ 2024-09-20 21/week @ 2024-09-27 13/week @ 2024-10-04 13/week @ 2024-10-11 7/week @ 2024-10-18

57 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

~16–27MB
~470K SLoC