[PATCH 1/1] test: Skip cleanup test if not built out of tree

2024-01-08 Thread Tobias Deiminger
42c0e5bb054d ("test: Find leftovers after clean/mrproper") assumes out
of tree builds. test_clean and test_mrproper fail if the assumption
isn't met.

However there are valid scenarios where tests run with in source builds
(i.e., test.py --build-dir=.).

Automatically skip cleanup tests in such scenarios to prevent false
positives.

Signed-off-by: Tobias Deiminger 
---
 test/py/tests/test_cleanup_build.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/test/py/tests/test_cleanup_build.py 
b/test/py/tests/test_cleanup_build.py
index 5206ff73ec..aca90cb110 100644
--- a/test/py/tests/test_cleanup_build.py
+++ b/test/py/tests/test_cleanup_build.py
@@ -17,6 +17,11 @@ import pytest
 @pytest.fixture
 def tmp_copy_of_builddir(u_boot_config, tmp_path):
 """For each test, provide a temporary copy of the initial build 
directory."""
+if os.path.realpath(u_boot_config.source_dir) == os.path.realpath(
+u_boot_config.build_dir
+):
+pytest.skip("Leftover detection requires out of tree build.")
+return None
 shutil.copytree(
 u_boot_config.build_dir,
 tmp_path,
-- 
2.30.2



[PATCH 0/1] Skip cleanup test if not built out of tree

2024-01-08 Thread Tobias Deiminger
This patch avoids false positives in cases where tests are invoked with
test.py --build-dir=./ . 

See tbot issue 107 [1] for motivation and prior discussion.

Previously it resulted in:
E   AssertionError: leftovers: net/mdio-uclass.c, net/bootp.c, [...]

Now it results in:
SKIPPED [2] test/py/tests/test_cleanup_build.py:23: Leftover detection
requires out of tree build.

[1] https://github.com/Rahix/tbot/issues/107#issuecomment-1880192186

Tobias Deiminger (1):
  test: Skip cleanup test if not built out of tree

 test/py/tests/test_cleanup_build.py | 5 +
 1 file changed, 5 insertions(+)


base-commit: 93d91e9485d902a1836a22e72d1a545b587adf36
-- 
2.30.2



[PATCH v2 6/6] test: Find leftovers after clean/mrproper

2023-06-19 Thread Tobias Deiminger
Docs describe 'make clean' to delete most generated files, 'make
mrproper' to delete current configuration and all generated files. This
test tries to assert it.

Idea is to search remaining files by patterns in copies of the initial
out-of-source build, which has two advantages:
- looking in an out-of-source build dir allows to tell generated source
  code from committed source code
- copying is fast (compared to rebuilding each time) which allows to do
  a "world clean"

Signed-off-by: Tobias Deiminger 
---
 test/py/tests/test_cleanup_build.py | 105 
 1 file changed, 105 insertions(+)
 create mode 100644 test/py/tests/test_cleanup_build.py

diff --git a/test/py/tests/test_cleanup_build.py 
b/test/py/tests/test_cleanup_build.py
new file mode 100644
index 00..5206ff73ec
--- /dev/null
+++ b/test/py/tests/test_cleanup_build.py
@@ -0,0 +1,105 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Tobias Deiminger 
+
+"""Test for unexpected leftovers after make clean"""
+
+import itertools
+import os
+import pathlib
+import shutil
+import sys
+
+import pytest
+
+# pylint: disable=redefined-outer-name
+
+
+@pytest.fixture
+def tmp_copy_of_builddir(u_boot_config, tmp_path):
+"""For each test, provide a temporary copy of the initial build 
directory."""
+shutil.copytree(
+u_boot_config.build_dir,
+tmp_path,
+symlinks=True,
+dirs_exist_ok=True,
+)
+return tmp_path
+
+
+@pytest.fixture(scope="module")
+def run_make(u_boot_log):
+"""Provide function to run and log make without connecting to u-boot 
console."""
+runner = u_boot_log.get_runner("make", sys.stdout)
+
+def _run_make(build_dir, target):
+cmd = ["make", f"O={build_dir}", target]
+runner.run(cmd)
+
+yield _run_make
+runner.close()
+
+
+@pytest.fixture(scope="module")
+def most_generated_files():
+"""Path.glob style patterns to describe what should be removed by 'make 
clean'."""
+return (
+"**/*.c",
+"**/*.dtb",
+"**/*.dtbo",
+"**/*.o",
+"**/*.py",
+"**/*.pyc",
+"**/*.so",
+"**/*.srec",
+"u-boot*",
+"[svt]pl/u-boot*",
+)
+
+
+@pytest.fixture(scope="module")
+def all_generated_files(most_generated_files):
+"""Path.glob style patterns to describe what should be removed by 'make 
mrproper'."""
+return most_generated_files + (".config", "**/*.h")
+
+
+def find_files(search_dir, include_patterns, exclude_dirs=None):
+"""Find files matching include_patterns, unless it's in one of 
exclude_dirs.
+
+include_patterns -- Path.glob style pattern relative to search dir
+exclude_dir -- directories to exclude, expected relative to search dir
+"""
+matches = []
+exclude_dirs = [] if exclude_dirs is None else exclude_dirs
+for abs_path in itertools.chain.from_iterable(
+pathlib.Path(search_dir).glob(pattern) for pattern in include_patterns
+):
+if abs_path.is_dir():
+continue
+rel_path = pathlib.Path(os.path.relpath(abs_path, search_dir))
+if not any(
+rel_path.is_relative_to(exclude_dir) for exclude_dir in 
exclude_dirs
+):
+matches.append(rel_path)
+return matches
+
+
+def test_clean(run_make, tmp_copy_of_builddir, most_generated_files):
+"""Test if 'make clean' deletes most generated files."""
+run_make(tmp_copy_of_builddir, "clean")
+leftovers = find_files(
+tmp_copy_of_builddir,
+most_generated_files,
+exclude_dirs=["scripts", "test/overlay"],
+)
+assert not leftovers, f"leftovers: {', '.join(map(str, leftovers))}"
+
+
+def test_mrproper(run_make, tmp_copy_of_builddir, all_generated_files):
+"""Test if 'make mrproper' deletes current configuration and all generated 
files."""
+run_make(tmp_copy_of_builddir, "mrproper")
+leftovers = find_files(
+tmp_copy_of_builddir,
+all_generated_files,
+exclude_dirs=["test/overlay"],
+)
+assert not leftovers, f"leftovers: {', '.join(map(str, leftovers))}"
-- 
2.30.2



[PATCH v2 5/6] Kbuild: Fix cleanup of *.dtbo for sandbox

2023-06-19 Thread Tobias Deiminger
sandbox can generate DT overlays, but they were not cleaned.

Extend the explicit clean-files list accordingly.

Fixes: 95300f203f32 ("pytest: add sandbox test for "extension" command")
Signed-off-by: Tobias Deiminger 
---
 arch/sandbox/dts/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile
index b6a88479b2..f810b4752f 100644
--- a/arch/sandbox/dts/Makefile
+++ b/arch/sandbox/dts/Makefile
@@ -18,4 +18,4 @@ PHONY += dtbs
 dtbs: $(addprefix $(obj)/, $(dtb-y))
@:
 
-clean-files := *.dtb
+clean-files := *.dtb *.dtbo
-- 
2.30.2



[PATCH v2 4/6] Kbuild: Fix cleanup of *.dtb for some archs

2023-06-19 Thread Tobias Deiminger
'make clean' did not descend into arch/$ARCH/dts for arc, m68k, nios2,
sh, xtensa.

Fix it by adding the missing archs to the explicit clean-dirs list.

Signed-off-by: Tobias Deiminger 
---
 dts/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dts/Makefile b/dts/Makefile
index cb31113829..3437e54033 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -63,4 +63,6 @@ spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
 clean-files := dt.dtb.S
 
 # Let clean descend into dts directories
-subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts 
../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts
+subdir- += ../arch/arc/dts ../arch/arm/dts ../arch/m68k/dts 
../arch/microblaze/dts \
+  ../arch/mips/dts ../arch/nios2/dts ../arch/powerpc/dts 
../arch/riscv/dts \
+  ../arch/sandbox/dts ../arch/sh/dts ../arch/x86/dts ../arch/xtensa/dts
-- 
2.30.2



[PATCH v2 3/6] Kbuild: Fix cleanup of VPL

2023-06-19 Thread Tobias Deiminger
VPL artifacts like example vpl/u-boot-vpl are currently not removed by
'make clean'.

We can clean them just as it's already done for SPL and TPL.

Fixes: f86ca5ad8f78 ("Introduce Verifying Program Loader (VPL)")
Signed-off-by: Tobias Deiminger 
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 444baaefd0..febe9c31d9 100644
--- a/Makefile
+++ b/Makefile
@@ -2148,7 +2148,7 @@ CHANGELOG:
 
 # Directories & files removed with 'make clean'
 CLEAN_DIRS  += $(MODVERDIR) \
-  $(foreach d, spl tpl, $(patsubst %,$d/%, \
+  $(foreach d, spl tpl vpl, $(patsubst %,$d/%, \
$(filter-out include, $(shell ls -1 $d 2>/dev/null
 
 CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
@@ -2163,7 +2163,7 @@ CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h 
\
   idbloader-spi.img lib/efi_loader/helloworld_efi.S
 
 # Directories & files removed with 'make mrproper'
-MRPROPER_DIRS  += include/config include/generated spl tpl \
+MRPROPER_DIRS  += include/config include/generated spl tpl vpl \
  .tmp_objdiff doc/output include/asm
 
 # Remove include/asm symlink created by U-Boot before v2014.01
-- 
2.30.2



[PATCH v2 2/6] Adjust gitignore for tools/generated/

2023-06-19 Thread Tobias Deiminger
Tell git that auto-generated C sources are now exclusively expected
under tools/generated/.

Signed-off-by: Tobias Deiminger 
---
 tools/.gitignore | 1 +
 tools/env/.gitignore | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/.gitignore b/tools/.gitignore
index cda3ea628c..941d38de21 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -34,6 +34,7 @@
 /relocate-rela
 /spl_size_limit
 /sunxi-spl-image-builder
+/tools/generated/**/*.c
 /update_octeon_header
 /version.h
 /xway-swap-bytes
diff --git a/tools/env/.gitignore b/tools/env/.gitignore
index 8d28b2b70b..804abacc6e 100644
--- a/tools/env/.gitignore
+++ b/tools/env/.gitignore
@@ -1,3 +1,2 @@
-embedded.c
 fw_printenv
 fw_printenv_unstripped
-- 
2.30.2



[PATCH v2 1/6] Kbuild: Fix cleanup of generated sources in tools

2023-06-19 Thread Tobias Deiminger
On 'make clean', generated C files in tools/env/ and tools/boot/ are
currently not removed, but they should.

Auto-generation for shared sources was first introduced with
ad80c4a3220b ("kbuild, tools: generate wrapper C sources automatically
by Makefile"). Cleanup later regressed (see Fixes:), because shared
files were moved out of lib/ and common/, but 'clean-dirs := lib common'
was not adjusted accordingly. Further, the generated
tools/env/embedded.c became a sibling to project files, which prevents
directory-wise cleanup at all.

To solve it, we establishe tools/generated/ as the sole place for
generated sources. Wrappers are now generated as
tools/generated//, and 'make clean' can
remove tools/generated/ as a whole (Linux Makefile.asm-generic headers
are cleaned similarly). This way we don't have to maintain separate
clean-files or clean-dirs entries for each single added or moved wrapper
file.

Fixes: 0649cd0d4908 ("Move environment files from common/ to env/")
Fixes: 19a91f2464a8 ("Create a new boot/ directory")
Signed-off-by: Tobias Deiminger 
---
 tools/Makefile | 64 +-
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index d793cf3bec..d6835b24b0 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -48,20 +48,20 @@ hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo
 HOSTCFLAGS_bmp_logo.o := -pedantic
 
 hostprogs-$(BUILD_ENVCRC) += envcrc
-envcrc-objs := envcrc.o lib/crc32.o env/embedded.o lib/sha1.o
+envcrc-objs := envcrc.o generated/lib/crc32.o generated/env/embedded.o 
generated/lib/sha1.o
 
 hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr
 HOSTCFLAGS_gen_eth_addr.o := -pedantic
 
 hostprogs-$(CONFIG_CMD_NET) += gen_ethaddr_crc
-gen_ethaddr_crc-objs := gen_ethaddr_crc.o lib/crc8.o
+gen_ethaddr_crc-objs := gen_ethaddr_crc.o generated/lib/crc8.o
 HOSTCFLAGS_gen_ethaddr_crc.o := -pedantic
 
 hostprogs-$(CONFIG_CMD_LOADS) += img2srec
 HOSTCFLAGS_img2srec.o := -pedantic
 
 hostprogs-y += mkenvimage
-mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o
+mkenvimage-objs := mkenvimage.o os_support.o generated/lib/crc32.o
 
 hostprogs-y += dumpimage mkimage
 hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign
@@ -71,30 +71,30 @@ ifneq 
($(CONFIG_CMD_BOOTEFI_SELFTEST)$(CONFIG_FWU_MDATA_GPT_BLK),)
 hostprogs-y += file2include
 endif
 
-FIT_OBJS-y := fit_common.o fit_image.o image-host.o boot/image-fit.o
-FIT_SIG_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := image-sig-host.o boot/image-fit-sig.o
-FIT_CIPHER_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := boot/image-cipher.o
+FIT_OBJS-y := fit_common.o fit_image.o image-host.o generated/boot/image-fit.o
+FIT_SIG_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := image-sig-host.o 
generated/boot/image-fit-sig.o
+FIT_CIPHER_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := generated/boot/image-cipher.o
 
 # The following files are synced with upstream DTC.
 # Use synced versions from scripts/dtc/libfdt/.
 LIBFDT_OBJS := $(addprefix libfdt/, fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o 
\
fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o)
 
-RSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/rsa/, \
+RSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix generated/lib/rsa/, \
rsa-sign.o rsa-verify.o \
rsa-mod-exp.o)
 
-ECDSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/ecdsa/, 
ecdsa-libcrypto.o)
+ECDSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix generated/lib/ecdsa/, 
ecdsa-libcrypto.o)
 
-AES_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/aes/, \
+AES_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix generated/lib/aes/, \
aes-encrypt.o aes-decrypt.o)
 
 # Cryptographic helpers and image types that depend on openssl/libcrypto
 LIBCRYPTO_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := \
-   lib/fdt-libcrypto.o \
+   generated/lib/fdt-libcrypto.o \
sunxi_toc0.o
 
-ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
+ROCKCHIP_OBS = generated/lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
 
 # common objs for dumpimage and mkimage
 dumpimage-mkimage-objs := aisimage.o \
@@ -102,20 +102,20 @@ dumpimage-mkimage-objs := aisimage.o \
$(FIT_OBJS-y) \
$(FIT_SIG_OBJS-y) \
$(FIT_CIPHER_OBJS-y) \
-   boot/fdt_region.o \
-   boot/bootm.o \
-   lib/crc32.o \
+   generated/boot/fdt_region.o \
+   generated/boot/bootm.o \
+   generated/lib/crc32.o \
default_image.o \
-   lib/fdtdec_common.o \
-   lib/fdtdec.o \
-   boot/image.o \
-   boot/image-host.o \
+   

[PATCH v2 0/6] Kbuild: Fix cleanup of generated sources in tools (and more)

2023-06-19 Thread Tobias Deiminger
This patch series fixes various unexpected leftovers after running
make clean and make mrproper.

The test suggested during review of v1 [0] revealed more cleanup related
issues. I thought it's best to fix them all together in a somewhat
extended v2, to let the new test pass without cheating.

Changes in v2:
- add test for 'make clean' and 'make mrproper'
- fix found issues until test passes
- move .gitignore changes to separate commit

[0] 
http://patchwork.ozlabs.org/project/uboot/patch/20230614113954.51812-2-tobias.deimin...@linutronix.de/

Tobias Deiminger (6):
  Kbuild: Fix cleanup of generated sources in tools
  Adjust gitignore for tools/generated/
  Kbuild: Fix cleanup of VPL
  Kbuild: Fix cleanup of *.dtb for some archs
  Kbuild: Fix cleanup of *.dtbo for sandbox
  test: Find leftovers after clean/mrproper

 Makefile|   4 +-
 arch/sandbox/dts/Makefile   |   2 +-
 dts/Makefile|   4 +-
 test/py/tests/test_cleanup_build.py | 105 
 tools/.gitignore|   1 +
 tools/Makefile  |  64 -
 tools/env/.gitignore|   1 -
 7 files changed, 144 insertions(+), 37 deletions(-)
 create mode 100644 test/py/tests/test_cleanup_build.py


base-commit: 50842b217fef505a0ec6662cc2acdc55d0bb23c5
-- 
2.30.2



Re: [PATCH 1/1] Kbuild: Fix cleanup of generated sources in tools

2023-06-16 Thread Tobias Deiminger
Am Do, 15. Jun 23 10:14 schrieb Simon Glass :
> If you like, it would be possible to create a test that all files are
> removed, by doing a build and then looking for stray files. See for
> example test_of_migrate.

Good idea, thanks for the pointer. I'll add a test and include it in v2 of the
patch.

Just noticed that tools/generated/**/*.c should be added to tools/.gitignore,
which will also be done in v2.


[PATCH 1/1] Kbuild: Fix cleanup of generated sources in tools

2023-06-14 Thread Tobias Deiminger
On 'make clean', generated C files in tools/env/ and tools/boot/ are
currently not removed, but they should.

Auto-generation for shared sources was first introduced with
ad80c4a3220b ("kbuild, tools: generate wrapper C sources automatically
by Makefile"). Cleanup later regressed (see Fixes:), because shared
files were moved out of lib/ and common/, but 'clean-dirs := lib common'
was not adjusted accordingly. Further, the generated
tools/env/embedded.c became a sibling to project files, which prevents
directory-wise cleanup at all.

To solve it, we established tools/generated/ as the sole place for
generated sources. Wrappers are now generated as
tools/generated//, and 'make clean' can
remove tools/generated/ as a whole (Linux Makefile.asm-generic headers
are cleaned similarly). This way we don't have to maintain separate
clean-files or clean-dirs entries for each single added or moved wrapper
file.

Fixes: 0649cd0d4908 ("Move environment files from common/ to env/")
Fixes: 19a91f2464a8 ("Create a new boot/ directory")
Signed-off-by: Tobias Deiminger 
---
 tools/Makefile   | 64 ++--
 tools/env/.gitignore |  1 -
 2 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index d793cf3bec..d6835b24b0 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -48,20 +48,20 @@ hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo
 HOSTCFLAGS_bmp_logo.o := -pedantic
 
 hostprogs-$(BUILD_ENVCRC) += envcrc
-envcrc-objs := envcrc.o lib/crc32.o env/embedded.o lib/sha1.o
+envcrc-objs := envcrc.o generated/lib/crc32.o generated/env/embedded.o 
generated/lib/sha1.o
 
 hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr
 HOSTCFLAGS_gen_eth_addr.o := -pedantic
 
 hostprogs-$(CONFIG_CMD_NET) += gen_ethaddr_crc
-gen_ethaddr_crc-objs := gen_ethaddr_crc.o lib/crc8.o
+gen_ethaddr_crc-objs := gen_ethaddr_crc.o generated/lib/crc8.o
 HOSTCFLAGS_gen_ethaddr_crc.o := -pedantic
 
 hostprogs-$(CONFIG_CMD_LOADS) += img2srec
 HOSTCFLAGS_img2srec.o := -pedantic
 
 hostprogs-y += mkenvimage
-mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o
+mkenvimage-objs := mkenvimage.o os_support.o generated/lib/crc32.o
 
 hostprogs-y += dumpimage mkimage
 hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign
@@ -71,30 +71,30 @@ ifneq 
($(CONFIG_CMD_BOOTEFI_SELFTEST)$(CONFIG_FWU_MDATA_GPT_BLK),)
 hostprogs-y += file2include
 endif
 
-FIT_OBJS-y := fit_common.o fit_image.o image-host.o boot/image-fit.o
-FIT_SIG_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := image-sig-host.o boot/image-fit-sig.o
-FIT_CIPHER_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := boot/image-cipher.o
+FIT_OBJS-y := fit_common.o fit_image.o image-host.o generated/boot/image-fit.o
+FIT_SIG_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := image-sig-host.o 
generated/boot/image-fit-sig.o
+FIT_CIPHER_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := generated/boot/image-cipher.o
 
 # The following files are synced with upstream DTC.
 # Use synced versions from scripts/dtc/libfdt/.
 LIBFDT_OBJS := $(addprefix libfdt/, fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o 
\
fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o)
 
-RSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/rsa/, \
+RSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix generated/lib/rsa/, \
rsa-sign.o rsa-verify.o \
rsa-mod-exp.o)
 
-ECDSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/ecdsa/, 
ecdsa-libcrypto.o)
+ECDSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix generated/lib/ecdsa/, 
ecdsa-libcrypto.o)
 
-AES_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/aes/, \
+AES_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix generated/lib/aes/, \
aes-encrypt.o aes-decrypt.o)
 
 # Cryptographic helpers and image types that depend on openssl/libcrypto
 LIBCRYPTO_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := \
-   lib/fdt-libcrypto.o \
+   generated/lib/fdt-libcrypto.o \
sunxi_toc0.o
 
-ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
+ROCKCHIP_OBS = generated/lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
 
 # common objs for dumpimage and mkimage
 dumpimage-mkimage-objs := aisimage.o \
@@ -102,20 +102,20 @@ dumpimage-mkimage-objs := aisimage.o \
$(FIT_OBJS-y) \
$(FIT_SIG_OBJS-y) \
$(FIT_CIPHER_OBJS-y) \
-   boot/fdt_region.o \
-   boot/bootm.o \
-   lib/crc32.o \
+   generated/boot/fdt_region.o \
+   generated/boot/bootm.o \
+   generated/lib/crc32.o \
default_image.o \
-   lib/fdtdec_common.o \
-   lib/fdtdec.o \
-   boot/image.o \
-   boot/ima

[PATCH 0/1] Kbuild: Fix cleanup of generated sources in tools

2023-06-14 Thread Tobias Deiminger
Generated C files in tools/env/ and tools/boot/ are currently not
cleaned on 'make clean'. The patch fixes it by establishing a dedicated
tools/generated/ directory that can be cleaned as a whole.

Steps to reproduce:
$ make CROSS_COMPILE=aarch64-linux-gnu- O=./build qemu_arm64_defconfig
$ make CROSS_COMPILE=aarch64-linux-gnu- O=./build
$ make CROSS_COMPILE=aarch64-linux-gnu- O=./build clean
$ ls build/tools/boot/ build/tools/env/
build/tools/boot/:
bootm.c  fdt_region.c  image.c  image-cipher.c  image-fit.c  image-fit-sig.c  
image-host.c

build/tools/env/:
embedded.c

Tobias Deiminger (1):
  Kbuild: Fix cleanup of generated sources in tools

 tools/Makefile   | 64 ++--
 tools/env/.gitignore |  1 -
 2 files changed, 32 insertions(+), 33 deletions(-)


base-commit: 19b77d3d23966a0d6dbb3c86187765f11100fb6f
-- 
2.30.2