@@ -970,7 +970,7 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem> {
970970 // setting: out folder
971971 iList . push ( new ProjTreeItem ( TreeItemType . SETTINGS_ITEM , {
972972 key : 'outDir' ,
973- value : NodePath . normalize ( config . config . outDir ) ,
973+ value : File . normalize ( config . config . outDir ) ,
974974 alias : view_str$settings$outFolderName ,
975975 tooltip : view_str$settings$outFolderName ,
976976 projectIndex : element . val . projectIndex
@@ -1453,24 +1453,11 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem> {
14531453 if ( projectnum == 0 )
14541454 throw new Error ( `Not found any project in this IAR workbench ! [path]: ${ option . projectFile . path } ` ) ;
14551455
1456- // store vscode workspace
1457- const vscWorkspaceFile = File . fromArray ( [ ewwRoot . path , `${ ewwInfo . name } .code-workspace` ] ) ;
1458- {
1459- const vscWorkspace = {
1460- "folders" : < any [ ] > [ ]
1461- } ;
1462-
1463- for ( const projpath in ewwInfo . projects ) {
1464- const repath = ewwRoot . ToRelativePath ( projpath ) || projpath ;
1465- const project = ewwInfo . projects [ projpath ] ;
1466- vscWorkspace . folders . push ( {
1467- name : project . name ,
1468- path : NodePath . dirname ( repath )
1469- } ) ;
1470- }
1456+ const vscWorkspace = {
1457+ "folders" : < any [ ] > [ ]
1458+ } ;
14711459
1472- fs . writeFileSync ( vscWorkspaceFile . path , JSON . stringify ( vscWorkspace , undefined , 4 ) ) ;
1473- }
1460+ const vscWorkspaceFile = File . fromArray ( [ ewwRoot . path , `${ ewwInfo . name } .code-workspace` ] ) ;
14741461
14751462 const toolchainType : ToolchainName = 'IAR_ARM' ;
14761463
@@ -1479,23 +1466,30 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem> {
14791466 for ( const path_ in ewwInfo . projects ) {
14801467
14811468 const iarproj = ewwInfo . projects [ path_ ] ;
1482- const prjRoot = new File ( NodePath . dirname ( path_ ) ) ;
1483- const createNewDir = NodePath . normalize ( prjRoot . path ) == NodePath . normalize ( ewwRoot . path ) ;
1469+ const iarPrjRoot = new File ( NodePath . dirname ( path_ ) ) ;
14841470
1471+ const needCreateNewDir = File . normalize ( iarPrjRoot . path ) == File . normalize ( ewwRoot . path ) ;
14851472 const basePrj = AbstractProject . NewProject ( ) . createBase ( {
14861473 name : iarproj . name ,
14871474 projectName : iarproj . name ,
14881475 type : 'ARM' ,
1489- outDir : prjRoot
1490- } , createNewDir ) ;
1476+ outDir : iarPrjRoot
1477+ } , needCreateNewDir ) ;
1478+
1479+ const prjRoot = basePrj . rootFolder ;
1480+
1481+ vscWorkspace . folders . push ( {
1482+ name : iarproj . name ,
1483+ path : ewwRoot . ToRelativePath ( prjRoot . path ) || prjRoot . path
1484+ } ) ;
14911485
14921486 if ( ! project0workspacefile )
14931487 project0workspacefile = basePrj . workspaceFile ;
14941488
14951489 const eidePrjCfg = basePrj . prjConfig . config ;
14961490 const eideFolder = File . fromArray ( [ prjRoot . path , AbstractProject . EIDE_DIR ] ) ;
14971491
1498- // set project env
1492+ // export project env
14991493 {
15001494 const envFile = File . fromArray ( [ eideFolder . path , 'env.ini' ] ) ;
15011495 const envCont = [
@@ -1504,9 +1498,13 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem> {
15041498 `###########################################################` ,
15051499 `` ,
15061500 ] ;
1501+
1502+ iarproj . envs [ 'PROJ_DIR' ] = needCreateNewDir ? '..' : '.' ;
1503+
15071504 for ( const key in iarproj . envs ) {
15081505 envCont . push ( `${ key } = ${ iarproj . envs [ key ] } ` ) ;
15091506 }
1507+
15101508 envFile . Write ( envCont . join ( os . EOL ) ) ;
15111509 }
15121510
@@ -1702,11 +1700,14 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem> {
17021700 basePrj . prjConfig . Save ( ) ;
17031701 }
17041702
1703+ // store vscode workspace
1704+ fs . writeFileSync ( vscWorkspaceFile . path , JSON . stringify ( vscWorkspace , undefined , 4 ) ) ;
1705+
17051706 // switch project
17061707 const selection = await vscode . window . showInformationMessage (
17071708 view_str$operation$import_done , continue_text , cancel_text ) ;
17081709 if ( selection === continue_text ) {
1709- WorkspaceManager . getInstance ( ) . openWorkspace ( projectnum > 1
1710+ WorkspaceManager . getInstance ( ) . openWorkspace ( vscWorkspace . folders . length > 1
17101711 ? vscWorkspaceFile
17111712 : project0workspacefile ) ;
17121713 }
@@ -3494,7 +3495,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
34943495 rootDir = prj . GetRootDir ( ) ;
34953496 templateName = prjConfig . name ;
34963497 tmp_suffix = 'ept' ;
3497- const prjOutFolder = NodePath . normalize ( prj . GetConfiguration ( ) . config . outDir ) ;
3498+ const prjOutFolder = File . normalize ( prj . GetConfiguration ( ) . config . outDir ) ;
34983499 defExcludeList . push ( `${ prjOutFolder } ` , `${ prjOutFolder } ${ File . sep } *` ) ;
34993500 resIgnoreList = prj . readIgnoreList ( ) ;
35003501 const prjUid = prjConfig . miscInfo . uid ;
@@ -4167,7 +4168,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
41674168 }
41684169
41694170 cppcheckConf = cppcheckConf
4170- . replace ( '${cppcheck_build_folder}' , NodePath . normalize ( prj . getOutputRoot ( ) ) )
4171+ . replace ( '${cppcheck_build_folder}' , File . normalize ( prj . getOutputRoot ( ) ) )
41714172 . replace ( '${platform}' , cppcheck_plat )
41724173 . replace ( '${lib_list}' , cfgList . map ( ( str ) => `<library>${ str } </library>` ) . join ( os . EOL + '\t\t' ) )
41734174 . replace ( '${include_list}' , includeList . map ( ( str ) => `<dir name="${ str } /"/>` ) . join ( os . EOL + '\t\t' ) )
@@ -4396,7 +4397,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
43964397 case 'outDir' :
43974398 {
43984399 const prjConfig = prj . GetConfiguration ( ) . config ;
4399- const oldFolderName = NodePath . normalize ( prjConfig . outDir ) ;
4400+ const oldFolderName = File . normalize ( prjConfig . outDir ) ;
44004401
44014402 const newName = await vscode . window . showInputBox ( {
44024403 value : oldFolderName ,
@@ -4972,7 +4973,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
49724973 let file : File | undefined ;
49734974
49744975 if ( item . val . value instanceof File ) { // if value is a file, use it
4975- file = new File ( NodePath . normalize ( item . val . value . path ) ) ;
4976+ file = new File ( File . normalize ( item . val . value . path ) ) ;
49764977 }
49774978
49784979 if ( file ) {
0 commit comments