Skip to content

Commit c9fd859

Browse files
authored
Merge pull request #191 from github0null/dev
v3.10.5
2 parents 1d641ef + a22c64f commit c9fd859

8 files changed

Lines changed: 104 additions & 96 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ All notable version changes will be recorded in this file.
66

77
***
88

9+
### [v3.10.5] revision
10+
11+
**Fix**:
12+
- `Symbol Link`: Not work for symbol link source folder.
13+
14+
**Optimize**:
15+
- `High Cpu Load`: Optimize code, reduce `find in system path` operations
16+
17+
***
18+
919
### [v3.10.4] revision
1020

1121
**Fix**:

lib/node-utility

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"homepage": "https://em-ide.com",
3636
"license": "MIT",
3737
"description": "A mcu development environment for 8051/AVR/STM8/Cortex-M/RISC-V",
38-
"version": "3.10.4",
38+
"version": "3.10.5",
3939
"preview": false,
4040
"engines": {
4141
"vscode": "^1.63.0"

src/EIDEProject.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,8 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
18251825
const toolManager = ToolchainManager.getInstance();
18261826

18271827
this.toolchain = toolManager.getToolchain(prjConfig.config.type, prjConfig.config.toolchain);
1828-
this.registerBuiltinVar('ToolchainRoot', () => this.getToolchain().getToolchainDir().path);
1828+
let toolchainRoot = this.toolchain.getToolchainDir().path;
1829+
this.registerBuiltinVar('ToolchainRoot', () => toolchainRoot);
18291830

18301831
const opFile = prjConfig.compileConfigModel.getOptionsFile(this.getEideDir().path, prjConfig.config);
18311832
toolManager.updateToolchainConfig(opFile, this.toolchain);
@@ -2764,7 +2765,8 @@ class EIDEProject extends AbstractProject {
27642765
"hars.cppsnippets",
27652766
"zixuanwang.linkerscript",
27662767
"redhat.vscode-yaml",
2767-
"IBM.output-colorizer"
2768+
"IBM.output-colorizer",
2769+
"cschlosser.doxdocgen"
27682770
];
27692771

27702772
const prjInfo = this.GetConfiguration().config;
@@ -2934,7 +2936,7 @@ class EIDEProject extends AbstractProject {
29342936
} catch (error) {
29352937
GlobalEvent.emit('msg', ExceptionToMessage(error, 'Hidden'));
29362938
}
2937-
}, 450);
2939+
}, 600);
29382940
}
29392941

29402942
// we already have a updater in running, now delay it

src/Platform.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ export function DeleteAllChildren(dir: File): string {
230230
}
231231

232232
const __find_cache: Map<string, string> = new Map();
233+
/**
234+
* @brief Find a exe path in System Path,
235+
* - if found, return a path with string type.
236+
* - if not found, return 'undefined'
237+
*/
233238
export function find(fileName: string, refreshCache?: boolean): string | undefined {
234239

235240
if (refreshCache)

src/ResManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export class ResManager extends events.EventEmitter {
276276
const pList = process.env['Path'].split(File.delimiter);
277277
for (const path of pList) {
278278
if (/WindowsPowerShell/.test(path)) {
279-
if (path && fs.existsSync(path) && fs.lstatSync(path).isDirectory) {
279+
if (path && File.IsDir(path)) {
280280
const res = path.replace(/\\*\s*$/, '');
281281
const psList = new File(res).GetList([/powershell\.exe/i], File.EXCLUDE_ALL_FILTER);
282282
if (psList.length > 0 && psList[0].IsFile()) {

src/SettingManager.ts

Lines changed: 79 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class SettingManager {
146146
this.getConfiguration().update(key, val, vscode.ConfigurationTarget.Global);
147147
}
148148

149-
private toFullPathForSettings(path_: string): string {
149+
private _formatPathForPluginSettings(path_: string): string {
150150

151151
const wsRoot = WorkspaceManager.getInstance().getWorkspaceRoot();
152152

@@ -189,59 +189,61 @@ export class SettingManager {
189189

190190
//------------------------- env and path --------------------------
191191

192-
private getExePathFromConfig(confName: string, execName: string): string | undefined {
193-
194-
let defPath: string | undefined;
195-
196-
const path = this.getConfiguration().get<string>(confName);
192+
private getFullPathByPluginConfig(configName: string): string | undefined {
193+
const path = this.getConfiguration().get<string>(configName);
197194
if (path) {
198-
defPath = Utility.formatPath(this.toFullPathForSettings(path));
199-
if (File.IsExist(defPath)) {
200-
return defPath;
195+
const p = Utility.formatPath(this._formatPathForPluginSettings(path));
196+
if (File.IsExist(p)) {
197+
return p;
201198
}
202199
}
200+
}
203201

204-
if (this.envPathCache.has(execName)) {
205-
return <string>this.envPathCache.get(execName);
202+
private findExePathInSystemEnv(exeName: string): string | undefined {
203+
204+
if (this.envPathCache.has(exeName)) {
205+
return <string>this.envPathCache.get(exeName);
206206
}
207207

208208
else {
209-
const absPath = find(execName);
209+
const absPath = find(exeName);
210210
if (absPath) {
211-
this.envPathCache.set(execName, absPath);
211+
this.envPathCache.set(exeName, absPath);
212212
return absPath;
213213
}
214214
}
215-
216-
return defPath;
217215
}
218216

219-
private getGccFolderFromConfig(confName: string, execName: string): string | undefined {
217+
private findExeDirInSystemEnv(exeName: string): string | undefined {
220218

221-
let defPath: string | undefined;
219+
if (this.envPathCache.has(exeName)) {
220+
return <string>this.envPathCache.get(exeName);
221+
}
222222

223-
const path = this.getConfiguration().get<string>(confName);
224-
if (path) {
225-
defPath = Utility.formatPath(this.toFullPathForSettings(path));
226-
if (File.IsExist(defPath)) {
227-
return defPath;
223+
else {
224+
const absPath = find(exeName);
225+
if (absPath) {
226+
const dirpath = NodePath.dirname(absPath);
227+
this.envPathCache.set(exeName, dirpath);
228+
return dirpath;
228229
}
229230
}
231+
}
230232

231-
if (this.envPathCache.has(execName)) {
232-
return <string>this.envPathCache.get(execName);
233+
private findGccCompilerRootInSystemEnv(gccName: string): string | undefined {
234+
235+
if (this.envPathCache.has(gccName)) {
236+
return <string>this.envPathCache.get(gccName);
233237
}
234238

235239
else {
236-
const absPath = find(execName);
240+
const absPath = find(gccName);
237241
if (absPath) {
238242
const dirName = NodePath.dirname(NodePath.dirname(absPath));
239-
this.envPathCache.set(execName, dirName);
243+
this.envPathCache.set(gccName, dirName);
240244
return dirName;
241245
}
242246
}
243-
244-
return defPath;
245247
}
246248

247249
//-------------------------- Serialport --------------------------------
@@ -350,74 +352,44 @@ export class SettingManager {
350352
}
351353

352354
getCppcheckerExe(): string | undefined {
353-
return this.getExePathFromConfig('Cppcheck.ExecutablePath', 'cppcheck');
355+
return this.getFullPathByPluginConfig('Cppcheck.ExecutablePath')
356+
|| this.findExePathInSystemEnv('cppcheck');
354357
}
355358

356359
//----------------------------- Flasher --------------------------------
357360

358361
getJlinkDir(): string {
359-
360-
let defPath: string | undefined;
361-
362-
const path = this.getConfiguration().get<string>('JLink.InstallDirectory');
363-
if (path) {
364-
defPath = Utility.formatPath(this.toFullPathForSettings(path));
365-
if (File.IsExist(defPath)) {
366-
return defPath;
367-
}
368-
}
369-
370-
const execName = 'JLink';
371-
372-
if (this.envPathCache.has(execName)) {
373-
return <string>this.envPathCache.get(execName)
374-
}
375-
376-
else {
377-
const absPath = find(execName);
378-
if (absPath) {
379-
const dirName = NodePath.dirname(absPath);
380-
this.envPathCache.set(execName, dirName);
381-
return dirName;
382-
}
383-
}
384-
385-
return defPath || 'null';
362+
return this.getFullPathByPluginConfig('JLink.InstallDirectory')
363+
|| this.findExeDirInSystemEnv('JLink')
364+
|| 'null';
386365
}
387366

388367
getStvpExePath(): string {
389-
return this.toFullPathForSettings(
390-
this.getExePathFromConfig('STM8.STVP.CliExePath', 'STVP_CmdLine') || 'null'
391-
);
368+
return this.getFullPathByPluginConfig('STM8.STVP.CliExePath')
369+
|| this.findExePathInSystemEnv('STVP_CmdLine')
370+
|| 'null';
392371
}
393372

394373
getSTLinkExePath(): string {
395-
396-
const flasher =
397-
this.getExePathFromConfig('STLink.ExePath', 'STM32_Programmer_CLI') ||
398-
this.getExePathFromConfig('STLink.ExePath', 'ST-LINK_CLI');
399-
400-
return this.toFullPathForSettings(flasher || 'null');
374+
return this.getFullPathByPluginConfig('STLink.ExePath')
375+
|| this.findExePathInSystemEnv('STM32_Programmer_CLI')
376+
|| this.findExePathInSystemEnv('ST-LINK_CLI')
377+
|| 'null';
401378
}
402379

403380
getOpenOCDExePath(): string {
404-
return this.toFullPathForSettings(
405-
this.getExePathFromConfig('OpenOCD.ExePath', 'openocd') || 'null'
406-
);
381+
return this.getFullPathByPluginConfig('OpenOCD.ExePath')
382+
|| this.findExePathInSystemEnv('openocd')
383+
|| 'null';
407384
}
408385

409386
//-----------------------------IAR-------------------------------
410387

411388
getIARForStm8Dir(): File {
412389

413-
let defPath: string | undefined;
414-
415-
const path = this.getConfiguration().get<string>('IAR.STM8.InstallDirectory');
416-
if (path) {
417-
defPath = Utility.formatPath(this.toFullPathForSettings(path));
418-
if (File.IsExist(defPath)) {
419-
return new File(defPath);
420-
}
390+
const p = this.getFullPathByPluginConfig('IAR.STM8.InstallDirectory');
391+
if (p) {
392+
return new File(p);
421393
}
422394

423395
const execName = 'iccstm8';
@@ -435,11 +407,15 @@ export class SettingManager {
435407
}
436408
}
437409

438-
return new File(defPath || 'null');
410+
return new File('null');
439411
}
440412

441413
getIarForArmDir(): File {
442-
return new File(this.getGccFolderFromConfig('IAR.ARM.Toolchain.InstallDirectory', 'iccarm') || 'null');
414+
return new File(
415+
this.getFullPathByPluginConfig('IAR.ARM.Toolchain.InstallDirectory') ||
416+
this.findGccCompilerRootInSystemEnv('iccarm') ||
417+
'null'
418+
);
443419
}
444420

445421
//---------------------------- ARM ----------------------------
@@ -467,24 +443,29 @@ export class SettingManager {
467443
}
468444

469445
getGCCDir(): File {
470-
const execName = `${this.getGCCPrefix()}gcc`;
471-
return new File(this.getGccFolderFromConfig('ARM.GCC.InstallDirectory', execName) || 'null');
446+
return new File(
447+
this.getFullPathByPluginConfig('ARM.GCC.InstallDirectory') ||
448+
this.findGccCompilerRootInSystemEnv(`${this.getGCCPrefix()}gcc`) ||
449+
'null'
450+
);
472451
}
473452

474453
// ---
475454

476455
getArmcc5Dir(): File {
477456
return new File(
478-
this.getGccFolderFromConfig('ARM.ARMCC5.InstallDirectory', 'armcc') ||
457+
this.getFullPathByPluginConfig('ARM.ARMCC5.InstallDirectory') ||
479458
this.pathCache.get('ARMCC5') ||
459+
this.findGccCompilerRootInSystemEnv('armcc') ||
480460
'null'
481461
);
482462
}
483463

484464
getArmcc6Dir(): File {
485465
return new File(
486-
this.getGccFolderFromConfig('ARM.ARMCC6.InstallDirectory', 'armclang') ||
466+
this.getFullPathByPluginConfig('ARM.ARMCC6.InstallDirectory') ||
487467
this.pathCache.get('ARMCC6') ||
468+
this.findGccCompilerRootInSystemEnv('armclang') ||
488469
'null'
489470
);
490471
}
@@ -584,18 +565,25 @@ export class SettingManager {
584565
//------------------------------- SDCC --------------------------------
585566

586567
getSdccDir(): File {
587-
return new File(this.getGccFolderFromConfig('SDCC.InstallDirectory', 'sdcc') || 'null');
568+
return new File(
569+
this.getFullPathByPluginConfig('SDCC.InstallDirectory') ||
570+
this.findGccCompilerRootInSystemEnv('sdcc') ||
571+
'null'
572+
);
588573
}
589574

590575
getGnuSdccStm8Dir(): File {
591-
return new File(this.getGccFolderFromConfig('STM8.GNU-SDCC.InstallDirectory', 'stm8-as') || 'null');
576+
return new File('null'); // disabled
592577
}
593578

594579
//------------------------------- RISC-V ----------------------------------
595580

596581
getRiscvToolFolder(): File {
597-
const execName = `${this.getRiscvToolPrefix()}gcc`;
598-
return new File(this.getGccFolderFromConfig('RISCV.InstallDirectory', execName) || 'null');
582+
return new File(
583+
this.getFullPathByPluginConfig('RISCV.InstallDirectory') ||
584+
this.findGccCompilerRootInSystemEnv(`${this.getRiscvToolPrefix()}gcc`) ||
585+
'null'
586+
);
599587
}
600588

601589
getRiscvToolPrefix(): string {
@@ -605,8 +593,11 @@ export class SettingManager {
605593
//------------------------------- Any GCC ----------------------------------
606594

607595
getAnyGccToolFolder(): File {
608-
const execName = `${this.getAnyGccToolPrefix()}gcc`;
609-
return new File(this.getGccFolderFromConfig('Toolchain.AnyGcc.InstallDirectory', execName) || 'null');
596+
return new File(
597+
this.getFullPathByPluginConfig('Toolchain.AnyGcc.InstallDirectory') ||
598+
this.findGccCompilerRootInSystemEnv(`${this.getAnyGccToolPrefix()}gcc`) ||
599+
'null'
600+
);
610601
}
611602

612603
getAnyGccToolPrefix(): string {

src/StringTable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ export const view_str$operation$setMDKPath = [
756756
][langIndex];
757757

758758
export const view_str$operation$setToolchainInstallDir = [
759-
'设置 ${name} 的安装目录路径',
760-
'Set ${name} installation folder path'
759+
'设置 ${name} 的安装目录路径(编译器根目录)',
760+
'Set ${name} installation folder path (compiler root directory)'
761761
][langIndex];
762762

763763
export const from_disk_desp = [

0 commit comments

Comments
 (0)