Skip to content

Commit 1022f2a

Browse files
committed
update eide.yml struct
1 parent 0812181 commit 1022f2a

11 files changed

+184
-167
lines changed

src/CodeBuilder.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export abstract class CodeBuilder {
370370
const toolchain = this.project.getToolchain();
371371

372372
const outDir = File.ToUnixPath(this.project.getOutputDir());
373-
const compileOptions: BuilderOptions = this.project.GetConfiguration().compileConfigModel.getOptions();
373+
const compileOptions: BuilderOptions = this.project.GetConfiguration().toolchainConfigModel.getOptions();
374374
const memMaxSize = this.getMcuMemorySize();
375375
const sourceInfo = this.genSourceInfo();
376376
const builderModeList: string[] = []; // build mode
@@ -882,7 +882,7 @@ export class ARMCodeBuilder extends CodeBuilder {
882882
+ File.sep + config.name + '.sct'));
883883

884884
let data = '';
885-
const memTxt = this.GenMemTxtBySct(this.GetMemoryScatter(config.compileConfig.storageLayout));
885+
const memTxt = this.GenMemTxtBySct(this.GetMemoryScatter(config.toolchainConfig.storageLayout));
886886

887887
memTxt.forEach(tItem => {
888888
let str = tItem.name + tItem.addr + '{\r\n';
@@ -946,9 +946,9 @@ export class ARMCodeBuilder extends CodeBuilder {
946946

947947
const prjConfig = this.project.GetConfiguration<ArmBaseCompileData>();
948948

949-
if (!prjConfig.config.compileConfig.useCustomScatterFile) {
949+
if (!prjConfig.config.toolchainConfig.useCustomScatterFile) {
950950

951-
const memLayout: ARMStorageLayout = JSON.parse(JSON.stringify(prjConfig.config.compileConfig.storageLayout));
951+
const memLayout: ARMStorageLayout = JSON.parse(JSON.stringify(prjConfig.config.toolchainConfig.storageLayout));
952952
const res: MemorySize = {};
953953

954954
try {
@@ -1001,9 +1001,9 @@ export class ARMCodeBuilder extends CodeBuilder {
10011001
*
10021002
* unify_builder 会根据这些条目来匹配 options.global['microcontroller-cpu'] 传入的 cpu_id, 然后生成对应的编译参数
10031003
*/
1004-
const cpu_id = config.compileConfig.cpuType.toLowerCase();
1005-
let fpu_suffix = ARMCodeBuilder.getFpuSuffix(config.compileConfig.cpuType,
1006-
config.compileConfig.floatingPointHardware);
1004+
const cpu_id = config.toolchainConfig.cpuType.toLowerCase();
1005+
let fpu_suffix = ARMCodeBuilder.getFpuSuffix(config.toolchainConfig.cpuType,
1006+
config.toolchainConfig.floatingPointHardware);
10071007

10081008
/**
10091009
* 某些情况下,fpu是通过添加 +<扩展名> 来开启,因此无需 fpu_suffix 标记
@@ -1029,7 +1029,7 @@ export class ARMCodeBuilder extends CodeBuilder {
10291029
options.global['$clang-arch-extensions'] = '';
10301030
options.global['$armlink-arch-extensions'] = '';
10311031
if (ArmCpuUtils.getArchExtensions(cpu_id, toolchain.name).length > 0) {
1032-
const opts = (config.compileConfig.archExtensions || '').split(',');
1032+
const opts = (config.toolchainConfig.archExtensions || '').split(',');
10331033
// for gcc
10341034
if (isGccFamilyToolchain(toolchain.name)) {
10351035
options.global['$arch-extensions'] = opts.join('');
@@ -1051,15 +1051,15 @@ export class ARMCodeBuilder extends CodeBuilder {
10511051

10521052
const ldFileList: string[] = [];
10531053

1054-
let scatterFilePath: string = config.compileConfig.scatterFilePath;
1054+
let scatterFilePath: string = config.toolchainConfig.scatterFilePath;
10551055

10561056
switch (toolchain.name) {
10571057

10581058
// 'armcc' can select whether use custom linker file
10591059
case 'AC5':
10601060
case 'AC6':
10611061
{
1062-
if (config.compileConfig.useCustomScatterFile) { // use custom linker script files
1062+
if (config.toolchainConfig.useCustomScatterFile) { // use custom linker script files
10631063
scatterFilePath.split(',')
10641064
.filter(s => s.trim() != '')
10651065
.forEach((sctPath) => {
@@ -1154,7 +1154,7 @@ class RiscvCodeBuilder extends CodeBuilder {
11541154
const config = this.project.GetConfiguration<RiscvCompileData>().config;
11551155

11561156
const ldFileList: string[] = [];
1157-
config.compileConfig.linkerScriptPath.split(',')
1157+
config.toolchainConfig.linkerScriptPath.split(',')
11581158
.filter(s => s.trim() != '')
11591159
.forEach((sctPath) => {
11601160
ldFileList.push(this.convLinkerScriptPathForCompiler(sctPath));
@@ -1180,7 +1180,7 @@ class MipsCodeBuilder extends CodeBuilder {
11801180
const config = this.project.GetConfiguration<MipsCompileData>().config;
11811181

11821182
const ldFileList: string[] = [];
1183-
config.compileConfig.linkerScriptPath.split(',')
1183+
config.toolchainConfig.linkerScriptPath.split(',')
11841184
.filter(s => s.trim() != '')
11851185
.forEach((sctPath) => {
11861186
ldFileList.push(this.convLinkerScriptPathForCompiler(sctPath));
@@ -1210,7 +1210,7 @@ class AnyGccCodeBuilder extends CodeBuilder {
12101210
}
12111211

12121212
// set linker script
1213-
options.linker['linker-script'] = config.compileConfig.linkerScriptPath.split(',')
1213+
options.linker['linker-script'] = config.toolchainConfig.linkerScriptPath.split(',')
12141214
.filter(s => s.trim() != '')
12151215
.map((sctPath) => {
12161216
return this.convLinkerScriptPathForCompiler(sctPath);
@@ -1262,7 +1262,7 @@ class C51CodeBuilder extends CodeBuilder {
12621262

12631263
const results = super.getLibDirs();
12641264
const toolchain = this.project.getToolchain();
1265-
const options: BuilderOptions = this.project.GetConfiguration().compileConfigModel.getOptions();
1265+
const options: BuilderOptions = this.project.GetConfiguration().toolchainConfigModel.getOptions();
12661266

12671267
/* for sdcc + binutils toolchain, we need provide -L for ld */
12681268
if (toolchain.name == 'GNU_SDCC_MCS51') {
@@ -1284,11 +1284,11 @@ class C51CodeBuilder extends CodeBuilder {
12841284
const toolchain = this.project.getToolchain();
12851285

12861286
/* set linker script if it's existed */
1287-
if (config.compileConfig.linkerScript) {
1287+
if (config.toolchainConfig.linkerScript) {
12881288

12891289
const ldFileList: string[] = [];
12901290

1291-
config.compileConfig.linkerScript.split(',')
1291+
config.toolchainConfig.linkerScript.split(',')
12921292
.filter(s => s.trim() != '')
12931293
.forEach((sctPath) => {
12941294
ldFileList.push(this.convLinkerScriptPathForCompiler(sctPath, true));

src/DependenceManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ export class DependenceManager implements ManagerInterface {
550550

551551
const toolchain = this.project.getToolchain();
552552
const prjConfig = this.project.GetConfiguration();
553-
const builderOpts = prjConfig.compileConfigModel.getOptions();
553+
const builderOpts = prjConfig.toolchainConfigModel.getOptions();
554554

555555
const incList = ArrayDelRepetition(toolchain.getSystemIncludeList(builderOpts)
556556
.concat(toolchain.getDefaultIncludeList()));

src/EIDEProject.ts

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import {
7171
view_str$prompt$userCanceledOperation,
7272
continue_text,
7373
cancel_text,
74+
view_str$prompt$migrationFailed,
7475
} from './StringTable';
7576
import { SettingManager } from './SettingManager';
7677
import { ExeCmd } from '../lib/node-utility/Executable';
@@ -81,7 +82,6 @@ import { EventData, CurrentDevice, ArmBaseCompileConfigModel, ArmBaseCompileData
8182
import * as FileLock from '../lib/node-utility/FileLock';
8283
import { CompilerCommandsDatabaseItem, CodeBuilder } from './CodeBuilder';
8384
import { xpackRequireDevTools } from './XpackDevTools';
84-
import { doMigration } from './EIDEProjectMigration';
8585

8686
export 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

Comments
 (0)