Skip to content

Commit 1073fba

Browse files
mped-oticonaescolar
authored andcommitted
cmake: configure_linker_script: accept argument with file extension
Reduce the amount of {pre,post}fixing magic: I.e. let it be clearer at call sites that "linker.cmd" is a file, rather than having to know that "linker" will be postfixed with ".cmd" internally. Change argument name to linker_script_gen, to better indicate that we are producing a generated file. No functional change expected. Signed-off-by: Mark Ruvald Pedersen <[email protected]>
1 parent 4c81197 commit 1073fba

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

CMakeLists.txt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,13 @@ endif()
408408

409409
configure_file(version.h.in ${PROJECT_BINARY_DIR}/include/generated/version.h)
410410

411-
# Run $LINKER_SCRIPT file through the C preprocessor, producing ${linker_output_name}.cmd
412-
macro(configure_linker_script linker_output_name)
411+
# Run $LINKER_SCRIPT file through the C preprocessor, producing ${linker_script_gen}
412+
macro(configure_linker_script linker_script_gen)
413413
set(extra_dependencies ${ARGN})
414-
set(linker_cmd_file_name ${linker_output_name}.cmd)
415414

416-
if (${linker_output_name} MATCHES "^linker_pass_final$")
415+
if (${linker_script_gen} MATCHES "^linker_pass_final.cmd$")
417416
set(linker_pass_define -DLINKER_PASS2)
418-
elseif (${linker_output_name} MATCHES "^linker_app_smem_unaligned$")
417+
elseif (${linker_script_gen} MATCHES "^linker_app_smem_unaligned.cmd$")
419418
set(linker_pass_define -DLINKER_APP_SMEM_UNALIGNED)
420419
else()
421420
set(linker_pass_define "")
@@ -428,7 +427,7 @@ macro(configure_linker_script linker_output_name)
428427
set(linker_script_dep IMPLICIT_DEPENDS C ${LINKER_SCRIPT})
429428
elseif(CMAKE_GENERATOR STREQUAL "Ninja")
430429
# Using DEPFILE with other generators than Ninja is an error.
431-
set(linker_script_dep DEPFILE ${PROJECT_BINARY_DIR}/${linker_cmd_file_name}.dep)
430+
set(linker_script_dep DEPFILE ${PROJECT_BINARY_DIR}/${linker_script_gen}.dep)
432431
else()
433432
# TODO: How would the linker script dependencies work for non-linker
434433
# script generators.
@@ -442,7 +441,7 @@ macro(configure_linker_script linker_output_name)
442441
get_property(current_defines GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES)
443442

444443
add_custom_command(
445-
OUTPUT ${linker_cmd_file_name}
444+
OUTPUT ${linker_script_gen}
446445
DEPENDS
447446
${LINKER_SCRIPT}
448447
${extra_dependencies}
@@ -451,13 +450,13 @@ macro(configure_linker_script linker_output_name)
451450
COMMAND ${CMAKE_C_COMPILER}
452451
-x assembler-with-cpp
453452
${NOSYSDEF_CFLAG}
454-
-MD -MF ${linker_cmd_file_name}.dep -MT ${base_name}/${linker_cmd_file_name}
453+
-MD -MF ${linker_script_gen}.dep -MT ${base_name}/${linker_script_gen}
455454
${current_includes}
456455
${current_defines}
457456
${linker_pass_define}
458457
-E ${LINKER_SCRIPT}
459458
-P # Prevent generation of debug `#line' directives.
460-
-o ${linker_cmd_file_name}
459+
-o ${linker_script_gen}
461460
VERBATIM
462461
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
463462
)
@@ -731,7 +730,7 @@ if (CONFIG_CODE_DATA_RELOCATION)
731730
endif() # CONFIG_CODE_DATA_RELOCATION
732731

733732
configure_linker_script(
734-
linker
733+
linker.cmd
735734
${PRIV_STACK_DEP}
736735
${APP_SMEM_ALIGNED_DEP}
737736
${CODE_RELOCATION_DEP}
@@ -1159,7 +1158,7 @@ if(CONFIG_USERSPACE)
11591158
)
11601159

11611160
configure_linker_script(
1162-
linker_app_smem_unaligned
1161+
linker_app_smem_unaligned.cmd
11631162
${CODE_RELOCATION_DEP}
11641163
${APP_SMEM_UNALIGNED_DEP}
11651164
${APP_SMEM_UNALIGNED_LD}
@@ -1203,7 +1202,7 @@ endif()
12031202

12041203
if(CONFIG_USERSPACE AND CONFIG_ARM)
12051204
configure_linker_script(
1206-
linker_priv_stacks
1205+
linker_priv_stacks.cmd
12071206
${CODE_RELOCATION_DEP}
12081207
${APP_SMEM_ALIGNED_DEP}
12091208
${APP_SMEM_ALIGNED_LD}
@@ -1249,7 +1248,7 @@ else()
12491248
# first pass (LINKER_SCRIPT), but this time with a different output
12501249
# file and preprocessed with the define LINKER_PASS2.
12511250
configure_linker_script(
1252-
linker_pass_final
1251+
linker_pass_final.cmd
12531252
${PRIV_STACK_DEP}
12541253
${CODE_RELOCATION_DEP}
12551254
${ZEPHYR_PREBUILT_EXECUTABLE}

0 commit comments

Comments
 (0)