From ac94fa231c9517d0ff540e47dcc00ff2f80a4cfd Mon Sep 17 00:00:00 2001 From: Chun-Chieh Li Date: Thu, 21 Nov 2024 16:13:42 +0800 Subject: [PATCH] Upload: Fix mbed_adjust_upload_debug_commands for multiple targets The purpose of mbed_adjust_upload_debug_commands() is to adjust first version of MBED_UPLOAD_LAUNCH_COMMANDS. For multiple executalbe cmake targets, MBED_UPLOAD_LAUNCH_COMMANDS becomes not fresh and may cause error. To overcome this, one new cmake cache variable MBED_UPLOAD_LAUNCH_COMMANDS_BAK is introduced to save first version of MBED_UPLOAD_LAUNCH_COMMANDS. --- tools/cmake/UploadMethodManager.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/cmake/UploadMethodManager.cmake b/tools/cmake/UploadMethodManager.cmake index b8ce6905623..26e386ff0f2 100644 --- a/tools/cmake/UploadMethodManager.cmake +++ b/tools/cmake/UploadMethodManager.cmake @@ -12,8 +12,14 @@ # NOTE: Place at the very start so that it can override by the below loaded # upload method if need be. function(mbed_adjust_upload_debug_commands target) - # MBED_UPLOAD_LAUNCH_COMMANDS defined? - if(NOT DEFINED MBED_UPLOAD_LAUNCH_COMMANDS) + # MBED_UPLOAD_LAUNCH_COMMANDS_BAK = first version of MBED_UPLOAD_LAUNCH_COMMANDS + if(DEFINED MBED_UPLOAD_LAUNCH_COMMANDS_BAK) + # Need first version for fresh adjust + set(MBED_UPLOAD_LAUNCH_COMMANDS ${MBED_UPLOAD_LAUNCH_COMMANDS_BAK}) + elseif(DEFINED MBED_UPLOAD_LAUNCH_COMMANDS) + # No FORCE for saving first version only + set(MBED_UPLOAD_LAUNCH_COMMANDS_BAK ${MBED_UPLOAD_LAUNCH_COMMANDS} CACHE INTERNAL "") + else() return() endif()