@@ -89,7 +89,9 @@ import {
8989 remove_this_item ,
9090 view_str$prompt$filesOptionsComment ,
9191 view_str$virual_doc_provider_banner ,
92- view_str$missed_stubs_added
92+ view_str$missed_stubs_added ,
93+ view_str$keil_export_path_warning ,
94+ view_str$settings$debugger
9395} from './StringTable' ;
9496import { CodeBuilder , BuildOptions } from './CodeBuilder' ;
9597import { ExceptionToMessage , newMessage } from './Message' ;
@@ -112,7 +114,8 @@ import {
112114 pyocd_getTargetList ,
113115 generateDotnetProgramCmd ,
114116 isGccFamilyToolchain ,
115- cxxDemangle
117+ cxxDemangle ,
118+ DEBUGGER_MAPS
116119} from './utility' ;
117120import { concatSystemEnvPath , DeleteDir , exeSuffix , kill , osType , DeleteAllChildren , userhome , getGlobalState } from './Platform' ;
118121import { KeilARMOption , KeilC51Option , KeilParser , KeilRteDependence } from './KeilXmlParser' ;
@@ -1371,6 +1374,16 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
13711374 projectIndex : element . val . projectIndex
13721375 } ) ) ;
13731376
1377+ // setting: debugger
1378+ const debuggerId = project . getTargetInfo ( ) . settings . debugger || 'unknown' ;
1379+ iList . push ( new ProjTreeItem ( TreeItemType . SETTINGS_ITEM , {
1380+ key : 'debugger' ,
1381+ value : DEBUGGER_MAPS [ debuggerId ] . name ,
1382+ keyAlias : view_str$settings$debugger ,
1383+ tooltip : newMarkdownString ( `**${ view_str$settings$debugger } **: \`${ DEBUGGER_MAPS [ debuggerId ] . name } \`` ) ,
1384+ projectIndex : element . val . projectIndex
1385+ } ) ) ;
1386+
13741387 // setting: project env
13751388 iList . push ( new ProjTreeItem ( TreeItemType . SETTINGS_ITEM , {
13761389 key : 'project.env' ,
@@ -1969,6 +1982,7 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
19691982 libList : [ ]
19701983 } ,
19711984 builderOptions : { } ,
1985+ settings : { }
19721986 } ;
19731987 eidePrjCfg . targets [ targetName ] = nEideTarget ;
19741988
@@ -2206,7 +2220,8 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
22062220 incList : [ ] ,
22072221 defineList : [ ] ,
22082222 libList : [ ]
2209- }
2223+ } ,
2224+ settings : { }
22102225 } ;
22112226
22122227 nEideTarget . cppPreprocessAttrs . defineList = eTarget . builldArgs . cMacros ;
@@ -4203,7 +4218,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
42034218 }
42044219 }
42054220
4206- ExportKeilXml ( prjItem : ProjTreeItem ) {
4221+ async ExportKeilXml ( prjItem : ProjTreeItem ) {
42074222 try {
42084223 const prj = this . getProjectByTreeItem ( prjItem ) ;
42094224 if ( ! prj )
@@ -4221,7 +4236,27 @@ export class ProjectExplorer implements CustomConfigurationProvider {
42214236 return ;
42224237 }
42234238
4224- const xmlFile = prj . ExportToKeilProject ( ) ;
4239+ const prjConfig = prj . GetConfiguration ( ) . config ;
4240+ const keilSuffix = prjConfig . type === 'C51' ? 'uvproj' : 'uvprojx' ;
4241+ const defaultUri = vscode . Uri . file ( NodePath . join ( prj . GetRootDir ( ) . path , `${ prjConfig . name } .${ keilSuffix } ` ) ) ;
4242+
4243+ const uri = await vscode . window . showSaveDialog ( {
4244+ defaultUri : defaultUri ,
4245+ filters : { 'Keil Project' : [ keilSuffix ] }
4246+ } ) ;
4247+ if ( ! uri ) return ;
4248+
4249+ // warn if the chosen save path is on a different drive from the project root;
4250+ // in that case, cross-drive paths cannot be made relative and will be written as absolute paths
4251+ const saveDrive = NodePath . parse ( uri . fsPath ) . root . toLowerCase ( ) ;
4252+ const prjDrive = NodePath . parse ( prj . GetRootDir ( ) . path ) . root . toLowerCase ( ) ;
4253+ if ( saveDrive !== prjDrive ) {
4254+ GlobalEvent . emit ( 'msg' , newMessage ( 'Warning' , view_str$keil_export_path_warning
4255+ . replace ( '{0}' , saveDrive )
4256+ . replace ( '{1}' , prjDrive ) ) ) ;
4257+ }
4258+
4259+ const xmlFile = prj . ExportToKeilProject ( new File ( uri . fsPath ) ) ;
42254260
42264261 if ( xmlFile ) {
42274262 GlobalEvent . emit ( 'msg' , newMessage ( 'Info' , export_keil_xml_ok + prj . toRelativePath ( xmlFile . path ) ) ) ;
@@ -6192,6 +6227,36 @@ export class ProjectExplorer implements CustomConfigurationProvider {
61926227 }
61936228 }
61946229 break ;
6230+ case 'debugger' :
6231+ {
6232+ const selections : any [ ] = [ ] ;
6233+
6234+ if ( prj . getProjectType ( ) !== 'C51' ) {
6235+
6236+ selections . push ( {
6237+ value : 'cortex-debug' ,
6238+ label : DEBUGGER_MAPS [ 'cortex-debug' ] . name ,
6239+ detail : `extension id: ${ DEBUGGER_MAPS [ 'cortex-debug' ] . extension_id } `
6240+ } ) ;
6241+
6242+ selections . push ( {
6243+ value : 'cdt-gdb-debug' ,
6244+ label : DEBUGGER_MAPS [ 'cdt-gdb-debug' ] . name ,
6245+ detail : `extension id: ${ DEBUGGER_MAPS [ 'cdt-gdb-debug' ] . extension_id } `
6246+ } ) ;
6247+ }
6248+
6249+ const res = await vscode . window . showQuickPick ( selections , { placeHolder : 'Select debugger type' } ) ;
6250+ if ( res ) {
6251+ const targetInfo = prj . getTargetInfo ( ) ;
6252+ if ( targetInfo . settings . debugger !== res . value ) {
6253+ targetInfo . settings . debugger = res . value ;
6254+ this . updateSettingsView ( prj ) ;
6255+ prj . Save ( true ) ;
6256+ }
6257+ }
6258+ }
6259+ break ;
61956260 // 'project.env'
61966261 case 'project.env' :
61976262 {
@@ -7222,7 +7287,8 @@ export class ProjectExplorer implements CustomConfigurationProvider {
72227287 type : 'jlink' | 'openocd' | 'pyocd' ,
72237288 prj : AbstractProject , old_cfgs : any [ ] ) : Promise < { debug_config : any , override_idx : number } | undefined > {
72247289
7225- const _elfPath = File . ToUnixPath ( prj . getOutputDir ( ) ) + '/' + `${ prj . getProjectName ( ) } .elf` ;
7290+ const _outFullName = File . ToUnixPath ( prj . getOutputDir ( ) ) + '/' + `${ prj . getProjectName ( ) } `
7291+ const _elfPath = `${ _outFullName } .elf` ;
72267292 const _debugConfigTemplates = {
72277293 'jlink' : {
72287294 cwd : '${workspaceRoot}' ,
@@ -7260,9 +7326,15 @@ export class ProjectExplorer implements CustomConfigurationProvider {
72607326 } ;
72617327
72627328 const debugConfig : any = _debugConfigTemplates [ type ] ;
7329+ const toolchain = prj . getToolchain ( ) ;
7330+
7331+ if ( toolchain . name == 'AC5' || toolchain . name == 'AC6' ) {
7332+ debugConfig [ 'executable' ] = undefined ;
7333+ debugConfig [ 'loadFiles' ] = [ `${ _outFullName } .hex` ] ;
7334+ debugConfig [ 'symbolFiles' ] = [ `${ _outFullName } .axf` ] ;
7335+ }
72637336
72647337 /* set gdb toolchain */
7265- const toolchain = prj . getToolchain ( ) ;
72667338 if ( toolchain . getToolchainPrefix ) {
72677339 debugConfig . toolchainPrefix = toolchain . getToolchainPrefix ( ) . trim ( ) . replace ( / - $ / , '' ) ;
72687340 } else if ( debugConfig . toolchainPrefix ) {
0 commit comments