Skip to content

Commit 5fea010

Browse files
committed
add family_support_configure_common()
1 parent 26d05d7 commit 5fea010

File tree

6 files changed

+42
-71
lines changed

6 files changed

+42
-71
lines changed

hw/bsp/family_support.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ function(family_add_default_example_warnings TARGET)
136136
endfunction()
137137

138138

139+
function(family_support_configure_common TARGET)
140+
# set output name to .elf
141+
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
142+
143+
# run size after build
144+
add_custom_command(TARGET ${TARGET} POST_BUILD
145+
COMMAND ${TOOLCHAIN_SIZE} $<TARGET_FILE:${TARGET}>
146+
)
147+
148+
# Generate map file
149+
target_link_options(${TARGET} PUBLIC
150+
# link map
151+
"LINKER:-Map=$<TARGET_FILE:${TARGET}>.map"
152+
)
153+
endfunction()
154+
139155
# add_custom_command(TARGET ${TARGET} POST_BUILD
140156
# COMMAND ${CMAKE_OBJCOPY} -O ihex $<TARGET_FILE:${TARGET}> ${TARGET}.hex
141157
# COMMAND ${CMAKE_OBJCOPY} -O binary $<TARGET_FILE:${TARGET}> ${TARGET}.bin

hw/bsp/imxrt/family.cmake

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ if (NOT TARGET ${BOARD_TARGET})
6363
)
6464
target_link_options(${BOARD_TARGET} PUBLIC
6565
"LINKER:--script=${LD_FILE_gcc}"
66-
"LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map"
6766
# nanolib
6867
--specs=nosys.specs
6968
--specs=nano.specs
@@ -79,17 +78,8 @@ endif () # BOARD_TARGET
7978
#------------------------------------
8079
# Functions
8180
#------------------------------------
82-
function(family_configure_target TARGET)
83-
# set output name to .elf
84-
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
85-
86-
# run size after build
87-
add_custom_command(TARGET ${TARGET} POST_BUILD
88-
COMMAND ${TOOLCHAIN_SIZE} $<TARGET_FILE:${TARGET}>
89-
)
90-
91-
# TOP is path to root directory
92-
set(TOP "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../..")
81+
function(family_configure_example TARGET)
82+
family_support_configure_common(${TARGET})
9383

9484
#---------- Port Specific ----------
9585
# These files are built for each example since it depends on example's tusb_config.h
@@ -162,13 +152,13 @@ function(family_add_freertos TARGET)
162152
endfunction()
163153

164154
function(family_configure_device_example TARGET)
165-
family_configure_target(${TARGET})
155+
family_configure_example(${TARGET})
166156
endfunction()
167157

168158
function(family_configure_host_example TARGET)
169-
family_configure_target(${TARGET})
159+
family_configure_example(${TARGET})
170160
endfunction()
171161

172162
function(family_configure_dual_usb_example TARGET)
173-
family_configure_target(${TARGET})
163+
family_configure_example(${TARGET})
174164
endfunction()

hw/bsp/lpc18/family.cmake

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,8 @@ endif () # BOARD_TARGET
6565
#------------------------------------
6666
# Functions
6767
#------------------------------------
68-
function(family_configure_target TARGET)
69-
# set output name to .elf
70-
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
71-
72-
# run size after build
73-
add_custom_command(TARGET ${TARGET} POST_BUILD
74-
COMMAND ${TOOLCHAIN_SIZE} $<TARGET_FILE:${TARGET}>
75-
)
68+
function(family_configure_example TARGET)
69+
family_support_configure_common(${TARGET})
7670

7771
#---------- Port Specific ----------
7872
# These files are built for each example since it depends on example's tusb_config.h
@@ -143,13 +137,13 @@ function(family_add_freertos TARGET)
143137
endfunction()
144138

145139
function(family_configure_device_example TARGET)
146-
family_configure_target(${TARGET})
140+
family_configure_example(${TARGET})
147141
endfunction()
148142

149143
function(family_configure_host_example TARGET)
150-
family_configure_target(${TARGET})
144+
family_configure_example(${TARGET})
151145
endfunction()
152146

153147
function(family_configure_dual_usb_example TARGET)
154-
family_configure_target(${TARGET})
148+
family_configure_example(${TARGET})
155149
endfunction()

hw/bsp/lpc55/family.cmake

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ if (NOT TARGET ${BOARD_TARGET})
6363
target_link_options(${BOARD_TARGET} PUBLIC
6464
# linker file
6565
"LINKER:--script=${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld"
66-
# link map
67-
"LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map"
6866
# nanolib
6967
--specs=nosys.specs
7068
--specs=nano.specs
@@ -77,12 +75,8 @@ endif () # BOARD_TARGET
7775
#------------------------------------
7876
# Functions
7977
#------------------------------------
80-
function(family_configure_target TARGET)
81-
# set output name to .elf
82-
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
83-
84-
# TOP is path to root directory
85-
set(TOP "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../..")
78+
function(family_configure_example TARGET)
79+
family_support_configure_common(${TARGET})
8680

8781
#---------- Port Specific ----------
8882
# These files are built for each example since it depends on example's tusb_config.h
@@ -153,13 +147,13 @@ function(family_add_freertos TARGET)
153147
endfunction()
154148

155149
function(family_configure_device_example TARGET)
156-
family_configure_target(${TARGET})
150+
family_configure_example(${TARGET})
157151
endfunction()
158152

159153
function(family_configure_host_example TARGET)
160-
family_configure_target(${TARGET})
154+
family_configure_example(${TARGET})
161155
endfunction()
162156

163157
function(family_configure_dual_usb_example TARGET)
164-
family_configure_target(${TARGET})
158+
family_configure_example(${TARGET})
165159
endfunction()

hw/bsp/mcx/family.cmake

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ if (NOT TARGET ${BOARD_TARGET})
5454
target_sources(${BOARD_TARGET} PUBLIC
5555
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S
5656
)
57+
cmake_print_variables(CMAKE_CURRENT_BINARY_DIR)
5758
target_link_options(${BOARD_TARGET} PUBLIC
5859
# linker file
5960
"LINKER:--script=${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld"
60-
# link map
61-
"LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map"
6261
# nanolib
6362
--specs=nosys.specs
6463
--specs=nano.specs
@@ -71,17 +70,8 @@ endif () # BOARD_TARGET
7170
#------------------------------------
7271
# Functions
7372
#------------------------------------
74-
function(family_configure_target TARGET)
75-
# set output name to .elf
76-
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
77-
78-
# run size after build
79-
add_custom_command(TARGET ${TARGET} POST_BUILD
80-
COMMAND ${TOOLCHAIN_SIZE} $<TARGET_FILE:${TARGET}>
81-
)
82-
83-
# TOP is path to root directory
84-
set(TOP "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../..")
73+
function(family_configure_example TARGET)
74+
family_support_configure_common(${TARGET})
8575

8676
#---------- Port Specific ----------
8777
# These files are built for each example since it depends on example's tusb_config.h
@@ -167,13 +157,13 @@ function(family_add_freertos TARGET)
167157
endfunction()
168158

169159
function(family_configure_device_example TARGET)
170-
family_configure_target(${TARGET})
160+
family_configure_example(${TARGET})
171161
endfunction()
172162

173163
function(family_configure_host_example TARGET)
174-
family_configure_target(${TARGET})
164+
family_configure_example(${TARGET})
175165
endfunction()
176166

177167
function(family_configure_dual_usb_example TARGET)
178-
family_configure_target(${TARGET})
168+
family_configure_example(${TARGET})
179169
endfunction()

hw/bsp/nrf/family.cmake

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ if (NOT TARGET ${BOARD_TARGET})
6565
# linker file
6666
"LINKER:--script=${LD_FILE_gcc}"
6767
-L${NRFX_DIR}/mdk
68-
# link map
69-
"LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map"
7068
# nanolib
7169
--specs=nosys.specs
7270
--specs=nano.specs
@@ -79,19 +77,8 @@ endif () # BOARD_TARGET
7977
#------------------------------------
8078
# Functions
8179
#------------------------------------
82-
function(family_configure_target TARGET)
83-
#family_add_default_example_warnings(${TARGET})
84-
85-
# set output name to .elf
86-
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}.elf)
87-
88-
# run size after build
89-
add_custom_command(TARGET ${TARGET} POST_BUILD
90-
COMMAND ${TOOLCHAIN_SIZE} $<TARGET_FILE:${TARGET}>
91-
)
92-
93-
# TOP is path to root directory
94-
set(TOP "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../..")
80+
function(family_configure_example TARGET)
81+
family_support_configure_common(${TARGET})
9582

9683
#---------- Port Specific ----------
9784
# These files are built for each example since it depends on example's tusb_config.h
@@ -161,13 +148,13 @@ function(family_add_freertos TARGET)
161148
endfunction()
162149

163150
function(family_configure_device_example TARGET)
164-
family_configure_target(${TARGET})
151+
family_configure_example(${TARGET})
165152
endfunction()
166153

167154
function(family_configure_host_example TARGET)
168-
family_configure_target(${TARGET})
155+
family_configure_example(${TARGET})
169156
endfunction()
170157

171158
function(family_configure_dual_usb_example TARGET)
172-
family_configure_target(${TARGET})
159+
family_configure_example(${TARGET})
173160
endfunction()

0 commit comments

Comments
 (0)