aya-bpf-bindings: fix anonymous enums

pull/1/head
Alessandro Decina 4 years ago
parent f0444233b3
commit bdca32cebf

@ -15,7 +15,7 @@ pub fn bpf_builder() -> Builder {
.ctypes_prefix("::aya_bpf_cty")
.layout_tests(false)
.clang_arg("-Wno-unknown-attributes")
.default_enum_style(EnumVariation::Consts)
.default_enum_style(EnumVariation::ModuleConsts)
.prepend_enum_name(false);
bindgen

@ -1,7 +1,7 @@
use core::{marker::PhantomData, mem};
use crate::{
bindings::{bpf_map_def, BPF_F_CURRENT_CPU, BPF_MAP_TYPE_PERF_EVENT_ARRAY},
bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_F_CURRENT_CPU},
helpers::bpf_perf_event_output,
BpfContext,
};

@ -21,7 +21,21 @@ pub fn codegen(opts: &Options) -> Result<(), anyhow::Error> {
let builder = || {
let mut bindgen = bindgen::bpf_builder()
.header(&*dir.join("include/bindings.h").to_string_lossy())
.clang_args(&["-I", &*opts.libbpf_dir.join("src").to_string_lossy()]);
.clang_args(&["-I", &*opts.libbpf_dir.join("src").to_string_lossy()])
// open aya-bpf-bindings/.../bindings.rs and look for mod
// _bindgen, those are anonymous enums
.constified_enum("BPF_F_.*")
.constified_enum("BPF_REG_.*")
.constified_enum("BPF_CSUM_.*")
.constified_enum("BPF_ADJ_.*")
.constified_enum("BPF_SK_.*")
.constified_enum("BPF_RB_.*")
.constified_enum("BPF_RINGBUF_.*")
.constified_enum("BPF_SOCK_.*")
.constified_enum("BPF_TCP_.*")
.constified_enum("BPF_DEVCG_.*")
.constified_enum("BPF_FIB_.*")
.constified_enum("BPF_FLOW_.*");
let types = ["bpf_map_.*"];
let vars = ["BPF_.*", "bpf_.*"];

Loading…
Cancel
Save