|
1 |
| -; Build vendored libbpf |
2 |
| - |
3 |
| -(rule |
4 |
| - (deps |
5 |
| - (source_tree %{project_root}/vendor/libbpf)) |
6 |
| - (targets |
7 |
| - libbpf.pc |
8 |
| - dllbpf.so |
9 |
| - libbpf.a |
10 |
| - bpf_core_read.h |
11 |
| - bpf_endian.h |
12 |
| - bpf.h |
13 |
| - bpf_helper_defs.h |
14 |
| - bpf_helpers.h |
15 |
| - bpf_tracing.h |
16 |
| - btf.h |
17 |
| - libbpf_common.h |
18 |
| - libbpf.h |
19 |
| - libbpf_legacy.h |
20 |
| - libbpf_version.h |
21 |
| - skel_internal.h |
22 |
| - usdt.bpf.h) |
23 |
| - (action |
24 |
| - (no-infer |
25 |
| - (progn |
26 |
| - (chdir |
27 |
| - %{project_root}/vendor/libbpf/src |
28 |
| - (progn |
29 |
| - (bash "mkdir build root") |
30 |
| - (run make OBJDIR=build DESTDIR=root install))) |
31 |
| - (copy %{project_root}/vendor/libbpf/src/build/libbpf.pc libbpf.pc) |
32 |
| - (copy %{project_root}/vendor/libbpf/src/build/libbpf.so dllbpf.so) |
33 |
| - (copy %{project_root}/vendor/libbpf/src/build/libbpf.a libbpf.a) |
34 |
| - (copy |
35 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/bpf_core_read.h |
36 |
| - bpf_core_read.h) |
37 |
| - (copy |
38 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/bpf_endian.h |
39 |
| - bpf_endian.h) |
40 |
| - (copy %{project_root}/vendor/libbpf/src/root/usr/include/bpf/bpf.h bpf.h) |
41 |
| - (copy |
42 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/bpf_helper_defs.h |
43 |
| - bpf_helper_defs.h) |
44 |
| - (copy |
45 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/bpf_helpers.h |
46 |
| - bpf_helpers.h) |
47 |
| - (copy |
48 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/bpf_tracing.h |
49 |
| - bpf_tracing.h) |
50 |
| - (copy %{project_root}/vendor/libbpf/src/root/usr/include/bpf/btf.h btf.h) |
51 |
| - (copy |
52 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/libbpf_common.h |
53 |
| - libbpf_common.h) |
54 |
| - (copy |
55 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/libbpf.h |
56 |
| - libbpf.h) |
57 |
| - (copy |
58 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/libbpf_legacy.h |
59 |
| - libbpf_legacy.h) |
60 |
| - (copy |
61 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/libbpf_version.h |
62 |
| - libbpf_version.h) |
63 |
| - (copy |
64 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/skel_internal.h |
65 |
| - skel_internal.h) |
66 |
| - (copy |
67 |
| - %{project_root}/vendor/libbpf/src/root/usr/include/bpf/usdt.bpf.h |
68 |
| - usdt.bpf.h))))) |
69 |
| - |
70 |
| -; Everything below is the bindings generation process using ctypes. It produces |
71 |
| -; two OCaml modules, Libbpf_c_generated_functions and Libbpf_c_generated_types. |
72 |
| - |
73 |
| -; Type bindings (Libbpf_c_generated_types). |
74 |
| - |
75 |
| -; Functor of type descriptions to be used in stub generator |
76 |
| -; libbpf_c_type_descriptions.ml -> libbpf_c_type_descriptions.cma/cmxa/cmxs |
77 |
| - |
78 | 1 | (library
|
79 |
| - (name libbpf_c_type_descriptions) |
80 |
| - (public_name ocaml_libbpf.libbpf_c_type_descriptions) |
81 |
| - (modules libbpf_c_type_descriptions) |
82 |
| - (libraries ctypes)) |
83 |
| - |
84 |
| -; Compile types_bindings_stub_gen with Libbpf_c_type_description.Types |
85 |
| -; functor to output C generator from type descriptions |
86 |
| -; types_binding_stub_gen.ml + libbpf_c_type_descriptions.cma/cmxa/cmxa -> types_binding_stub_gen.exe |
87 |
| - |
88 |
| -(executable |
89 |
| - (name gen_type_bindings) |
90 |
| - (modules gen_type_bindings) |
91 |
| - (libraries ctypes.stubs libbpf_c_type_descriptions)) |
92 |
| - |
93 |
| -; Run generator gen_type_bindings.exe to get c source file to generate OCaml module |
94 |
| -; gen_type_bindings.exe -> gen_type_bindings.c |
95 |
| - |
96 |
| -(rule |
97 |
| - (targets gen_type_bindings.c) |
98 |
| - (deps libbpf.h) |
99 |
| - (action |
100 |
| - (run ./gen_type_bindings.exe))) |
101 |
| - |
102 |
| -; Compile types_bindings_c_stub_gen.c |
103 |
| -; types_bindings_c_stub_gen.c -> gen_type_bindings.exe |
104 |
| - |
105 |
| -(rule |
106 |
| - (targets gen_type_bindings_from_c.exe) |
107 |
| - (deps gen_type_bindings.c) |
108 |
| - (action |
109 |
| - (bash |
110 |
| - "%{cc} %{deps} -I `dirname %{lib:ctypes:ctypes_cstubs_internals.h}` -I %{ocaml_where} -o %{targets}"))) |
111 |
| - |
112 |
| -; Run generator gen_type_bindings.exe to get |
113 |
| -; libbpf_c_generated_types.ml |
114 |
| -; gen_type_bindings_from_c.exe -> libbpf_c_generated_types.ml |
115 |
| - |
116 |
| -(rule |
117 |
| - (with-stdout-to |
118 |
| - libbpf_c_generated_types.ml |
119 |
| - (run ./gen_type_bindings_from_c.exe))) |
120 |
| - |
121 |
| -; Function bindings. |
122 |
| - |
123 |
| -(library |
124 |
| - (name libbpf_c_function_descriptions) |
125 |
| - (public_name ocaml_libbpf.libbpf_c_function_descriptions) |
126 |
| - (flags ; (:standard -w -9-16-27) |
127 |
| - ) |
128 |
| - ; (wrapped false) |
129 |
| - (modules libbpf_c_generated_types libbpf_c_function_descriptions) |
130 |
| - (libraries ctypes libbpf_c_type_descriptions)) |
131 |
| - |
132 |
| -; Compile gen_function_bindings |
133 |
| - |
134 |
| -(executable |
135 |
| - (name gen_function_bindings) |
136 |
| - (modules gen_function_bindings) |
137 |
| - (libraries ctypes.stubs libbpf_c_function_descriptions)) |
138 |
| - |
139 |
| -; Generate both the function stubs and the generated functions |
140 |
| - |
141 |
| -(rule |
142 |
| - (targets libbpf_stubs.c libbpf_c_generated_functions.ml) |
143 |
| - (deps gen_function_bindings.exe) |
144 |
| - (action |
145 |
| - (run %{deps}))) |
146 |
| - |
147 |
| -; This is so that we can collate the functions and type bindings |
148 |
| - |
149 |
| -(library |
150 |
| - (name libbpf_bindings) |
151 |
| - (public_name ocaml_libbpf.libbpf_bindings) |
152 |
| - (libraries libbpf_c_function_descriptions) |
153 |
| - (modules libbpf_bindings libbpf_c_generated_functions)) |
154 |
| - |
155 |
| -; The Nicely packaged library for users |
156 |
| - |
157 |
| -(library |
158 |
| - (name ocaml_libbpf) |
159 | 2 | (public_name ocaml_libbpf)
|
160 |
| - (foreign_archives bpf) |
161 |
| - (c_library_flags -lelf -lz) |
162 |
| - (foreign_stubs |
163 |
| - (language c) |
164 |
| - (names libbpf_stubs) |
165 |
| - (include_dirs root/usr/include)) |
166 |
| - (libraries ctypes.stubs libbpf_bindings) |
167 |
| - (modules ocaml_libbpf)) |
| 3 | + (ctypes |
| 4 | + (external_library_name libbpf) |
| 5 | + (build_flags_resolver pkg_config) |
| 6 | + (headers (include bpf/libbpf.h)) |
| 7 | + (type_description |
| 8 | + (instance Types) |
| 9 | + (functor Type_description)) |
| 10 | + (function_description |
| 11 | + (concurrency unlocked) |
| 12 | + (instance Functions) |
| 13 | + (functor Function_description)) |
| 14 | + (generated_types Types_generated) |
| 15 | + (generated_entry_point C))) |
0 commit comments