Skip to content

Commit e57676a

Browse files
SebastianBoekartben
authored andcommitted
soc: nordic: nrf54h: uicr: Improve deps for uicr/zephyr/zephyr.hex
uicr/zephyr/zephyr.hex needs to be built after all other zephyr images. Instead of adding a dependency on uicr, we check the sysbuild_images property to find images. Also, we check it as late possible by using the cmake_language(DEFER DIRECTORY feature. Which will ensure that running this code will be one of the last things that the CMake sysbuild program does at Configure time. Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
1 parent b5ddded commit e57676a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

soc/nordic/common/uicr/sysbuild.cmake

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ ExternalZephyrProject_Add(
99
# Ensure UICR is configured and built after the default image so EDT/ELFs exist.
1010
sysbuild_add_dependencies(CONFIGURE uicr ${DEFAULT_IMAGE})
1111

12-
add_dependencies(uicr ${DEFAULT_IMAGE})
13-
if(DEFINED image)
14-
add_dependencies(uicr ${image})
15-
endif()
12+
# Add build dependencies for all images whose ELF files may be used by gen_uicr.
13+
# The gen_uicr/CMakeLists.txt scans all sibling build directories and adds their
14+
# ELF files as file dependencies. However, we also need target dependencies to
15+
# ensure those images are built before uicr attempts to use their ELF files.
16+
#
17+
# Use cmake_language(DEFER DIRECTORY) to ensure this runs after ALL images have
18+
# been added to the sysbuild_images global property, even if some module adds
19+
# images after the soc subdirectory is processed. We defer to the source root
20+
# directory to ensure we're at the top-level scope where all subdirectories have
21+
# completed processing.
22+
function(uicr_add_image_dependencies)
23+
get_property(all_images GLOBAL PROPERTY sysbuild_images)
24+
foreach(img ${all_images})
25+
if(NOT img STREQUAL "uicr")
26+
add_dependencies(uicr ${img})
27+
endif()
28+
endforeach()
29+
endfunction()
30+
31+
cmake_language(DEFER DIRECTORY ${CMAKE_SOURCE_DIR} CALL uicr_add_image_dependencies)

0 commit comments

Comments
 (0)