#bpf #typical #programs #building #elf #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

#712 in Unix APIs

Download history 81/week @ 2024-08-12 258/week @ 2024-08-19 51/week @ 2024-08-26 9/week @ 2024-09-02 7/week @ 2024-09-09

406 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
~468K SLoC