diff --git a/CHANGELOG.md b/CHANGELOG.md index 13004657..7a7f2a33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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**: diff --git a/lib/node-utility b/lib/node-utility index ee96d3c3..f8e6833e 160000 --- a/lib/node-utility +++ b/lib/node-utility @@ -1 +1 @@ -Subproject commit ee96d3c31b2f4d42b42abf08cd2e74e2276c08b8 +Subproject commit f8e6833e59d8fb8e97eb8ff710292e8ac86dd323 diff --git a/package.json b/package.json index ae41cdef..3da0d6a0 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/EIDEProject.ts b/src/EIDEProject.ts index bd1fa6e8..3e48a813 100644 --- a/src/EIDEProject.ts +++ b/src/EIDEProject.ts @@ -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); @@ -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; @@ -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 diff --git a/src/Platform.ts b/src/Platform.ts index efa24dec..18dc7bd5 100644 --- a/src/Platform.ts +++ b/src/Platform.ts @@ -230,6 +230,11 @@ export function DeleteAllChildren(dir: File): string { } const __find_cache: Map = 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) diff --git a/src/ResManager.ts b/src/ResManager.ts index 66815201..46001a1a 100644 --- a/src/ResManager.ts +++ b/src/ResManager.ts @@ -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()) { diff --git a/src/SettingManager.ts b/src/SettingManager.ts index 1df4dab7..5400a98e 100644 --- a/src/SettingManager.ts +++ b/src/SettingManager.ts @@ -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(); @@ -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(confName); + private getFullPathByPluginConfig(configName: string): string | undefined { + const path = this.getConfiguration().get(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 this.envPathCache.get(execName); + private findExePathInSystemEnv(exeName: string): string | undefined { + + if (this.envPathCache.has(exeName)) { + return 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 this.envPathCache.get(exeName); + } - const path = this.getConfiguration().get(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 this.envPathCache.get(execName); + private findGccCompilerRootInSystemEnv(gccName: string): string | undefined { + + if (this.envPathCache.has(gccName)) { + return 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 -------------------------------- @@ -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('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 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('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'; @@ -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 ---------------------------- @@ -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' ); } @@ -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 { @@ -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 { diff --git a/src/StringTable.ts b/src/StringTable.ts index af9cbaab..c266d2c9 100644 --- a/src/StringTable.ts +++ b/src/StringTable.ts @@ -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 = [