From fdbf2dbd2b89d1cdcaa09352857522c2bc6fe96c Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 20 Oct 2020 14:31:56 -0400 Subject: [PATCH] build: add option to delete intermediate files Add option to remove intermediate files to save space and remove clutter. Signed-off-by: Anas Nashif --- CMakeLists.txt | 11 +++++++++++ Kconfig.zephyr | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f267696066b..ac7b691cb3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1153,6 +1153,17 @@ if(CONFIG_BUILD_OUTPUT_BIN) endif() endif() + +# Cleanup intermediate files +if(CONFIG_CLEANUP_INTERMEDIATE_FILES) + list(APPEND + post_build_commands + COMMAND + # This file can be very large in some cases, delete it as we do not need it. + ${CMAKE_COMMAND} -E remove ${ZEPHYR_PREBUILT_EXECUTABLE}.elf + ) +endif() + if(CONFIG_BUILD_OUTPUT_S19) get_property(elfconvert_formats TARGET bintools PROPERTY elfconvert_formats) if(srec IN_LIST elfconvert_formats) diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 698e642b83e..e4b96a56756 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -295,6 +295,12 @@ config OUTPUT_PRINT_MEMORY_USAGE ram_report and https://sourceware.org/binutils/docs/ld/MEMORY.html +config CLEANUP_INTERMEDIATE_FILES + bool "Remove all intermediate files" + help + Delete intermediate files to save space and cleanup clutter resulting + from the build process. + config BUILD_NO_GAP_FILL bool "Don't fill gaps in generated hex/bin/s19 files."