From 53712319357ca6bf7108ecfe2e566dadd1738a1f Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Mon, 1 Mar 2021 12:30:50 +0800 Subject: [PATCH] build: fix linker scripts edition not triggering a rebuild Fix the dependencies in CMakeLists files for triggering a relink when linker script file is modified. --- components/esp32/CMakeLists.txt | 3 ++- components/esp32c3/CMakeLists.txt | 3 ++- components/esp32s2/CMakeLists.txt | 3 ++- components/esp32s3/CMakeLists.txt | 3 ++- tools/ci/test_build_system_cmake.sh | 10 ++++++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index de64b5f8fa..462d9a0891 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -57,7 +57,8 @@ else() add_custom_command( OUTPUT esp32_out.ld COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${config_dir} ${LD_DIR}/esp32.ld - MAIN_DEPENDENCY ${LD_DIR}/esp32.ld ${sdkconfig_header} + MAIN_DEPENDENCY ${LD_DIR}/esp32.ld + DEPENDS ${sdkconfig_header} COMMENT "Generating linker script..." VERBATIM) diff --git a/components/esp32c3/CMakeLists.txt b/components/esp32c3/CMakeLists.txt index a07dd16adb..e1fd8ecdb0 100644 --- a/components/esp32c3/CMakeLists.txt +++ b/components/esp32c3/CMakeLists.txt @@ -58,7 +58,8 @@ else() add_custom_command( OUTPUT esp32c3_out.ld COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32c3_out.ld -I ${config_dir} ${LD_DIR}/esp32c3.ld - MAIN_DEPENDENCY ${LD_DIR}/esp32c3.ld ${sdkconfig_header} + MAIN_DEPENDENCY ${LD_DIR}/esp32c3.ld + DEPENDS ${sdkconfig_header} COMMENT "Generating linker script..." VERBATIM) diff --git a/components/esp32s2/CMakeLists.txt b/components/esp32s2/CMakeLists.txt index 7faf0e2d23..0f34f5d36f 100644 --- a/components/esp32s2/CMakeLists.txt +++ b/components/esp32s2/CMakeLists.txt @@ -61,7 +61,8 @@ else() add_custom_command( OUTPUT esp32s2_out.ld COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32s2_out.ld -I ${config_dir} ${LD_DIR}/esp32s2.ld - MAIN_DEPENDENCY ${LD_DIR}/esp32s2.ld ${sdkconfig_header} + MAIN_DEPENDENCY ${LD_DIR}/esp32s2.ld + DEPENDS ${sdkconfig_header} COMMENT "Generating linker script..." VERBATIM) diff --git a/components/esp32s3/CMakeLists.txt b/components/esp32s3/CMakeLists.txt index ce87b35ed0..3020dba080 100644 --- a/components/esp32s3/CMakeLists.txt +++ b/components/esp32s3/CMakeLists.txt @@ -58,7 +58,8 @@ else() add_custom_command( OUTPUT esp32s3_out.ld COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32s3_out.ld -I ${config_dir} ${LD_DIR}/esp32s3.ld - MAIN_DEPENDENCY ${LD_DIR}/esp32s3.ld ${sdkconfig_header} + MAIN_DEPENDENCY ${LD_DIR}/esp32s3.ld + DEPENDS ${sdkconfig_header} COMMENT "Generating linker script..." VERBATIM) diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index a38ea53026..a1b91bb9fa 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -218,6 +218,16 @@ function run_tests() assert_not_rebuilt ${BOOTLOADER_BINS} mv esp32.project.ld.in ${IDF_PATH}/components/esp32/ld/ + print_status "Updating ld file should only re-link app" + take_build_snapshot + cp ${IDF_PATH}/components/esp32/ld/esp32.ld . + sleep 1 # ninja may ignore if the timestamp delta is too low + echo "/* (Build test comment) */" >> ${IDF_PATH}/components/esp32/ld/esp32.ld + idf.py build || failure "Failed to rebuild with modified linker script" + assert_rebuilt ${APP_BINS} + assert_not_rebuilt ${BOOTLOADER_BINS} + mv esp32.ld ${IDF_PATH}/components/esp32/ld/ + print_status "Updating fragment file should only re-link app" # only app linker script is generated by tool for now take_build_snapshot cp ${IDF_PATH}/components/esp32/ld/esp32_fragments.lf .