@@ -71,6 +71,7 @@ import {
7171 view_str$prompt$userCanceledOperation ,
7272 continue_text ,
7373 cancel_text ,
74+ view_str$prompt$migrationFailed ,
7475} from './StringTable' ;
7576import { SettingManager } from './SettingManager' ;
7677import { ExeCmd } from '../lib/node-utility/Executable' ;
@@ -81,7 +82,6 @@ import { EventData, CurrentDevice, ArmBaseCompileConfigModel, ArmBaseCompileData
8182import * as FileLock from '../lib/node-utility/FileLock' ;
8283import { CompilerCommandsDatabaseItem , CodeBuilder } from './CodeBuilder' ;
8384import { xpackRequireDevTools } from './XpackDevTools' ;
84- import { doMigration } from './EIDEProjectMigration' ;
8585
8686export class CheckError extends Error {
8787}
@@ -1604,16 +1604,16 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
16041604 continue ;
16051605 }
16061606
1607- if ( name === 'compileConfig ' ) {
1608- const compileConfig = prjConfig . compileConfigModel . data ;
1607+ if ( name === 'toolchainConfig ' ) {
1608+ const toolchainConfig = prjConfig . toolchainConfigModel . data ;
16091609 const oldCompileConfig = oldTarget [ name ] ;
16101610 // delete all properties
1611- for ( const key in compileConfig ) {
1612- delete compileConfig [ key ] ;
1611+ for ( const key in toolchainConfig ) {
1612+ delete toolchainConfig [ key ] ;
16131613 }
16141614 // update properties
16151615 for ( const key in oldCompileConfig ) {
1616- compileConfig [ key ] = copyObject ( oldCompileConfig [ key ] ) ;
1616+ toolchainConfig [ key ] = copyObject ( oldCompileConfig [ key ] ) ;
16171617 }
16181618 continue ;
16191619 }
@@ -1639,9 +1639,10 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
16391639 }
16401640
16411641 // copy source options if not exist
1642- const opts = this . getSourceExtraArgsCfg ( prevTargetName ) ;
1643- if ( opts ) {
1644- this . setSourceExtraArgsCfg ( opts , targetName ) ;
1642+ if ( isNewTarget ) {
1643+ const opts = this . getSourceExtraArgsCfg ( prevTargetName ) ;
1644+ if ( opts )
1645+ this . setSourceExtraArgsCfg ( opts , targetName ) ;
16451646 }
16461647
16471648 this . sourceRoots . forceUpdateAllFolders ( ) ;
@@ -1887,7 +1888,7 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
18871888 . filter ( f => keywords . some ( k => f . name . toLowerCase ( ) . includes ( k ) ) ) ;
18881889 // matched dirs, filter files
18891890 if ( subdirs . length > 0 ) {
1890- const cpuTyp = ( < ArmBaseCompileConfigModel > this . GetConfiguration ( ) . compileConfigModel ) . data . cpuType ;
1891+ const cpuTyp = ( < ArmBaseCompileConfigModel > this . GetConfiguration ( ) . toolchainConfigModel ) . data . cpuType ;
18911892 const allfiles = subdirs [ 0 ] . GetList ( undefined , File . EXCLUDE_ALL_FILTER ) ;
18921893 const unusedFiles = allfiles . filter ( f => ! matchLibFileAndCpuTyp ( f . name , cpuTyp ) ) ;
18931894 libPaths . push ( subdirs [ 0 ] . path ) ;
@@ -1918,7 +1919,7 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
19181919 let isUseCustomScatterFile = false ;
19191920 if ( this . getProjectType ( ) == 'ARM' )
19201921 isUseCustomScatterFile = this . GetConfiguration < ArmBaseCompileData > ( ) . config
1921- . compileConfig . useCustomScatterFile ;
1922+ . toolchainConfig . useCustomScatterFile ;
19221923 const toolchainName = this . getToolchain ( ) . name ;
19231924 return ( toolchainName === 'AC5' || toolchainName === 'AC6' ) && ! isUseCustomScatterFile ;
19241925 }
@@ -2520,7 +2521,7 @@ $(OUT_DIR):
25202521 }
25212522
25222523 getBuilderOptions ( ) : BuilderOptions {
2523- return this . GetConfiguration ( ) . compileConfigModel . getOptions ( ) ;
2524+ return this . GetConfiguration ( ) . toolchainConfigModel . getOptions ( ) ;
25242525 }
25252526
25262527 //---
@@ -2534,10 +2535,10 @@ $(OUT_DIR):
25342535 let toolchainRoot = this . toolchain . getToolchainDir ( ) . path ;
25352536 this . registerBuiltinVar ( 'ToolchainRoot' , ( ) => toolchainRoot ) ;
25362537
2537- const curOptions = prjConfig . compileConfigModel . getOptions ( ) ;
2538+ const curOptions = prjConfig . toolchainConfigModel . getOptions ( ) ;
25382539 const newOptions = toolManager . migrateBuilderOptions ( curOptions , this . toolchain ) ;
25392540 if ( newOptions ) {
2540- prjConfig . compileConfigModel . setOptions ( newOptions , undefined , this . toolchain . name ) ;
2541+ prjConfig . toolchainConfigModel . setOptions ( newOptions , undefined , this . toolchain . name ) ;
25412542 }
25422543 }
25432544
@@ -2648,7 +2649,7 @@ $(OUT_DIR):
26482649
26492650 prjConfig . on ( 'dataChanged' , ( type ) => this . onPrjConfigChanged ( type ) ) ;
26502651
2651- prjConfig . compileConfigModel . on ( 'event' , ( eDat ) => this . onConfigurationEvent ( eDat ) ) ;
2652+ prjConfig . toolchainConfigModel . on ( 'event' , ( eDat ) => this . onConfigurationEvent ( eDat ) ) ;
26522653
26532654 prjConfig . uploadConfigModel . on ( 'event' , ( eDat ) => this . onConfigurationEvent ( eDat ) ) ;
26542655
@@ -2740,24 +2741,29 @@ $(OUT_DIR):
27402741 }
27412742
27422743 // get all builder options
2743- const allOptions : { target_l : string , toolchain : string , options : BuilderOptions } [ ] = [ ] ;
2744+ const allOptions : {
2745+ target_l : string ,
2746+ toolchain : string ,
2747+ options : BuilderOptions ,
2748+ file : File ,
2749+ notCleanup ?: boolean
2750+ } [ ] = [ ] ;
27442751 for ( const file of eideDir . GetList ( undefined , File . EXCLUDE_ALL_FILTER ) ) {
27452752 const tidx = toolchainInfos . findIndex ( info => file . name . endsWith ( info . configFileName ) ) ;
27462753 if ( tidx != - 1 ) {
27472754 const toolInfo = toolchainInfos [ tidx ] ;
27482755 // get lower case target name
2749- let targetName_l : string = file . name . replace ( toolInfo . configFileName , '' ) ;
2750- if ( targetName_l == '' ) targetName_l = 'release' ;
2751- else targetName_l = targetName_l . substr ( 0 , targetName_l . length - 1 ) ;
2756+ const t = file . name . replace ( toolInfo . configFileName , '' ) ;
2757+ const targetName_l = t === ''
2758+ ? 'release' : t . substr ( 0 , t . length - 1 ) ; // use 't.length - 1' remove tailing '.'
27522759 // append in list
27532760 const options = jsonc . parse ( file . Read ( ) ) ;
27542761 allOptions . push ( {
27552762 target_l : targetName_l ,
27562763 toolchain : toolInfo . name ,
27572764 options : options ,
2765+ file : file
27582766 } ) ;
2759- // delete old builder options file, we don't need it anymore.
2760- try { fs . unlinkSync ( file . path ) ; } catch { } ;
27612767 }
27622768 }
27632769
@@ -2769,10 +2775,22 @@ $(OUT_DIR):
27692775 if ( idx != - 1 ) {
27702776 const targetName = allTargetNames [ idx ] ;
27712777 const target = conf . targets [ targetName ] ;
2772- if ( target . builderOptions == undefined ) target . builderOptions = { } ;
2773- target . builderOptions [ optionsInfo . toolchain ] = optionsInfo . options ;
2778+ if ( target . toolchainConfigMap &&
2779+ target . toolchainConfigMap [ optionsInfo . toolchain ] ) {
2780+ target . toolchainConfigMap [ optionsInfo . toolchain ] . options = optionsInfo . options ;
2781+ } else {
2782+ optionsInfo . notCleanup = true ;
2783+ GlobalEvent . log_warn ( `No options for toolchain ${ optionsInfo . toolchain } in toolchainConfigMap` ) ;
2784+ GlobalEvent . log_show ( ) ;
2785+ }
27742786 }
27752787 }
2788+
2789+ // delete old builder options file, we don't need it anymore.
2790+ for ( const optionsInfo of allOptions ) {
2791+ if ( ! optionsInfo . notCleanup )
2792+ try { fs . unlinkSync ( optionsInfo . file . path ) ; } catch { } ;
2793+ }
27762794 }
27772795
27782796 // remove 'sourceDirList' of custom_dep
@@ -2830,7 +2848,11 @@ $(OUT_DIR):
28302848 /* udpate project version to lastest */
28312849 if ( this . isOldVersionProject ) {
28322850 conf . version = EIDE_CONF_VERSION ;
2833- eideFile . Write ( JSON . stringify ( conf , undefined , 2 ) ) ;
2851+ eideFile . Write ( ProjectConfiguration . dumpProjectFile ( conf ) ) ;
2852+ // rm old eide.json file
2853+ const eideJsonFile = File . from ( wsFile . dir , AbstractProject . EIDE_DIR , 'eide.json' ) ;
2854+ if ( eideJsonFile . IsExist ( ) )
2855+ fs . unlinkSync ( eideJsonFile . path ) ;
28342856 }
28352857 }
28362858
@@ -3163,7 +3185,7 @@ class EIDEProject extends AbstractProject {
31633185 protected onDeviceChanged ( oldDevice ?: CurrentDevice | undefined ) : void {
31643186
31653187 const prjConfig = this . GetConfiguration ( ) ;
3166- const cConfig = prjConfig . compileConfigModel ;
3188+ const cConfig = prjConfig . toolchainConfigModel ;
31673189
31683190 // project type is ARM
31693191 if ( cConfig instanceof ArmBaseCompileConfigModel ) {
@@ -3976,7 +3998,7 @@ class EIDEProject extends AbstractProject {
39763998 // get project includes and defines
39773999 const depMerge = prjConfig . GetAllMergeDep ( ) ;
39784000 const defMacros : string [ ] = [ '__VSCODE_CPPTOOL' ] ; // it's for internal force include header
3979- const intrDefs = this . _getCompilerIntrDefsForCpptools ( toolchain , < any > prjConfig . config . compileConfig , builderOpts ) ;
4001+ const intrDefs = this . _getCompilerIntrDefsForCpptools ( toolchain , < any > prjConfig . config . toolchainConfig , builderOpts ) ;
39804002 const defLi = defMacros . concat ( depMerge . defineList , intrDefs ) ;
39814003 depMerge . incList = depMerge . incList . concat ( this . getSourceIncludeList ( ) ) . map ( p => this . ToAbsolutePath ( p ) ) ;
39824004
@@ -3992,11 +4014,11 @@ class EIDEProject extends AbstractProject {
39924014 this . cppToolsConfig . cppCompilerArgs = undefined ;
39934015
39944016 // preset cpu info for arm project
3995- if ( prjConfig . compileConfigModel instanceof ArmBaseCompileConfigModel ) {
4017+ if ( prjConfig . toolchainConfigModel instanceof ArmBaseCompileConfigModel ) {
39964018 builderOpts . global = builderOpts . global || { } ;
3997- const cpuName : string = prjConfig . compileConfigModel . data . cpuType . toLowerCase ( ) ;
3998- const fpuName : string = prjConfig . compileConfigModel . data . floatingPointHardware ;
3999- const archExt : string = prjConfig . compileConfigModel . data . archExtensions || '' ;
4019+ const cpuName : string = prjConfig . toolchainConfigModel . data . cpuType . toLowerCase ( ) ;
4020+ const fpuName : string = prjConfig . toolchainConfigModel . data . floatingPointHardware ;
4021+ const archExt : string = prjConfig . toolchainConfigModel . data . archExtensions || '' ;
40004022 // 将 cpu 信息作为上下文传递给 updateCppIntellisenceCfg,
40014023 // 以便 toolchain 能够生成合适的 compiler args 用于执行 Intellisence
40024024 builderOpts . global [ '_cpuName' ] = cpuName ;
0 commit comments