Skip to content
Permalink
Browse files

cmake: change construct_add_custom_command_for_linker_pass into macro

Change construct_add_custom_command_for_linker_pass from function into
macro. The purpose of the function was to set the output variable to a
string that would be fed to add_custom_command. This meant all use
required a two-step procedure and an intermediate
variable (custom_command).

The environmental leakage from a macro in this case is small, so let's
just simplify to a macro and avoid the two-step.

No functional change expected.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
  • Loading branch information...
mped-oticon authored and aescolar committed Apr 29, 2019
1 parent 8c7c2d2 commit 11d6baea8c2887263c7f69e1959f4d806638ae3e
Showing with 7 additions and 22 deletions.
  1. +7 −22 CMakeLists.txt
@@ -32,6 +32,7 @@ assert(toolchain_is_ok "The toolchain is unable to build a dummy C file. See CMa
set(CMAKE_EXECUTABLE_SUFFIX .elf)
set(ZEPHYR_PREBUILT_EXECUTABLE zephyr_prebuilt)

# Set some phony targets to collect dependencies
set(OFFSETS_H_TARGET offsets_h)
set(SYSCALL_MACROS_H_TARGET syscall_macros_h_target)
set(SYSCALL_LIST_H_TARGET syscall_list_h_target)
@@ -407,7 +408,7 @@ endif()

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

function(construct_add_custom_command_for_linker_pass linker_output_name output_variable)
macro(construct_add_custom_command_for_linker_pass linker_output_name)
set(extra_dependencies ${ARGN})
set(linker_cmd_file_name ${linker_output_name}.cmd)

@@ -439,7 +440,9 @@ function(construct_add_custom_command_for_linker_pass linker_output_name output_
get_filename_component(base_name ${CMAKE_CURRENT_BINARY_DIR} NAME)
get_property(current_defines GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES)

set(${output_variable}
# Run $LINKER_SCRIPT through the C preprocessor, producing $linker_cmd_file_name

add_custom_command(
OUTPUT ${linker_cmd_file_name}
DEPENDS
${LINKER_SCRIPT}
@@ -458,10 +461,8 @@ function(construct_add_custom_command_for_linker_pass linker_output_name output_
-o ${linker_cmd_file_name}
VERBATIM
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}

PARENT_SCOPE
)
endfunction()
)
endmacro()

# Error-out when the deprecated naming convention is found (until
# after 1.14.0 has been released)
@@ -732,15 +733,11 @@ endif() # CONFIG_CODE_DATA_RELOCATION

construct_add_custom_command_for_linker_pass(
linker
custom_command
${PRIV_STACK_DEP}
${APP_SMEM_ALIGNED_DEP}
${CODE_RELOCATION_DEP}
${OFFSETS_H_TARGET}
)
add_custom_command(
${custom_command}
)

add_custom_target(
${LINKER_SCRIPT_TARGET}
@@ -1164,15 +1161,11 @@ if(CONFIG_USERSPACE)

construct_add_custom_command_for_linker_pass(
linker_app_smem_unaligned
custom_command
${CODE_RELOCATION_DEP}
${APP_SMEM_UNALIGNED_DEP}
${APP_SMEM_UNALIGNED_LD}
${OFFSETS_H_TARGET}
)
add_custom_command(
${custom_command}
)

add_custom_target(
linker_app_smem_unaligned_script
@@ -1212,15 +1205,11 @@ endif()
if(CONFIG_USERSPACE AND CONFIG_ARM)
construct_add_custom_command_for_linker_pass(
linker_priv_stacks
custom_command
${CODE_RELOCATION_DEP}
${APP_SMEM_ALIGNED_DEP}
${APP_SMEM_ALIGNED_LD}
${OFFSETS_H_TARGET}
)
add_custom_command(
${custom_command}
)

add_custom_target(
linker_priv_stacks_script
@@ -1262,15 +1251,11 @@ else()
# file and preprocessed with the define LINKER_PASS2.
construct_add_custom_command_for_linker_pass(
linker_pass_final
custom_command
${PRIV_STACK_DEP}
${CODE_RELOCATION_DEP}
${ZEPHYR_PREBUILT_EXECUTABLE}
${OFFSETS_H_TARGET}
)
add_custom_command(
${custom_command}
)

set(LINKER_PASS_FINAL_SCRIPT_TARGET linker_pass_final_script_target)
add_custom_target(

0 comments on commit 11d6bae

Please sign in to comment.
You can’t perform that action at this time.