Skip to content

Commit 1022121

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

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_kernel_generated.h
2020

@@ -303,24 +303,24 @@ quiet_cmd_bindgen = BINDGEN $@
303303
--size_t-is-usize -o $@ -- $(bindgen_c_flags_final) -DMODULE \
304304
$(bindgen_target_cflags) $(bindgen_target_extra)
305305

306-
$(obj)/bindings_generated.rs: private bindgen_target_flags = \
306+
$(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \
307307
$(shell grep -v '^\#\|^$$' $(srctree)/$(src)/bindgen_parameters)
308-
$(obj)/bindings_generated.rs: $(src)/kernel/bindings_helper.h \
308+
$(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \
309309
$(src)/bindgen_parameters FORCE
310310
$(call if_changed_dep,bindgen)
311311

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

326326
quiet_cmd_exports = EXPORTS $@
@@ -389,10 +389,10 @@ $(obj)/alloc.o: $(src)/alloc/lib.rs $(obj)/compiler_builtins.o FORCE
389389
$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
390390
$(call if_changed_dep,rustc_library)
391391

392-
$(obj)/bindings.o: $(src)/kernel/bindings.rs \
393-
$(obj)/compiler_builtins.o \
394-
$(obj)/bindings_generated.rs \
395-
$(obj)/bindings_helpers_generated.rs FORCE
392+
$(obj)/bindings.o: $(src)/bindings/lib.rs \
393+
$(obj)/compiler_builtins.o \
394+
$(obj)/bindings/bindings_generated.rs \
395+
$(obj)/bindings/bindings_helpers_generated.rs FORCE
396396
$(call if_changed_dep,rustc_library)
397397

398398
$(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)