build-bpf

Crates.iobuild-bpf
lib.rsbuild-bpf
version0.2.0
sourcesrc
created_at2024-08-18 20:20:59.849319
updated_at2024-08-24 18:38:21.662374
descriptionTools for building ELFs and Skeletons for typical (e)BPF programs
homepagehttps://github.com/e-dant/build-bpf
repositoryhttps://github.com/e-dant/build-bpf
max_upload_size
id1342953
size11,572
Will (e-dant)

documentation

https://github.com/e-dant/build-bpf

README

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.

Commit count: 0

cargo fmt