gen-bindings 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. NETLINK_TYPES="\
  67. ifinfomsg
  68. "
  69. NETLINK_VARS="\
  70. NLMSG_ALIGNTO \
  71. IFLA_XDP_FD \
  72. XDP_FLAGS_.*
  73. "
  74. bindgen $LIBBPF_DIR/include/uapi/linux/bpf.h \
  75. --no-layout-tests \
  76. --default-enum-style moduleconsts \
  77. $(for ty in $BPF_TYPES; do
  78. echo --whitelist-type "$ty"
  79. done) \
  80. $(for var in $BPF_VARS; do
  81. echo --whitelist-var "$var"
  82. done) \
  83. > $OUTPUT_DIR/bpf_bindings.rs
  84. bindgen $LIBBPF_DIR/include/uapi/linux/btf.h \
  85. --no-layout-tests \
  86. --default-enum-style moduleconsts \
  87. $(for ty in $BTF_TYPES; do
  88. echo --whitelist-type "$ty"
  89. done) \
  90. $(for var in $BTF_VARS; do
  91. echo --whitelist-var "$var"
  92. done) \
  93. > $OUTPUT_DIR/btf_bindings.rs
  94. bindgen $LIBBPF_DIR/src/libbpf_internal.h \
  95. --no-layout-tests \
  96. --default-enum-style moduleconsts \
  97. $(for ty in $BTF_TYPES; do
  98. echo --whitelist-type "$ty"
  99. done) \
  100. $(for var in $BTF_VARS; do
  101. echo --whitelist-var "$var"
  102. done) \
  103. > $OUTPUT_DIR/btf_internal_bindings.rs
  104. bindgen include/perf_wrapper.h \
  105. --no-layout-tests \
  106. --default-enum-style moduleconsts \
  107. $(for ty in $PERF_TYPES; do
  108. echo --whitelist-type "$ty"
  109. done) \
  110. $(for var in $PERF_VARS; do
  111. echo --whitelist-var "$var"
  112. done) \
  113. > $OUTPUT_DIR/perf_bindings.rs
  114. bindgen include/netlink_wrapper.h \
  115. --no-layout-tests \
  116. --default-enum-style moduleconsts \
  117. $(for ty in $NETLINK_TYPES; do
  118. echo --whitelist-type "$ty"
  119. done) \
  120. $(for var in $NETLINK_VARS; do
  121. echo --whitelist-var "$var"
  122. done) \
  123. > $OUTPUT_DIR/netlink_bindings.rs