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.
This commit is contained in:
Omar Chebib 2021-03-01 12:30:50 +08:00
parent 788312a009
commit 831d470a75
5 changed files with 18 additions and 4 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -204,6 +204,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 .