@@ -14,9 +14,10 @@ CFLAGS_REMOVE_helpers.o = -Wmissing-prototypes -Wmissing-declarations
14
14
always-$(CONFIG_RUST) += libmacros.so
15
15
no-clean-files += libmacros.so
16
16
17
- always-$(CONFIG_RUST) += bindings_generated.rs bindings_helpers_generated.rs
18
- obj-$(CONFIG_RUST) += alloc.o kernel.o
19
- always-$(CONFIG_RUST) += exports_alloc_generated.h exports_kernel_generated.h
17
+ always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs
18
+ obj-$(CONFIG_RUST) += alloc.o bindings.o kernel.o
19
+ always-$(CONFIG_RUST) += exports_alloc_generated.h exports_bindings_generated.h \
20
+ exports_kernel_generated.h
20
21
21
22
ifdef CONFIG_RUST_BUILD_ASSERT_DENY
22
23
always-$(CONFIG_RUST) += build_error.o
@@ -110,10 +111,11 @@ rustdoc-alloc: $(src)/alloc/lib.rs rustdoc-core rustdoc-compiler_builtins FORCE
110
111
$(call if_changed,rustdoc)
111
112
112
113
rustdoc-kernel : private rustc_target_flags = --extern alloc \
113
- --extern build_error --extern macros=$(objtree)/$(obj)/libmacros.so
114
+ --extern build_error --extern macros=$(objtree)/$(obj)/libmacros.so \
115
+ --extern bindings
114
116
rustdoc-kernel : $(src ) /kernel/lib.rs rustdoc-core rustdoc-macros \
115
117
rustdoc-compiler_builtins rustdoc-alloc $(obj)/libmacros.so \
116
- $(obj)/bindings_generated.rs $(obj)/bindings_helpers_generated.rs FORCE
118
+ $(obj)/bindings.o FORCE
117
119
$(call if_changed,rustdoc)
118
120
119
121
quiet_cmd_rustc_test_library = RUSTC TL $<
@@ -135,6 +137,9 @@ rusttestlib-macros: private rustc_test_library_proc = yes
135
137
rusttestlib-macros : $(src ) /macros/lib.rs rusttest-prepare FORCE
136
138
$(call if_changed,rustc_test_library)
137
139
140
+ rusttestlib-bindings : $(src ) /bindings/lib.rs rusttest-prepare FORCE
141
+ $(call if_changed,rustc_test_library)
142
+
138
143
quiet_cmd_rustdoc_test = RUSTDOC T $<
139
144
cmd_rustdoc_test = \
140
145
OBJTREE=$(abspath $(objtree ) ) \
@@ -154,6 +159,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
154
159
@$(objtree ) /include/generated/rustc_cfg \
155
160
-L$(objtree ) /$(obj ) --extern alloc --extern kernel \
156
161
--extern build_error --extern macros \
162
+ --extern bindings \
157
163
--no-run --crate-name kernel -Zunstable-options \
158
164
--test-builder $(srctree ) /scripts/rustdoc_test_builder.py \
159
165
$< $(rustdoc_test_kernel_quiet ) ; \
@@ -234,10 +240,9 @@ rusttest-macros: $(src)/macros/lib.rs rusttest-prepare FORCE
234
240
$(call if_changed,rustdoc_test)
235
241
236
242
rusttest-kernel : private rustc_target_flags = --extern alloc \
237
- --extern build_error --extern macros
238
- rusttest-kernel : private rustc_test_run_flags = --skip bindgen_test_layout_
243
+ --extern build_error --extern macros --extern bindings
239
244
rusttest-kernel : $(src ) /kernel/lib.rs rusttest-prepare \
240
- rusttestlib-build_error rusttestlib-macros FORCE
245
+ rusttestlib-build_error rusttestlib-macros rusttestlib-bindings FORCE
241
246
$(call if_changed,rustc_test)
242
247
$(call if_changed,rustc_test_library)
243
248
@@ -302,24 +307,24 @@ quiet_cmd_bindgen = BINDGEN $@
302
307
--size_t-is-usize -o $@ -- $(bindgen_c_flags_final ) -DMODULE \
303
308
$(bindgen_target_cflags ) $(bindgen_target_extra )
304
309
305
- $(obj ) /bindings_generated.rs : private bindgen_target_flags = \
310
+ $(obj ) /bindings/ bindings_generated.rs : private bindgen_target_flags = \
306
311
$(shell grep -v '^\# \|^$$' $(srctree)/$(src)/bindgen_parameters)
307
- $(obj ) /bindings_generated.rs : $(src ) /kernel /bindings_helper.h \
312
+ $(obj ) /bindings/ bindings_generated.rs : $(src ) /bindings /bindings_helper.h \
308
313
$(src)/bindgen_parameters FORCE
309
314
$(call if_changed_dep,bindgen)
310
315
311
316
# See `CFLAGS_REMOVE_helpers.o` above. In addition, Clang on C does not warn
312
317
# with `-Wmissing-declarations` (unlike GCC), so it is not strictly needed here
313
318
# given it is `libclang`; but for consistency, future Clang changes and/or
314
319
# a potential future GCC backend for `bindgen`, we disable it too.
315
- $(obj ) /bindings_helpers_generated.rs : private bindgen_target_flags = \
320
+ $(obj ) /bindings/ bindings_helpers_generated.rs : private bindgen_target_flags = \
316
321
--blacklist-type '.*' --whitelist-var '' \
317
322
--whitelist-function 'rust_helper_.*'
318
- $(obj ) /bindings_helpers_generated.rs : private bindgen_target_cflags = \
323
+ $(obj ) /bindings/ bindings_helpers_generated.rs : private bindgen_target_cflags = \
319
324
-I$(objtree)/$(obj) -Wno-missing-prototypes -Wno-missing-declarations
320
- $(obj ) /bindings_helpers_generated.rs : private bindgen_target_extra = ; \
325
+ $(obj ) /bindings/ bindings_helpers_generated.rs : private bindgen_target_extra = ; \
321
326
sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/# [link_name="rust_helper_\1"]\n pub fn \1/g' $@
322
- $(obj ) /bindings_helpers_generated.rs : $(src ) /helpers.c FORCE
327
+ $(obj ) /bindings/ bindings_helpers_generated.rs : $(src ) /helpers.c FORCE
323
328
$(call if_changed_dep,bindgen)
324
329
325
330
quiet_cmd_exports = EXPORTS $@
@@ -335,6 +340,9 @@ $(obj)/exports_core_generated.h: $(obj)/core.o FORCE
335
340
$(obj ) /exports_alloc_generated.h : $(obj ) /alloc.o FORCE
336
341
$(call if_changed,exports)
337
342
343
+ $(obj ) /exports_bindings_generated.h : $(obj ) /bindings.o FORCE
344
+ $(call if_changed,exports)
345
+
338
346
$(obj ) /exports_kernel_generated.h : $(obj ) /kernel.o FORCE
339
347
$(call if_changed,exports)
340
348
@@ -388,11 +396,16 @@ $(obj)/alloc.o: $(src)/alloc/lib.rs $(obj)/compiler_builtins.o FORCE
388
396
$(obj ) /build_error.o : $(src ) /build_error.rs $(obj ) /compiler_builtins.o FORCE
389
397
$(call if_changed_dep,rustc_library)
390
398
399
+ $(obj ) /bindings.o : $(src ) /bindings/lib.rs \
400
+ $(obj)/compiler_builtins.o \
401
+ $(obj)/bindings/bindings_generated.rs \
402
+ $(obj)/bindings/bindings_helpers_generated.rs FORCE
403
+ $(call if_changed_dep,rustc_library)
404
+
391
405
$(obj ) /kernel.o : private rustc_target_flags = --extern alloc \
392
- --extern build_error --extern macros
406
+ --extern build_error --extern macros --extern bindings
393
407
$(obj ) /kernel.o : $(src ) /kernel/lib.rs $(obj ) /alloc.o $(obj ) /build_error.o \
394
- $(obj)/libmacros.so $(obj)/bindings_generated.rs \
395
- $(obj)/bindings_helpers_generated.rs FORCE
408
+ $(obj)/libmacros.so $(obj)/bindings.o FORCE
396
409
$(call if_changed_dep,rustc_library)
397
410
398
411
endif # CONFIG_RUST
0 commit comments