123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #!/usr/bin/env sh
- LIBBPF_DIR=$1
- OUTPUT_DIR=$2
- if test -z "$LIBBPF_DIR"; then
- echo "error: no libbpf dir provided"
- exit 1
- fi
- if test -z "$OUTPUT_DIR"; then
- echo "error: no output dir provided"
- exit 1
- fi
- BPF_TYPES="\
- bpf_cmd \
- bpf_insn \
- bpf_attr \
- bpf_map_type \
- bpf_prog_type \
- bpf_attach_type
- "
- BPF_VARS="\
- BPF_PSEUDO_.*
- BPF_ALU \
- BPF_ALU64 \
- BPF_LDX \
- BPF_ST \
- BPF_STX \
- BPF_LD \
- BPF_K \
- BPF_DW \
- BPF_W \
- BPF_H \
- BPF_B
- "
- BTF_TYPES="\
- btf_header \
- btf_ext_header \
- btf_ext_info \
- btf_ext_info_sec \
- bpf_core_relo \
- bpf_core_relo_kind \
- btf_type \
- btf_enum \
- btf_array \
- btf_member \
- btf_param \
- btf_var \
- btf_var_secinfo
- "
- BTF_VARS="\
- BTF_KIND_.*
- BTF_INT_.*
- "
- PERF_TYPES="\
- perf_event_attr \
- perf_sw_ids \
- perf_event_sample_format \
- perf_event_mmap_page \
- perf_event_header \
- perf_type_id \
- perf_event_type
- "
- PERF_VARS="\
- PERF_FLAG_.* \
- PERF_EVENT_.*
- "
- NETLINK_TYPES="\
- ifinfomsg
- "
- NETLINK_VARS="\
- NLMSG_ALIGNTO \
- IFLA_XDP_FD \
- XDP_FLAGS_.*
- "
- bindgen $LIBBPF_DIR/include/uapi/linux/bpf.h \
- --no-layout-tests \
- --default-enum-style moduleconsts \
- $(for ty in $BPF_TYPES; do
- echo --whitelist-type "$ty"
- done) \
- $(for var in $BPF_VARS; do
- echo --whitelist-var "$var"
- done) \
- > $OUTPUT_DIR/bpf_bindings.rs
- bindgen $LIBBPF_DIR/include/uapi/linux/btf.h \
- --no-layout-tests \
- --default-enum-style moduleconsts \
- $(for ty in $BTF_TYPES; do
- echo --whitelist-type "$ty"
- done) \
- $(for var in $BTF_VARS; do
- echo --whitelist-var "$var"
- done) \
- > $OUTPUT_DIR/btf_bindings.rs
- bindgen $LIBBPF_DIR/src/libbpf_internal.h \
- --no-layout-tests \
- --default-enum-style moduleconsts \
- $(for ty in $BTF_TYPES; do
- echo --whitelist-type "$ty"
- done) \
- $(for var in $BTF_VARS; do
- echo --whitelist-var "$var"
- done) \
- > $OUTPUT_DIR/btf_internal_bindings.rs
- bindgen include/perf_wrapper.h \
- --no-layout-tests \
- --default-enum-style moduleconsts \
- $(for ty in $PERF_TYPES; do
- echo --whitelist-type "$ty"
- done) \
- $(for var in $PERF_VARS; do
- echo --whitelist-var "$var"
- done) \
- > $OUTPUT_DIR/perf_bindings.rs
- bindgen include/netlink_wrapper.h \
- --no-layout-tests \
- --default-enum-style moduleconsts \
- $(for ty in $NETLINK_TYPES; do
- echo --whitelist-type "$ty"
- done) \
- $(for var in $NETLINK_VARS; do
- echo --whitelist-var "$var"
- done) \
- > $OUTPUT_DIR/netlink_bindings.rs
|