Skip to content

Commit 65101b9

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

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
@@ -304,24 +304,24 @@ quiet_cmd_bindgen = BINDGEN $@
304304
--size_t-is-usize -o $@ -- $(bindgen_c_flags_final) -DMODULE \
305305
$(bindgen_target_cflags) $(bindgen_target_extra)
306306

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

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

327327
quiet_cmd_exports = EXPORTS $@
@@ -393,10 +393,10 @@ $(obj)/alloc.o: $(src)/alloc/lib.rs $(obj)/compiler_builtins.o FORCE
393393
$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
394394
$(call if_changed_dep,rustc_library)
395395

396-
$(obj)/bindings.o: $(src)/kernel/bindings.rs \
397-
$(obj)/compiler_builtins.o \
398-
$(obj)/bindings_generated.rs \
399-
$(obj)/bindings_helpers_generated.rs FORCE
396+
$(obj)/bindings.o: $(src)/bindings/lib.rs \
397+
$(obj)/compiler_builtins.o \
398+
$(obj)/bindings/bindings_generated.rs \
399+
$(obj)/bindings/bindings_helpers_generated.rs FORCE
400400
$(call if_changed_dep,rustc_library)
401401

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