Skip to content

Commit 498b494

Browse files
marc-hbgalak
authored andcommitted
CMakeLists.txt: fix misleading logical_target_for_zephyr_elf comment
The comment for: set_target_properties(${logical_target_for_zephyr_elf} PROPERTIES OUTPUT_NAME ${KERNEL_NAME}) was completely off-topic and making something relatively simple incredibly puzzling and time-consuming to understand. Re-order the if(GKSF OR GKOF) clauses so the two initializations of logical_target_for_zephyr_elf are close to each other and so the very short clause is not buried at the bottom of the long one. Other minor logical_target_for_zephyr_elf comment fixes. Signed-off-by: Marc Herbert <[email protected]>
1 parent d6d7a80 commit 498b494

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

CMakeLists.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,12 @@ set_property(TARGET ${ZEPHYR_PREBUILT_EXECUTABLE} PROPERTY LINK_DEPENDS ${PROJ
12981298
add_dependencies( ${ZEPHYR_PREBUILT_EXECUTABLE} ${ALIGN_SIZING_DEP} ${PRIV_STACK_DEP} ${LINKER_SCRIPT_TARGET} ${OFFSETS_LIB})
12991299

13001300

1301-
if(GKOF OR GKSF)
1301+
set(generated_kernel_files ${GKSF} ${GKOF})
1302+
if(NOT generated_kernel_files)
1303+
# Use the prebuilt elf as the final elf since we don't have a
1304+
# generation stage.
1305+
set(logical_target_for_zephyr_elf ${ZEPHYR_PREBUILT_EXECUTABLE})
1306+
else()
13021307
set(KERNEL_ELF kernel_elf)
13031308
set(logical_target_for_zephyr_elf ${KERNEL_ELF})
13041309

@@ -1334,18 +1339,16 @@ if(GKOF OR GKSF)
13341339
target_link_libraries(${KERNEL_ELF} ${GKOF} ${TOPT} ${PROJECT_BINARY_DIR}/linker_pass_final.cmd ${zephyr_lnk} ${CODE_RELOCATION_DEP})
13351340
set_property(TARGET ${KERNEL_ELF} PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker_pass_final.cmd)
13361341
add_dependencies( ${KERNEL_ELF} ${ALIGN_SIZING_DEP} ${PRIV_STACK_DEP} ${LINKER_PASS_FINAL_SCRIPT_TARGET})
1337-
else()
1338-
set(logical_target_for_zephyr_elf ${ZEPHYR_PREBUILT_EXECUTABLE})
1339-
# Use the prebuilt elf as the final elf since we don't have a
1340-
# generation stage.
13411342
endif()
13421343

13431344
# Export the variable to the application's scope to allow the
13441345
# application to know what the name of the final elf target is.
13451346
set(logical_target_for_zephyr_elf ${logical_target_for_zephyr_elf} PARENT_SCOPE)
13461347

1347-
# To avoid having the same logical target name for the zephyr lib and
1348-
# the zephyr elf, we set the kernel_elf file name to zephyr.elf.
1348+
# Override the base name of final .elf so:
1349+
# 1. it doesn't depend on the number of passes above and the
1350+
# post_build_commands below can always find it no matter which is it;
1351+
# 2. it can be defined in Kconfig
13491352
set_target_properties(${logical_target_for_zephyr_elf} PROPERTIES OUTPUT_NAME ${KERNEL_NAME})
13501353

13511354
set(post_build_commands "")
@@ -1412,11 +1415,14 @@ list(APPEND
14121415
${extra_post_build_commands}
14131416
)
14141417

1418+
# Add post_build_commands to post-process the final .elf file produced by
1419+
# either the ZEPHYR_PREBUILT_EXECUTABLE or the KERNEL_ELF executable
1420+
# targets above.
14151421
add_custom_command(
14161422
TARGET ${logical_target_for_zephyr_elf}
14171423
POST_BUILD
14181424
${post_build_commands}
1419-
COMMENT "Generating files from zephyr.elf for board: ${BOARD}"
1425+
COMMENT "Generating files from ${KERNEL_ELF_NAME} for board: ${BOARD}"
14201426
# NB: COMMENT only works for some CMake-Generators
14211427
)
14221428

0 commit comments

Comments
 (0)