rust: syn: enable support in kbuild
With all the new files in place and ready from the new crate, enable the support for it in the build system. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Tested-by: Gary Guo <gary@garyguo.net> Tested-by: Jesung Yang <y.j3ms.n@gmail.com> Link: https://patch.msgid.link/20251124151837.2184382-20-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>pull/1354/merge
parent
1112ba8655
commit
737401751a
1
Makefile
1
Makefile
|
|
@ -1835,6 +1835,7 @@ rustfmt:
|
||||||
\( \
|
\( \
|
||||||
-path $(srctree)/rust/proc-macro2 \
|
-path $(srctree)/rust/proc-macro2 \
|
||||||
-o -path $(srctree)/rust/quote \
|
-o -path $(srctree)/rust/quote \
|
||||||
|
-o -path $(srctree)/rust/syn \
|
||||||
\) -prune -o \
|
\) -prune -o \
|
||||||
-type f -a -name '*.rs' -a ! -name '*generated*' -print \
|
-type f -a -name '*.rs' -a ! -name '*generated*' -print \
|
||||||
| xargs $(RUSTFMT) $(rustfmt_flags)
|
| xargs $(RUSTFMT) $(rustfmt_flags)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ endif
|
||||||
|
|
||||||
obj-$(CONFIG_RUST) += exports.o
|
obj-$(CONFIG_RUST) += exports.o
|
||||||
|
|
||||||
always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib
|
always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
|
||||||
|
|
||||||
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
|
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
|
||||||
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
|
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
|
||||||
|
|
@ -101,6 +101,22 @@ quote-flags := \
|
||||||
--extern proc_macro2 \
|
--extern proc_macro2 \
|
||||||
$(call cfgs-to-flags,$(quote-cfgs))
|
$(call cfgs-to-flags,$(quote-cfgs))
|
||||||
|
|
||||||
|
# `extra-traits`, `fold` and `visit` may be enabled if needed.
|
||||||
|
syn-cfgs := \
|
||||||
|
feature="clone-impls" \
|
||||||
|
feature="derive" \
|
||||||
|
feature="full" \
|
||||||
|
feature="parsing" \
|
||||||
|
feature="printing" \
|
||||||
|
feature="proc-macro" \
|
||||||
|
feature="visit-mut"
|
||||||
|
|
||||||
|
syn-flags := \
|
||||||
|
--cap-lints=allow \
|
||||||
|
--extern proc_macro2 \
|
||||||
|
--extern quote \
|
||||||
|
$(call cfgs-to-flags,$(syn-cfgs))
|
||||||
|
|
||||||
# `rustdoc` did not save the target modifiers, thus workaround for
|
# `rustdoc` did not save the target modifiers, thus workaround for
|
||||||
# the time being (https://github.com/rust-lang/rust/issues/144521).
|
# the time being (https://github.com/rust-lang/rust/issues/144521).
|
||||||
rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
|
rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
|
||||||
|
|
@ -161,11 +177,16 @@ rustdoc-quote: private skip_flags = $(quote-skip_flags)
|
||||||
rustdoc-quote: $(src)/quote/lib.rs rustdoc-clean rustdoc-proc_macro2 FORCE
|
rustdoc-quote: $(src)/quote/lib.rs rustdoc-clean rustdoc-proc_macro2 FORCE
|
||||||
+$(call if_changed,rustdoc)
|
+$(call if_changed,rustdoc)
|
||||||
|
|
||||||
|
rustdoc-syn: private rustdoc_host = yes
|
||||||
|
rustdoc-syn: private rustc_target_flags = $(syn-flags)
|
||||||
|
rustdoc-syn: $(src)/syn/lib.rs rustdoc-clean rustdoc-quote FORCE
|
||||||
|
+$(call if_changed,rustdoc)
|
||||||
|
|
||||||
rustdoc-macros: private rustdoc_host = yes
|
rustdoc-macros: private rustdoc_host = yes
|
||||||
rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
|
rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
|
||||||
--extern proc_macro
|
--extern proc_macro
|
||||||
rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean rustdoc-proc_macro2 \
|
rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean rustdoc-proc_macro2 \
|
||||||
rustdoc-quote FORCE
|
rustdoc-quote rustdoc-syn FORCE
|
||||||
+$(call if_changed,rustdoc)
|
+$(call if_changed,rustdoc)
|
||||||
|
|
||||||
# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
|
# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
|
||||||
|
|
@ -231,6 +252,10 @@ rusttestlib-quote: private rustc_target_flags = $(quote-flags)
|
||||||
rusttestlib-quote: $(src)/quote/lib.rs rusttestlib-proc_macro2 FORCE
|
rusttestlib-quote: $(src)/quote/lib.rs rusttestlib-proc_macro2 FORCE
|
||||||
+$(call if_changed,rustc_test_library)
|
+$(call if_changed,rustc_test_library)
|
||||||
|
|
||||||
|
rusttestlib-syn: private rustc_target_flags = $(syn-flags)
|
||||||
|
rusttestlib-syn: $(src)/syn/lib.rs rusttestlib-quote FORCE
|
||||||
|
+$(call if_changed,rustc_test_library)
|
||||||
|
|
||||||
rusttestlib-macros: private rustc_target_flags = --extern proc_macro
|
rusttestlib-macros: private rustc_target_flags = --extern proc_macro
|
||||||
rusttestlib-macros: private rustc_test_library_proc = yes
|
rusttestlib-macros: private rustc_test_library_proc = yes
|
||||||
rusttestlib-macros: $(src)/macros/lib.rs FORCE
|
rusttestlib-macros: $(src)/macros/lib.rs FORCE
|
||||||
|
|
@ -488,6 +513,11 @@ $(obj)/libquote.rlib: private rustc_target_flags = $(quote-flags)
|
||||||
$(obj)/libquote.rlib: $(src)/quote/lib.rs $(obj)/libproc_macro2.rlib FORCE
|
$(obj)/libquote.rlib: $(src)/quote/lib.rs $(obj)/libproc_macro2.rlib FORCE
|
||||||
+$(call if_changed_dep,rustc_procmacrolibrary)
|
+$(call if_changed_dep,rustc_procmacrolibrary)
|
||||||
|
|
||||||
|
$(obj)/libsyn.rlib: private skip_clippy = 1
|
||||||
|
$(obj)/libsyn.rlib: private rustc_target_flags = $(syn-flags)
|
||||||
|
$(obj)/libsyn.rlib: $(src)/syn/lib.rs $(obj)/libquote.rlib FORCE
|
||||||
|
+$(call if_changed_dep,rustc_procmacrolibrary)
|
||||||
|
|
||||||
quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
|
quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
|
||||||
cmd_rustc_procmacro = \
|
cmd_rustc_procmacro = \
|
||||||
$(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \
|
$(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \
|
||||||
|
|
@ -500,7 +530,7 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
|
||||||
|
|
||||||
# Procedural macros can only be used with the `rustc` that compiled it.
|
# Procedural macros can only be used with the `rustc` that compiled it.
|
||||||
$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib \
|
$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib \
|
||||||
$(obj)/libquote.rlib FORCE
|
$(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
|
||||||
+$(call if_changed_dep,rustc_procmacro)
|
+$(call if_changed_dep,rustc_procmacro)
|
||||||
|
|
||||||
$(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel
|
$(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel
|
||||||
|
|
@ -525,6 +555,7 @@ rust-analyzer:
|
||||||
--cfgs='core=$(core-cfgs)' $(core-edition) \
|
--cfgs='core=$(core-cfgs)' $(core-edition) \
|
||||||
--cfgs='proc_macro2=$(proc_macro2-cfgs)' \
|
--cfgs='proc_macro2=$(proc_macro2-cfgs)' \
|
||||||
--cfgs='quote=$(quote-cfgs)' \
|
--cfgs='quote=$(quote-cfgs)' \
|
||||||
|
--cfgs='syn=$(syn-cfgs)' \
|
||||||
$(realpath $(srctree)) $(realpath $(objtree)) \
|
$(realpath $(srctree)) $(realpath $(objtree)) \
|
||||||
$(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(srcroot)) \
|
$(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(srcroot)) \
|
||||||
> rust-project.json
|
> rust-project.json
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,13 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
|
||||||
cfg=crates_cfgs["quote"],
|
cfg=crates_cfgs["quote"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
append_crate(
|
||||||
|
"syn",
|
||||||
|
srctree / "rust" / "syn" / "lib.rs",
|
||||||
|
["proc_macro", "proc_macro2", "quote"],
|
||||||
|
cfg=crates_cfgs["syn"],
|
||||||
|
)
|
||||||
|
|
||||||
append_crate(
|
append_crate(
|
||||||
"macros",
|
"macros",
|
||||||
srctree / "rust" / "macros" / "lib.rs",
|
srctree / "rust" / "macros" / "lib.rs",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue