pub struct SkeletonBuilder { /* private fields */ }Expand description
SkeletonBuilder builds and generates a single skeleton.
This type is typically used from within a build scripts.
§Examples
use libbpf_cargo::SkeletonBuilder;
SkeletonBuilder::new()
.source("myobject.bpf.c")
.clang("/opt/clang/clang")
.build_and_generate("/output/path")
.unwrap();Implementations§
Source§impl SkeletonBuilder
impl SkeletonBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new SkeletonBuilder.
Sourcepub fn source<P: AsRef<Path>>(&mut self, source: P) -> &mut SkeletonBuilder
pub fn source<P: AsRef<Path>>(&mut self, source: P) -> &mut SkeletonBuilder
Point the SkeletonBuilder to a source file for compilation
Default is None
Sourcepub fn obj<P: AsRef<Path>>(&mut self, obj: P) -> &mut SkeletonBuilder
pub fn obj<P: AsRef<Path>>(&mut self, obj: P) -> &mut SkeletonBuilder
Point the SkeletonBuilder to an object file for generation
Default is None
Sourcepub fn clang<P: AsRef<Path>>(&mut self, clang: P) -> &mut SkeletonBuilder
pub fn clang<P: AsRef<Path>>(&mut self, clang: P) -> &mut SkeletonBuilder
Specify which clang binary to use
Default searches $PATH for clang
Sourcepub fn clang_args<A, S>(&mut self, args: A) -> &mut SkeletonBuilder
pub fn clang_args<A, S>(&mut self, args: A) -> &mut SkeletonBuilder
Pass additional arguments to clang when building BPF object file
§Examples
use libbpf_cargo::SkeletonBuilder;
SkeletonBuilder::new()
.source("myobject.bpf.c")
.clang_args([
"-DMACRO=value",
"-I/some/include/dir",
])
.build_and_generate("/output/path")
.unwrap();Sourcepub fn rustfmt<P: AsRef<Path>>(&mut self, rustfmt: P) -> &mut SkeletonBuilder
pub fn rustfmt<P: AsRef<Path>>(&mut self, rustfmt: P) -> &mut SkeletonBuilder
Specify which rustfmt binary to use
Default searches $PATH for rustfmt
Sourcepub fn build_and_generate<P: AsRef<Path>>(&mut self, output: P) -> Result<()>
pub fn build_and_generate<P: AsRef<Path>>(&mut self, output: P) -> Result<()>
Build BPF programs and generate the skeleton at path output
§Notes
When used from a build script, you may be interested in
surfacing compiler warnings as part of the build. Please refer
to util::CargoWarningFormatter and its documentation for how
to go about that.
Sourcepub fn build(&mut self) -> Result<()>
pub fn build(&mut self) -> Result<()>
Build BPF programs without generating a skeleton.
SkeletonBuilder::source must be set for this to succeed.
§Notes
When used from a build script, you may be interested in
surfacing compiler warnings as part of the build. Please refer
to util::CargoWarningFormatter and its documentation for how
to go about that.