Skip to content

Commit c745995

Browse files
dcpleungnashif
authored andcommitted
cmake: rename linker script for zephyr_prebuilt.elf
The linker script 'linker.cmd' is actually being used for building zephyr_prebuilt.elf and is not the one used to build the final binary. So rename it to better reflect what it is used for. Signed-off-by: Daniel Leung <[email protected]>
1 parent 9742211 commit c745995

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

CMakeLists.txt

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ set(OFFSETS_H_TARGET offsets_h)
5353
set(SYSCALL_LIST_H_TARGET syscall_list_h_target)
5454
set(DRIVER_VALIDATION_H_TARGET driver_validation_h_target)
5555
set(KOBJ_TYPES_H_TARGET kobj_types_h_target)
56-
set(LINKER_SCRIPT_TARGET linker_script_target)
5756
set(PARSE_SYSCALLS_TARGET parse_syscalls_target)
5857

5958
define_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT BRIEF_DOCS " " FULL_DOCS " ")
@@ -702,32 +701,13 @@ if (CONFIG_CODE_DATA_RELOCATION)
702701
set(CODE_RELOCATION_DEP code_relocation_source_lib)
703702
endif() # CONFIG_CODE_DATA_RELOCATION
704703

705-
configure_linker_script(
706-
linker.cmd
707-
""
708-
${APP_SMEM_ALIGNED_DEP}
709-
${CODE_RELOCATION_DEP}
710-
zephyr_generated_headers
711-
)
712-
713-
add_custom_target(
714-
${LINKER_SCRIPT_TARGET}
715-
DEPENDS
716-
linker.cmd
717-
)
718-
719-
# Give the '${LINKER_SCRIPT_TARGET}' target all of the include directories so
720-
# that cmake can successfully find the linker_script's header
704+
# Give the linker script targets all of the include directories so
705+
# that cmake can successfully find the linker scripts' header
721706
# dependencies.
722707
zephyr_get_include_directories_for_lang(C
723708
ZEPHYR_INCLUDE_DIRS
724709
STRIP_PREFIX # Don't use a -I prefix
725710
)
726-
set_property(TARGET
727-
${LINKER_SCRIPT_TARGET}
728-
PROPERTY INCLUDE_DIRECTORIES
729-
${ZEPHYR_INCLUDE_DIRS}
730-
)
731711

732712
if(CONFIG_GEN_ISR_TABLES)
733713
if(CONFIG_GEN_SW_ISR_TABLE)
@@ -1056,21 +1036,47 @@ if(CONFIG_USERSPACE)
10561036
)
10571037
endif()
10581038

1039+
configure_linker_script(
1040+
linker_zephyr_prebuilt.cmd
1041+
"-DLINKER_ZEPHYR_PREBUILT"
1042+
${APP_SMEM_ALIGNED_DEP}
1043+
${CODE_RELOCATION_DEP}
1044+
zephyr_generated_headers
1045+
)
1046+
1047+
add_custom_target(
1048+
linker_zephyr_prebuilt_script_target
1049+
DEPENDS
1050+
linker_zephyr_prebuilt.cmd
1051+
)
1052+
1053+
set_property(TARGET
1054+
linker_zephyr_prebuilt_script_target
1055+
PROPERTY INCLUDE_DIRECTORIES
1056+
${ZEPHYR_INCLUDE_DIRS}
1057+
)
1058+
10591059
# FIXME: Is there any way to get rid of empty_file.c?
10601060
add_executable( ${ZEPHYR_PREBUILT_EXECUTABLE} misc/empty_file.c)
10611061
toolchain_ld_link_elf(
10621062
TARGET_ELF ${ZEPHYR_PREBUILT_EXECUTABLE}
10631063
OUTPUT_MAP ${PROJECT_BINARY_DIR}/${ZEPHYR_PREBUILT_EXECUTABLE}.map
10641064
LIBRARIES_PRE_SCRIPT ""
1065-
LINKER_SCRIPT ${PROJECT_BINARY_DIR}/linker.cmd
1065+
LINKER_SCRIPT ${PROJECT_BINARY_DIR}/linker_zephyr_prebuilt.cmd
10661066
DEPENDENCIES ${CODE_RELOCATION_DEP}
10671067
)
10681068
target_byproducts(TARGET ${ZEPHYR_PREBUILT_EXECUTABLE}
10691069
BYPRODUCTS ${PROJECT_BINARY_DIR}/${ZEPHYR_PREBUILT_EXECUTABLE}.map
10701070
)
1071-
set_property(TARGET ${ZEPHYR_PREBUILT_EXECUTABLE} PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker.cmd)
1072-
add_dependencies( ${ZEPHYR_PREBUILT_EXECUTABLE} ${LINKER_SCRIPT_TARGET} ${OFFSETS_LIB})
1073-
1071+
set_property(TARGET
1072+
${ZEPHYR_PREBUILT_EXECUTABLE}
1073+
PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker_zephyr_prebuilt.cmd
1074+
)
1075+
add_dependencies(
1076+
${ZEPHYR_PREBUILT_EXECUTABLE}
1077+
linker_zephyr_prebuilt_script_target
1078+
${OFFSETS_LIB}
1079+
)
10741080

10751081
set(generated_kernel_files ${GKSF} ${GKOF})
10761082
if(NOT generated_kernel_files)

0 commit comments

Comments
 (0)