Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ All notable version changes will be recorded in this file.

***

### [v3.10.5] revision

**Fix**:
- `Symbol Link`: Not work for symbol link source folder.

**Optimize**:
- `High Cpu Load`: Optimize code, reduce `find in system path` operations

***

### [v3.10.4] revision

**Fix**:
Expand Down
2 changes: 1 addition & 1 deletion lib/node-utility
Submodule node-utility updated 1 files
+19 −19 File.ts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"homepage": "https://em-ide.com",
"license": "MIT",
"description": "A mcu development environment for 8051/AVR/STM8/Cortex-M/RISC-V",
"version": "3.10.4",
"version": "3.10.5",
"preview": false,
"engines": {
"vscode": "^1.63.0"
Expand Down
8 changes: 5 additions & 3 deletions src/EIDEProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,8 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
const toolManager = ToolchainManager.getInstance();

this.toolchain = toolManager.getToolchain(prjConfig.config.type, prjConfig.config.toolchain);
this.registerBuiltinVar('ToolchainRoot', () => this.getToolchain().getToolchainDir().path);
let toolchainRoot = this.toolchain.getToolchainDir().path;
this.registerBuiltinVar('ToolchainRoot', () => toolchainRoot);

const opFile = prjConfig.compileConfigModel.getOptionsFile(this.getEideDir().path, prjConfig.config);
toolManager.updateToolchainConfig(opFile, this.toolchain);
Expand Down Expand Up @@ -2764,7 +2765,8 @@ class EIDEProject extends AbstractProject {
"hars.cppsnippets",
"zixuanwang.linkerscript",
"redhat.vscode-yaml",
"IBM.output-colorizer"
"IBM.output-colorizer",
"cschlosser.doxdocgen"
];

const prjInfo = this.GetConfiguration().config;
Expand Down Expand Up @@ -2934,7 +2936,7 @@ class EIDEProject extends AbstractProject {
} catch (error) {
GlobalEvent.emit('msg', ExceptionToMessage(error, 'Hidden'));
}
}, 450);
}, 600);
}

// we already have a updater in running, now delay it
Expand Down
5 changes: 5 additions & 0 deletions src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ export function DeleteAllChildren(dir: File): string {
}

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

if (refreshCache)
Expand Down
2 changes: 1 addition & 1 deletion src/ResManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class ResManager extends events.EventEmitter {
const pList = process.env['Path'].split(File.delimiter);
for (const path of pList) {
if (/WindowsPowerShell/.test(path)) {
if (path && fs.existsSync(path) && fs.lstatSync(path).isDirectory) {
if (path && File.IsDir(path)) {
const res = path.replace(/\\*\s*$/, '');
const psList = new File(res).GetList([/powershell\.exe/i], File.EXCLUDE_ALL_FILTER);
if (psList.length > 0 && psList[0].IsFile()) {
Expand Down
167 changes: 79 additions & 88 deletions src/SettingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class SettingManager {
this.getConfiguration().update(key, val, vscode.ConfigurationTarget.Global);
}

private toFullPathForSettings(path_: string): string {
private _formatPathForPluginSettings(path_: string): string {

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

Expand Down Expand Up @@ -189,59 +189,61 @@ export class SettingManager {

//------------------------- env and path --------------------------

private getExePathFromConfig(confName: string, execName: string): string | undefined {

let defPath: string | undefined;

const path = this.getConfiguration().get<string>(confName);
private getFullPathByPluginConfig(configName: string): string | undefined {
const path = this.getConfiguration().get<string>(configName);
if (path) {
defPath = Utility.formatPath(this.toFullPathForSettings(path));
if (File.IsExist(defPath)) {
return defPath;
const p = Utility.formatPath(this._formatPathForPluginSettings(path));
if (File.IsExist(p)) {
return p;
}
}
}

if (this.envPathCache.has(execName)) {
return <string>this.envPathCache.get(execName);
private findExePathInSystemEnv(exeName: string): string | undefined {

if (this.envPathCache.has(exeName)) {
return <string>this.envPathCache.get(exeName);
}

else {
const absPath = find(execName);
const absPath = find(exeName);
if (absPath) {
this.envPathCache.set(execName, absPath);
this.envPathCache.set(exeName, absPath);
return absPath;
}
}

return defPath;
}

private getGccFolderFromConfig(confName: string, execName: string): string | undefined {
private findExeDirInSystemEnv(exeName: string): string | undefined {

let defPath: string | undefined;
if (this.envPathCache.has(exeName)) {
return <string>this.envPathCache.get(exeName);
}

const path = this.getConfiguration().get<string>(confName);
if (path) {
defPath = Utility.formatPath(this.toFullPathForSettings(path));
if (File.IsExist(defPath)) {
return defPath;
else {
const absPath = find(exeName);
if (absPath) {
const dirpath = NodePath.dirname(absPath);
this.envPathCache.set(exeName, dirpath);
return dirpath;
}
}
}

if (this.envPathCache.has(execName)) {
return <string>this.envPathCache.get(execName);
private findGccCompilerRootInSystemEnv(gccName: string): string | undefined {

if (this.envPathCache.has(gccName)) {
return <string>this.envPathCache.get(gccName);
}

else {
const absPath = find(execName);
const absPath = find(gccName);
if (absPath) {
const dirName = NodePath.dirname(NodePath.dirname(absPath));
this.envPathCache.set(execName, dirName);
this.envPathCache.set(gccName, dirName);
return dirName;
}
}

return defPath;
}

//-------------------------- Serialport --------------------------------
Expand Down Expand Up @@ -350,74 +352,44 @@ export class SettingManager {
}

getCppcheckerExe(): string | undefined {
return this.getExePathFromConfig('Cppcheck.ExecutablePath', 'cppcheck');
return this.getFullPathByPluginConfig('Cppcheck.ExecutablePath')
|| this.findExePathInSystemEnv('cppcheck');
}

//----------------------------- Flasher --------------------------------

getJlinkDir(): string {

let defPath: string | undefined;

const path = this.getConfiguration().get<string>('JLink.InstallDirectory');
if (path) {
defPath = Utility.formatPath(this.toFullPathForSettings(path));
if (File.IsExist(defPath)) {
return defPath;
}
}

const execName = 'JLink';

if (this.envPathCache.has(execName)) {
return <string>this.envPathCache.get(execName)
}

else {
const absPath = find(execName);
if (absPath) {
const dirName = NodePath.dirname(absPath);
this.envPathCache.set(execName, dirName);
return dirName;
}
}

return defPath || 'null';
return this.getFullPathByPluginConfig('JLink.InstallDirectory')
|| this.findExeDirInSystemEnv('JLink')
|| 'null';
}

getStvpExePath(): string {
return this.toFullPathForSettings(
this.getExePathFromConfig('STM8.STVP.CliExePath', 'STVP_CmdLine') || 'null'
);
return this.getFullPathByPluginConfig('STM8.STVP.CliExePath')
|| this.findExePathInSystemEnv('STVP_CmdLine')
|| 'null';
}

getSTLinkExePath(): string {

const flasher =
this.getExePathFromConfig('STLink.ExePath', 'STM32_Programmer_CLI') ||
this.getExePathFromConfig('STLink.ExePath', 'ST-LINK_CLI');

return this.toFullPathForSettings(flasher || 'null');
return this.getFullPathByPluginConfig('STLink.ExePath')
|| this.findExePathInSystemEnv('STM32_Programmer_CLI')
|| this.findExePathInSystemEnv('ST-LINK_CLI')
|| 'null';
}

getOpenOCDExePath(): string {
return this.toFullPathForSettings(
this.getExePathFromConfig('OpenOCD.ExePath', 'openocd') || 'null'
);
return this.getFullPathByPluginConfig('OpenOCD.ExePath')
|| this.findExePathInSystemEnv('openocd')
|| 'null';
}

//-----------------------------IAR-------------------------------

getIARForStm8Dir(): File {

let defPath: string | undefined;

const path = this.getConfiguration().get<string>('IAR.STM8.InstallDirectory');
if (path) {
defPath = Utility.formatPath(this.toFullPathForSettings(path));
if (File.IsExist(defPath)) {
return new File(defPath);
}
const p = this.getFullPathByPluginConfig('IAR.STM8.InstallDirectory');
if (p) {
return new File(p);
}

const execName = 'iccstm8';
Expand All @@ -435,11 +407,15 @@ export class SettingManager {
}
}

return new File(defPath || 'null');
return new File('null');
}

getIarForArmDir(): File {
return new File(this.getGccFolderFromConfig('IAR.ARM.Toolchain.InstallDirectory', 'iccarm') || 'null');
return new File(
this.getFullPathByPluginConfig('IAR.ARM.Toolchain.InstallDirectory') ||
this.findGccCompilerRootInSystemEnv('iccarm') ||
'null'
);
}

//---------------------------- ARM ----------------------------
Expand Down Expand Up @@ -467,24 +443,29 @@ export class SettingManager {
}

getGCCDir(): File {
const execName = `${this.getGCCPrefix()}gcc`;
return new File(this.getGccFolderFromConfig('ARM.GCC.InstallDirectory', execName) || 'null');
return new File(
this.getFullPathByPluginConfig('ARM.GCC.InstallDirectory') ||
this.findGccCompilerRootInSystemEnv(`${this.getGCCPrefix()}gcc`) ||
'null'
);
}

// ---

getArmcc5Dir(): File {
return new File(
this.getGccFolderFromConfig('ARM.ARMCC5.InstallDirectory', 'armcc') ||
this.getFullPathByPluginConfig('ARM.ARMCC5.InstallDirectory') ||
this.pathCache.get('ARMCC5') ||
this.findGccCompilerRootInSystemEnv('armcc') ||
'null'
);
}

getArmcc6Dir(): File {
return new File(
this.getGccFolderFromConfig('ARM.ARMCC6.InstallDirectory', 'armclang') ||
this.getFullPathByPluginConfig('ARM.ARMCC6.InstallDirectory') ||
this.pathCache.get('ARMCC6') ||
this.findGccCompilerRootInSystemEnv('armclang') ||
'null'
);
}
Expand Down Expand Up @@ -584,18 +565,25 @@ export class SettingManager {
//------------------------------- SDCC --------------------------------

getSdccDir(): File {
return new File(this.getGccFolderFromConfig('SDCC.InstallDirectory', 'sdcc') || 'null');
return new File(
this.getFullPathByPluginConfig('SDCC.InstallDirectory') ||
this.findGccCompilerRootInSystemEnv('sdcc') ||
'null'
);
}

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

//------------------------------- RISC-V ----------------------------------

getRiscvToolFolder(): File {
const execName = `${this.getRiscvToolPrefix()}gcc`;
return new File(this.getGccFolderFromConfig('RISCV.InstallDirectory', execName) || 'null');
return new File(
this.getFullPathByPluginConfig('RISCV.InstallDirectory') ||
this.findGccCompilerRootInSystemEnv(`${this.getRiscvToolPrefix()}gcc`) ||
'null'
);
}

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

getAnyGccToolFolder(): File {
const execName = `${this.getAnyGccToolPrefix()}gcc`;
return new File(this.getGccFolderFromConfig('Toolchain.AnyGcc.InstallDirectory', execName) || 'null');
return new File(
this.getFullPathByPluginConfig('Toolchain.AnyGcc.InstallDirectory') ||
this.findGccCompilerRootInSystemEnv(`${this.getAnyGccToolPrefix()}gcc`) ||
'null'
);
}

getAnyGccToolPrefix(): string {
Expand Down
4 changes: 2 additions & 2 deletions src/StringTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,8 @@ export const view_str$operation$setMDKPath = [
][langIndex];

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

export const from_disk_desp = [
Expand Down