Skip to content

Commit 521024c

Browse files
committed
Move bindings related code to rust/bindings
Signed-off-by: Björn Roy Baron <[email protected]>
1 parent b0ec4c8 commit 521024c

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

rust/Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CFLAGS_REMOVE_helpers.o = -Wmissing-prototypes -Wmissing-declarations
1414
always-$(CONFIG_RUST) += libmacros.so
1515
no-clean-files += libmacros.so
1616

17-
always-$(CONFIG_RUST) += bindings_generated.rs bindings_helpers_generated.rs
17+
always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs
1818
obj-$(CONFIG_RUST) += alloc.o bindings.o kernel.o
1919
always-$(CONFIG_RUST) += exports_alloc_generated.h exports_bindings_generated.h \
2020
exports_kernel_generated.h
@@ -307,24 +307,24 @@ quiet_cmd_bindgen = BINDGEN $@
307307
--size_t-is-usize -o $@ -- $(bindgen_c_flags_final) -DMODULE \
308308
$(bindgen_target_cflags) $(bindgen_target_extra)
309309

310-
$(obj)/bindings_generated.rs: private bindgen_target_flags = \
310+
$(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \
311311
$(shell grep -v '^\#\|^$$' $(srctree)/$(src)/bindgen_parameters)
312-
$(obj)/bindings_generated.rs: $(src)/kernel/bindings_helper.h \
312+
$(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \
313313
$(src)/bindgen_parameters FORCE
314314
$(call if_changed_dep,bindgen)
315315

316316
# See `CFLAGS_REMOVE_helpers.o` above. In addition, Clang on C does not warn
317317
# with `-Wmissing-declarations` (unlike GCC), so it is not strictly needed here
318318
# given it is `libclang`; but for consistency, future Clang changes and/or
319319
# a potential future GCC backend for `bindgen`, we disable it too.
320-
$(obj)/bindings_helpers_generated.rs: private bindgen_target_flags = \
320+
$(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_flags = \
321321
--blacklist-type '.*' --whitelist-var '' \
322322
--whitelist-function 'rust_helper_.*'
323-
$(obj)/bindings_helpers_generated.rs: private bindgen_target_cflags = \
323+
$(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_cflags = \
324324
-I$(objtree)/$(obj) -Wno-missing-prototypes -Wno-missing-declarations
325-
$(obj)/bindings_helpers_generated.rs: private bindgen_target_extra = ; \
325+
$(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_extra = ; \
326326
sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/#[link_name="rust_helper_\1"]\n pub fn \1/g' $@
327-
$(obj)/bindings_helpers_generated.rs: $(src)/helpers.c FORCE
327+
$(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers.c FORCE
328328
$(call if_changed_dep,bindgen)
329329

330330
quiet_cmd_exports = EXPORTS $@
@@ -396,10 +396,10 @@ $(obj)/alloc.o: $(src)/alloc/lib.rs $(obj)/compiler_builtins.o FORCE
396396
$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
397397
$(call if_changed_dep,rustc_library)
398398

399-
$(obj)/bindings.o: $(src)/kernel/bindings.rs \
400-
$(obj)/compiler_builtins.o \
401-
$(obj)/bindings_generated.rs \
402-
$(obj)/bindings_helpers_generated.rs FORCE
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
403403
$(call if_changed_dep,rustc_library)
404404

405405
$(obj)/kernel.o: private rustc_target_flags = --extern alloc \
File renamed without changes.

rust/kernel/bindings.rs renamed to rust/bindings/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ mod bindings_raw {
2929
// Use glob import here to expose all helpers.
3030
// Symbols defined within the module will take precedence to the glob import.
3131
pub use super::bindings_helper::*;
32-
include!(concat!(env!("OBJTREE"), "/rust/bindings_generated.rs"));
32+
include!(concat!(
33+
env!("OBJTREE"),
34+
"/rust/bindings/bindings_generated.rs"
35+
));
3336
}
3437

3538
// When both a directly exposed symbol and a helper exists for the same function,
@@ -41,7 +44,7 @@ mod bindings_helper {
4144
use super::bindings_raw::*;
4245
include!(concat!(
4346
env!("OBJTREE"),
44-
"/rust/bindings_helpers_generated.rs"
47+
"/rust/bindings/bindings_helpers_generated.rs"
4548
));
4649
}
4750

scripts/generate_rust_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def append_crate(display_name, root_module, deps, cfg=[], is_workspace_member=Tr
7575

7676
append_crate(
7777
"bindings",
78-
srctree / "rust"/ "kernel" / "bindings.rs",
78+
srctree / "rust"/ "bindings" / "lib.rs",
7979
["core"],
8080
cfg=cfg,
8181
)

0 commit comments

Comments
 (0)