Skip to content

Commit eda76f0

Browse files
committed
copy source options file if it's not existed when switch target
1 parent 79bd75c commit eda76f0

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/EIDEProject.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,8 +1421,9 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
14211421
targets[targetName] = prjConfig.cloneCurrentTarget();
14221422
}
14231423

1424-
const oldBuilderOptsFile = prjConfig.compileConfigModel
1424+
const prevBuilderOptsFile = prjConfig.compileConfigModel
14251425
.getOptionsFile(this.getEideDir().path, prjConfig.config);
1426+
const prevSourcesOptsFile = this.getSourceExtraArgsCfgFile(true);
14261427

14271428
// update current target name
14281429
prjConfigData.mode = targetName;
@@ -1485,12 +1486,24 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
14851486
.getOptionsFile(this.getEideDir().path, prjConfig.config, true);
14861487
if (!optsFile.IsFile()) {
14871488
try {
1488-
fs.copyFileSync(oldBuilderOptsFile.path, optsFile.path);
1489+
fs.copyFileSync(prevBuilderOptsFile.path, optsFile.path);
14891490
} catch (error) {
14901491
// nothing todo
14911492
}
14921493
}
14931494

1495+
// if source options file is not existed, copy it.
1496+
if (prevSourcesOptsFile.IsFile()) {
1497+
const srcOptsFile = File.fromArray([this.getEideDir().path, `${targetName.toLowerCase()}.files.options.yml`]);
1498+
if (!srcOptsFile.IsFile()) {
1499+
try {
1500+
fs.copyFileSync(prevSourcesOptsFile.path, srcOptsFile.path);
1501+
} catch (error) {
1502+
// nothing todo
1503+
}
1504+
}
1505+
}
1506+
14941507
this.sourceRoots.forceUpdateAllFolders();
14951508
this.virtualSource.forceUpdateAllFolders();
14961509

src/EIDETypeDefine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ export interface ProjectConfigData<T extends BuilderConfigData> {
365365
type: ProjectType;
366366

367367
// cur target info (virtual node)
368-
mode: string; // target name
368+
mode: string; // target name (And for historical reasons, that's what it's called)
369369
excludeList: string[];
370370
toolchain: ToolchainName;
371371
compileConfig: T;

0 commit comments

Comments
 (0)