gen-bindings 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/env sh
  2. LIBBPF_DIR=$1
  3. OUTPUT_DIR=$2
  4. if test -z "$LIBBPF_DIR"; then
  5. echo "error: no libbpf dir provided"
  6. exit 1
  7. fi
  8. if test -z "$OUTPUT_DIR"; then
  9. echo "error: no output dir provided"
  10. exit 1
  11. fi
  12. BPF_TYPES="\
  13. bpf_cmd \
  14. bpf_insn \
  15. bpf_attr \
  16. bpf_map_type \
  17. bpf_prog_type \
  18. bpf_attach_type
  19. "
  20. BPF_VARS="\
  21. BPF_PSEUDO_.*
  22. BPF_ALU \
  23. BPF_ALU64 \
  24. BPF_LDX \
  25. BPF_ST \
  26. BPF_STX \
  27. BPF_LD \
  28. BPF_K \
  29. BPF_DW \
  30. BPF_W \
  31. BPF_H \
  32. BPF_B
  33. "
  34. BTF_TYPES="\
  35. btf_header \
  36. btf_ext_header \
  37. btf_ext_info \
  38. btf_ext_info_sec \
  39. bpf_core_relo \
  40. bpf_core_relo_kind \
  41. btf_type \
  42. btf_enum \
  43. btf_array \
  44. btf_member \
  45. btf_param \
  46. btf_var \
  47. btf_var_secinfo
  48. "
  49. BTF_VARS="\
  50. BTF_KIND_.*
  51. BTF_INT_.*
  52. "
  53. PERF_TYPES="\
  54. perf_event_attr \
  55. perf_sw_ids \
  56. perf_event_sample_format \
  57. perf_event_mmap_page \
  58. perf_event_header \
  59. perf_type_id \
  60. perf_event_type
  61. "
  62. PERF_VARS="\
  63. PERF_FLAG_.* \
  64. PERF_EVENT_.*
  65. "
  66. bindgen $LIBBPF_DIR/include/uapi/linux/bpf.h \
  67. --no-layout-tests \
  68. --default-enum-style moduleconsts \
  69. $(for ty in $BPF_TYPES; do
  70. echo --whitelist-type "$ty"
  71. done) \
  72. $(for var in $BPF_VARS; do
  73. echo --whitelist-var "$var"
  74. done) \
  75. > $OUTPUT_DIR/bpf_bindings.rs
  76. bindgen $LIBBPF_DIR/include/uapi/linux/btf.h \
  77. --no-layout-tests \
  78. --default-enum-style moduleconsts \
  79. $(for ty in $BTF_TYPES; do
  80. echo --whitelist-type "$ty"
  81. done) \
  82. $(for var in $BTF_VARS; do
  83. echo --whitelist-var "$var"
  84. done) \
  85. > $OUTPUT_DIR/btf_bindings.rs
  86. bindgen $LIBBPF_DIR/src/libbpf_internal.h \
  87. --no-layout-tests \
  88. --default-enum-style moduleconsts \
  89. $(for ty in $BTF_TYPES; do
  90. echo --whitelist-type "$ty"
  91. done) \
  92. $(for var in $BTF_VARS; do
  93. echo --whitelist-var "$var"
  94. done) \
  95. > $OUTPUT_DIR/btf_internal_bindings.rs
  96. bindgen include/perf_wrapper.h \
  97. --no-layout-tests \
  98. --default-enum-style moduleconsts \
  99. $(for ty in $PERF_TYPES; do
  100. echo --whitelist-type "$ty"
  101. done) \
  102. $(for var in $PERF_VARS; do
  103. echo --whitelist-var "$var"
  104. done) \
  105. > $OUTPUT_DIR/perf_bindings.rs