aya-gen: add bindgen builder for userspace code

pull/1/head
Alessandro Decina 4 years ago
parent d9c3489165
commit 08d4b1aeda

@ -1,6 +1,15 @@
use bindgen::{self, Builder, EnumVariation}; use bindgen::{self, Builder, EnumVariation};
pub fn builder() -> Builder { pub fn user_builder() -> Builder {
let bindgen = bindgen::builder()
.layout_tests(false)
.default_enum_style(EnumVariation::ModuleConsts)
.prepend_enum_name(false);
bindgen
}
pub fn bpf_builder() -> Builder {
let bindgen = bindgen::builder() let bindgen = bindgen::builder()
.use_core() .use_core()
.ctypes_prefix("::aya_bpf_cty") .ctypes_prefix("::aya_bpf_cty")

@ -28,7 +28,7 @@ pub fn generate<T: AsRef<str>>(
types: &[T], types: &[T],
probe_read_getters: bool, probe_read_getters: bool,
) -> Result<String, Error> { ) -> Result<String, Error> {
let mut bindgen = bindgen::builder(); let mut bindgen = bindgen::bpf_builder();
let c_header = c_header_from_btf(btf_file)?; let c_header = c_header_from_btf(btf_file)?;
bindgen = bindgen.header_contents("kernel_types.h", &c_header); bindgen = bindgen.header_contents("kernel_types.h", &c_header);

Loading…
Cancel
Save