Skip to content

Commit 61e8b9d

Browse files
committed
Upload: Generate GDB command line gdbinit for multiple application
This enables generating GDB command line gdbinit file for single project multiple application scenario. For this change, mbed_finalize_build needs to pass <app> target name, or warning pops up.
1 parent 176ebe6 commit 61e8b9d

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

tools/cmake/mbed_ide_debug_cfg_generator.cmake

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ if(MBED_GENERATE_CLION_DEBUG_CFGS)
8686
")
8787
endfunction(mbed_generate_ide_debug_configuration)
8888

89-
function(mbed_finalize_ide_debug_configurations)
89+
function(mbed_finalize_ide_debug_configurations CMAKE_TARGET)
9090
# Don't need to do anything
9191
endfunction(mbed_finalize_ide_debug_configurations)
9292

@@ -163,7 +163,7 @@ elseif(MBED_GENERATE_VS_CODE_DEBUG_CFGS)
163163
endfunction(mbed_generate_ide_debug_configuration)
164164

165165
# Take all generated debug configurations and write them to launch.json.
166-
function(mbed_finalize_ide_debug_configurations)
166+
function(mbed_finalize_ide_debug_configurations CMAKE_TARGET)
167167

168168
set(VSCODE_LAUNCH_JSON_PATH ${CMAKE_SOURCE_DIR}/.vscode/launch.json)
169169

@@ -246,15 +246,14 @@ elseif(MBED_UPLOAD_SUPPORTS_DEBUG)
246246
add_custom_target(debug-${target}
247247
COMMENT "Starting GDB to debug ${target}..."
248248
COMMAND ${MBED_GDB}
249-
--command=${CMAKE_BINARY_DIR}/mbed-cmake.gdbinit
249+
--command=${CMAKE_BINARY_DIR}/mbed-cmake$<$<BOOL:${CMAKE_TARGET}>:-${CMAKE_TARGET}>.gdbinit
250250
$<TARGET_FILE:${target}>
251251
USES_TERMINAL)
252252
endif()
253253

254254
endfunction(mbed_generate_ide_debug_configuration)
255255

256-
function(mbed_finalize_ide_debug_configurations)
257-
256+
function(mbed_finalize_ide_debug_configurations CMAKE_TARGET)
258257
# create init file for GDB client
259258
if(MBED_UPLOAD_WANTS_EXTENDED_REMOTE)
260259
set(UPLOAD_GDB_REMOTE_KEYWORD "extended-remote")
@@ -264,7 +263,7 @@ elseif(MBED_UPLOAD_SUPPORTS_DEBUG)
264263

265264
list(JOIN MBED_UPLOAD_LAUNCH_COMMANDS "\n" MBED_UPLOAD_LAUNCH_COMMANDS_FOR_GDBINIT)
266265

267-
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/mbed-cmake.gdbinit CONTENT
266+
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/mbed-cmake$<$<BOOL:${CMAKE_TARGET}>:-${CMAKE_TARGET}>.gdbinit CONTENT
268267
"# connect to GDB server
269268
target ${UPLOAD_GDB_REMOTE_KEYWORD} 127.0.0.1:${GDB_PORT}
270269
${MBED_UPLOAD_LAUNCH_COMMANDS_FOR_GDBINIT}
@@ -285,7 +284,7 @@ else()
285284
function(mbed_generate_ide_debug_configuration CMAKE_TARGET)
286285
endfunction()
287286

288-
function(mbed_finalize_ide_debug_configurations)
287+
function(mbed_finalize_ide_debug_configurations CMAKE_TARGET)
289288
endfunction()
290289

291290
endif()

tools/cmake/mbed_target_functions.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,16 @@ endfunction()
188188
# Call this at the very end of the build script. Does some final cleanup tasks such as
189189
# writing out debug configurations.
190190
#
191+
# 1st arg: <app> cmake target name
192+
#
191193
function(mbed_finalize_build)
192-
mbed_finalize_ide_debug_configurations()
194+
if("${ARGN}" STREQUAL "")
195+
message(WARNING "Invoke mbed_finalize_build(<app>_target_name) for single project multiple application scenario")
196+
mbed_finalize_ide_debug_configurations("")
197+
else()
198+
set(CMAKE_TARGET ${ARGV0})
199+
mbed_finalize_ide_debug_configurations(${CMAKE_TARGET})
200+
endif()
193201
endfunction(mbed_finalize_build)
194202

195203
# Lists that mbed_disable_mcu_target_file stores data in

0 commit comments

Comments
 (0)