Skip to content

Commit

Permalink
kbuild: rust: move rust/target.json to scripts/
Browse files Browse the repository at this point in the history
scripts/ is a better place to generate files used treewide.

With target.json moved to scripts/, you do not need to add target.json
to no-clean-files or MRPROPER_FILES.

'make clean' does not visit scripts/, but 'make mrproper' does.

Signed-off-by: Masahiro Yamada <[email protected]>
Reviewed-by: Miguel Ojeda <[email protected]>
Tested-by: Miguel Ojeda <[email protected]>
  • Loading branch information
masahir0y committed Jan 22, 2023
1 parent 93c656d commit c83b16c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
-std=gnu11
KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_RUSTFLAGS := $(rust_common_flags) \
--target=$(objtree)/rust/target.json \
--target=$(objtree)/scripts/target.json \
-Cpanic=abort -Cembed-bitcode=n -Clto=n \
-Cforce-unwind-tables=n -Ccodegen-units=1 \
-Csymbol-mangling-version=v0 \
Expand Down Expand Up @@ -1606,7 +1606,7 @@ MRPROPER_FILES += include/config include/generated \
certs/x509.genkey \
vmlinux-gdb.py \
*.spec \
rust/target.json rust/libmacros.so
rust/libmacros.so

# clean - Delete most, but leave enough to build external modules
#
Expand Down
1 change: 0 additions & 1 deletion rust/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: GPL-2.0

target.json
bindings_generated.rs
bindings_helpers_generated.rs
exports_*_generated.h
Expand Down
10 changes: 1 addition & 9 deletions rust/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-2.0

always-$(CONFIG_RUST) += target.json
no-clean-files += target.json

obj-$(CONFIG_RUST) += core.o compiler_builtins.o
always-$(CONFIG_RUST) += exports_core_generated.h

Expand Down Expand Up @@ -231,11 +228,6 @@ rusttest-kernel: $(src)/kernel/lib.rs rusttest-prepare \
$(call if_changed,rustc_test)
$(call if_changed,rustc_test_library)

filechk_rust_target = $(objtree)/scripts/generate_rust_target < $<

$(obj)/target.json: $(objtree)/include/config/auto.conf FORCE
$(call filechk,rust_target)

ifdef CONFIG_CC_IS_CLANG
bindgen_c_flags = $(c_flags)
else
Expand Down Expand Up @@ -359,7 +351,7 @@ rust-analyzer:
$(obj)/core.o: private skip_clippy = 1
$(obj)/core.o: private skip_flags = -Dunreachable_pub
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs $(obj)/target.json FORCE
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE
$(call if_changed_dep,rustc_library)

$(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*'
Expand Down
1 change: 1 addition & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
/recordmcount
/sign-file
/sorttable
/target.json
/unifdef
8 changes: 7 additions & 1 deletion scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ hostprogs-always-$(CONFIG_BUILDTIME_TABLE_SORT) += sorttable
hostprogs-always-$(CONFIG_ASN1) += asn1_compiler
hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file
hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
hostprogs-always-$(CONFIG_RUST) += generate_rust_target
always-$(CONFIG_RUST) += target.json

filechk_rust_target = $< < include/config/auto.conf

$(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE
$(call filechk,rust_target)

hostprogs += generate_rust_target
generate_rust_target-rust := y

HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
Expand Down
2 changes: 2 additions & 0 deletions scripts/remove-stale-files
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ rm -f arch/x86/purgatory/kexec-purgatory.c
rm -f scripts/extract-cert

rm -f scripts/kconfig/[gmnq]conf-cfg

rm -f rust/target.json

0 comments on commit c83b16c

Please sign in to comment.