diff --git a/CHANGELOG.md b/CHANGELOG.md index b05a21a..9780bbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ All notable version changes will be recorded in this file. *** +### [v3.25.5] revision + +**Fix**: + - `Flasher`: fix flasher crashed when enumSerialPort failed. + - `Setup Toolchain`: fix performace issue for OnSetToolchainPath(). update toolchain descriptions. + - `sdcc+binutils Toolchain`: fix "fatal error: cannot execute 'cc1'" for Win32 platform. + +*** + ### [v3.25.3] revision **Improve**: diff --git a/package.json b/package.json index 397c048..c7f3f6e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "homepage": "https://em-ide.com", "license": "MIT", "description": "A mcu development environment for 8051/AVR/STM8/Cortex-M/MIPS/RISC-V", - "version": "3.25.3", + "version": "3.25.5", "preview": false, "engines": { "vscode": "^1.67.0" diff --git a/src/CodeBuilder.ts b/src/CodeBuilder.ts index 67c799a..c764ea7 100644 --- a/src/CodeBuilder.ts +++ b/src/CodeBuilder.ts @@ -470,6 +470,12 @@ export abstract class CodeBuilder { getOutDir: () => { return this.project.ToAbsolutePath(outDir); } }, builderOptions.options); + // add extra system search path + if (toolchain.exportSystemSearchPath) { + toolchain.exportSystemSearchPath(builderOptions.options) + .forEach(p => builderOptions.sysPaths?.push(p)); + } + // handle options this.preHandleOptions(builderOptions.options); diff --git a/src/HexUploader.ts b/src/HexUploader.ts index 327df38..bf6797a 100644 --- a/src/HexUploader.ts +++ b/src/HexUploader.ts @@ -257,12 +257,21 @@ export abstract class HexUploader { resolveHexFilePathEnvs(input: string, programs: FlashProgramFile[]): string { - const portList = ResManager.GetInstance().enumSerialPort(); + let portList: string[] = []; + try { + portList = ResManager.GetInstance().enumSerialPort(); + } catch (error) { + GlobalEvent.log_error(error); + } let commandLine = input .replace(/\$\{hexFile\}|\$\{binFile\}|\$\{programFile\}/ig, programs[0].path) .replace(/\$\{port\}/ig, portList[0] || '') - .replace(/\$\{portList\}/ig, portList.join(' ')); + .replace(/\$\{portList\}/ig, portList.join(' ')) + .replace('${port[0]}', portList[0] || '') + .replace('${port[1]}', portList[1] || '') + .replace('${port[2]}', portList[2] || '') + .replace('${port[3]}', portList[3] || ''); programs.forEach((file, index) => { diff --git a/src/OperationExplorer.ts b/src/OperationExplorer.ts index d47712e..e999267 100644 --- a/src/OperationExplorer.ts +++ b/src/OperationExplorer.ts @@ -415,7 +415,7 @@ export class OperationExplorer { const itemList: ProjectTemplatePickItem[] = [ { label: '8051 Quick Start (SDCC)', - detail: 'Universal 8051 example project with SDCC', + detail: 'Generic 8051 example project with SDCC', templateName: 'mcs51_sdcc', type: 'C51' }, @@ -692,6 +692,14 @@ export class OperationExplorer { const toolchainManager = ToolchainManager.getInstance(); const resManager = ResManager.GetInstance(); + const makeToolchainDespTxt = (id: ToolchainName): string => { + const dir = toolchainManager.getToolchainExecutableFolder(id); + if (dir && dir.IsDir()) + return this.getStatusTxt(true) + ` Loc: ${dir.path}`; + else + return this.getStatusTxt(false) + ` Loc: ${dir?.path || ''}` + }; + const toolchainPickItems: ToolchainDespPickItem[] = [ { type: 'None', @@ -701,37 +709,32 @@ export class OperationExplorer { { label: 'Keil C51 (cx51) (ide path)', type: 'Keil_C51', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('Keil_C51')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('Keil_C51')?.path}`, + description: makeToolchainDespTxt('Keil_C51'), detail: view_str$operation$setKeil51Path }, { label: 'IAR For STM8 (iccstm8) (ide path)', type: 'IAR_STM8', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('IAR_STM8')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('IAR_STM8')?.path}`, + description: makeToolchainDespTxt('IAR_STM8'), detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'IAR For STM8') }, { label: 'SDCC (sdcc)', type: 'SDCC', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('SDCC')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('SDCC')?.path}`, + description: makeToolchainDespTxt('SDCC'), detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'SDCC') }, { label: 'SDCC + Binutils For 8051 (sdcc + i51-elf-as)', type: 'GNU_SDCC_MCS51', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('GNU_SDCC_MCS51')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('GNU_SDCC_MCS51')?.path}`, + description: makeToolchainDespTxt('GNU_SDCC_MCS51'), detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'SDCC + Binutils For 8051') }, { label: 'COSMIC STM8 C Compiler (cxstm8)', type: 'COSMIC_STM8', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('COSMIC_STM8')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('COSMIC_STM8')?.path}`, - detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'COSMIC_STM8'), + description: makeToolchainDespTxt('COSMIC_STM8'), + detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'COSMIC STM8'), buttons: [ { iconPath: vscode.Uri.file(resManager.GetIconByName('Login_16x.svg').path), @@ -761,22 +764,19 @@ export class OperationExplorer { { label: 'ARMCC V5 (armcc) (standalone toolchain)', type: 'AC5', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('AC5')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('AC5')?.path}`, - detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'ARMCC V5 Toolchain') + description: makeToolchainDespTxt('AC5'), + detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'ARMCC V5') }, { label: 'ARMCC V6 (armclang) (standalone toolchain)', type: 'AC6', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('AC6')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('AC6')?.path}`, - detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'ARMCC V6 Toolchain') + description: makeToolchainDespTxt('AC6'), + detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'ARMCC V6') }, { label: 'IAR ARM C/C++ Compiler (iccarm) (standalone toolchain)', type: 'IAR_ARM', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('IAR_ARM')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('IAR_ARM')?.path}`, + description: makeToolchainDespTxt('IAR_ARM'), detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'IAR ARM C/C++ Compiler') }, @@ -789,8 +789,7 @@ export class OperationExplorer { { label: `GNU Arm Embedded Toolchain (${toolchainManager.getToolchainPrefix('GCC')}gcc)`, type: 'GCC', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('GCC')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('GCC')?.path}`, + description: makeToolchainDespTxt('GCC'), detail: view_str$operation$setToolchainInstallDir.replace('${name}', `GNU Arm Embedded Toolchain`), buttons: [ { @@ -802,8 +801,7 @@ export class OperationExplorer { { label: `RISC-V GCC Toolchain (${toolchainManager.getToolchainPrefix('RISCV_GCC')}gcc)`, type: 'RISCV_GCC', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('RISCV_GCC')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('RISCV_GCC')?.path}`, + description: makeToolchainDespTxt('RISCV_GCC'), detail: view_str$operation$setToolchainInstallDir.replace('${name}', `RISC-V GCC Toolchain`), buttons: [ { @@ -815,16 +813,14 @@ export class OperationExplorer { { label: 'MIPS MTI GCC Compiler', type: 'MTI_GCC', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('MTI_GCC')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('MTI_GCC')?.path}`, + description: makeToolchainDespTxt('MTI_GCC'), detail: view_str$operation$setToolchainInstallDir.replace('${name}', 'MTI_GCC'), }, { - label: `Universal GCC Toolchain (${toolchainManager.getToolchainPrefix('ANY_GCC')}gcc)`, + label: `Generic GCC Toolchain (${toolchainManager.getToolchainPrefix('ANY_GCC')}gcc)`, type: 'ANY_GCC', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('ANY_GCC')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('ANY_GCC')?.path}`, - detail: view_str$operation$setToolchainInstallDir.replace('${name}', `ANY GCC Toolchain`), + description: makeToolchainDespTxt('ANY_GCC'), + detail: view_str$operation$setToolchainInstallDir.replace('${name}', `Generic GCC Toolchain`), buttons: [ { iconPath: vscode.Uri.file(resManager.GetIconByName('EditTitleString_16x.svg').path), @@ -842,8 +838,7 @@ export class OperationExplorer { { label: `LLVM Embedded Toolchain For Arm (clang)`, type: 'LLVM_ARM', - description: this.getStatusTxt(toolchainManager.isToolchainPathReady('LLVM_ARM')) - + ` Loc: ${toolchainManager.getToolchainExecutableFolder('LLVM_ARM')?.path}`, + description: makeToolchainDespTxt('LLVM_ARM'), detail: view_str$operation$setToolchainInstallDir.replace('${name}', `LLVM Embedded Toolchain For Arm`) } ]; diff --git a/src/StringTable.ts b/src/StringTable.ts index 0dea650..66e1c35 100644 --- a/src/StringTable.ts +++ b/src/StringTable.ts @@ -895,7 +895,7 @@ export const view_str$operation$empty_mips_prj = [ export const view_str$operation$empty_anygcc_prj = [ '通用的 GCC 项目', - 'Universal GCC Project' + 'Generic GCC Project' ][langIndex]; export const view_str$operation$open_serialport = [ diff --git a/src/ToolchainManager.ts b/src/ToolchainManager.ts index eed8b19..d9cf203 100644 --- a/src/ToolchainManager.ts +++ b/src/ToolchainManager.ts @@ -162,6 +162,11 @@ export interface IToolchian { */ migrateOptions?: (oldOptions: BuilderOptions) => void; + /** + * 导出额外的系统搜索路径(如果有的话) + */ + exportSystemSearchPath?: (builderOptions: BuilderOptions) => string[]; + newInstance(): IToolchian; } @@ -319,7 +324,7 @@ export class ToolchainManager { case 'RISCV_GCC': return 'GNU RISC-V Toolchain'; case 'ANY_GCC': - return 'GNU Toolchain'; + return 'Generic GNU Toolchain'; case 'COSMIC_STM8': return 'COSMIC STM8 C Compiler'; case 'MTI_GCC': @@ -1214,6 +1219,14 @@ class GNU_SDCC_MCS51 implements IToolchian { } } + exportSystemSearchPath(builderOptions: BuilderOptions): string[] { + const r: string[] = []; + // to fix: sdcpp.exe: fatal error: cannot execute 'cc1': CreateProcess: No such file or directory + if (platform.osType() == 'win32') + r.push(File.ToLocalPath(NodePath.join(this.getToolchainDir().path, 'libexec', 'sdcc', 'x86_64-w64-mingw32', '12.1.0'))); + return r; + } + getInternalDefines(builderCfg: T, builderOpts: BuilderOptions): utility.CppMacroDefine[] { const mList: utility.CppMacroDefine[] = [ diff --git a/src/extension.ts b/src/extension.ts index 5af2fbb..58fc7ac 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2078,6 +2078,12 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider { m = /(?:-USB|-SelectEmuBySN) ([^\s]+)/.exec(flasherCfg.otherCmds); if (m && m.length > 1) dbgCfg['serialNumber'] = m[1]; + // -JLinkScriptFile + m = /-JLinkScriptFile ([^\s"]+|"[^"]+")/.exec(flasherCfg.otherCmds); + if (m && m.length > 1) + dbgCfg['jlinkscript'] = m[1].startsWith('"') + ? m[1].substring(1, m[1].length - 1) + : m[1]; } result.push(dbgCfg); result.push(newAttachDebugCfg(dbgCfg));