@@ -55,6 +55,7 @@ import {
55
55
runDtshShell ,
56
56
clean ,
57
57
MenuConfig ,
58
+ build ,
58
59
} from "./zephyr_utilities/build" ;
59
60
import { flashActive } from "./zephyr_utilities/flash" ;
60
61
import { WorkspaceConfig , GlobalConfig } from "./setup_utilities/types" ;
@@ -983,7 +984,7 @@ export async function activate(context: vscode.ExtensionContext) {
983
984
context . subscriptions . push (
984
985
vscode . commands . registerCommand ( "zephyr-ide.debug" , async ( ) => {
985
986
let debugTarget = "Zephyr IDE: Debug" ;
986
- let activeBuild = await project . getActiveBuild ( context , wsConfig ) ;
987
+ let activeBuild = await project . getActiveBuild ( wsConfig ) ;
987
988
988
989
if ( activeBuild ?. launchTarget ) {
989
990
debugTarget = activeBuild . launchTarget ;
@@ -1008,7 +1009,7 @@ export async function activate(context: vscode.ExtensionContext) {
1008
1009
context . subscriptions . push (
1009
1010
vscode . commands . registerCommand ( "zephyr-ide.debug-attach" , async ( ) => {
1010
1011
let debugTarget = "Zephyr IDE: Attach" ;
1011
- let activeBuild = await project . getActiveBuild ( context , wsConfig ) ;
1012
+ let activeBuild = await project . getActiveBuild ( wsConfig ) ;
1012
1013
1013
1014
if ( activeBuild ?. attachTarget ) {
1014
1015
debugTarget = activeBuild . attachTarget ;
@@ -1033,18 +1034,40 @@ export async function activate(context: vscode.ExtensionContext) {
1033
1034
context . subscriptions . push (
1034
1035
vscode . commands . registerCommand ( "zephyr-ide.build-debug" , async ( ) => {
1035
1036
let debugTarget = "Zephyr IDE: Debug" ;
1036
- let activeBuild = await project . getActiveBuild ( context , wsConfig ) ;
1037
+ let activeProject = await project . getActiveProject ( wsConfig ) ;
1038
+ let activeBuild = await project . getActiveBuild ( wsConfig ) ;
1037
1039
1038
- if ( activeBuild ?. buildDebugTarget ) {
1040
+ if ( activeProject && activeBuild ?. buildDebugTarget ) {
1039
1041
debugTarget = activeBuild . buildDebugTarget ;
1040
1042
}
1041
1043
let debugConfig = await getLaunchConfigurationByName (
1042
1044
wsConfig ,
1043
1045
debugTarget
1044
1046
) ;
1045
1047
1046
- if ( debugConfig ) {
1047
- let res = await buildHelper ( context , wsConfig , false ) ;
1048
+ if ( debugConfig && activeProject && activeBuild ) {
1049
+ debugConfig . executable = '${command:zephyr-ide.get-active-build-path}/${command:zephyr-ide.get-active-project-name}/zephyr/zephyr.elf' ;
1050
+ // Resolve all ${command:zephyr-ide.*} variables in debugConfig
1051
+ async function resolveZephyrCommandsInObject ( obj : Record < string , unknown > ) {
1052
+ for ( const key of Object . keys ( obj ) ) {
1053
+ if ( typeof obj [ key ] === "string" ) {
1054
+ const strVal = obj [ key ] as string ;
1055
+ const matches = strVal . match ( / \$ \{ c o m m a n d : z e p h y r - i d e \. [ ^ } ] + \} / g) ;
1056
+ if ( matches ) {
1057
+ let newValue = strVal ;
1058
+ for ( const match of matches ) {
1059
+ const commandName = match . slice ( 10 , - 1 ) ; // Remove ${command: and }
1060
+ const result = await vscode . commands . executeCommand ( commandName ) ;
1061
+ const resultStr = result !== undefined ? String ( result ) : "" ;
1062
+ newValue = newValue . split ( match ) . join ( resultStr ) ;
1063
+ }
1064
+ obj [ key ] = newValue ;
1065
+ }
1066
+ }
1067
+ }
1068
+ }
1069
+ await resolveZephyrCommandsInObject ( debugConfig ) ;
1070
+ let res = await build ( wsConfig , activeProject , activeBuild , false ) ;
1048
1071
if ( res ) {
1049
1072
await vscode . commands . executeCommand (
1050
1073
"debug.startFromConfig" ,
0 commit comments