You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aya/scripts/gen-bindings

119 lines
2.2 KiB
Bash

#!/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_.*
"
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