Skip to content

Commit 72342ad

Browse files
authored
Merge pull request #120 from github0null/dev
v3.5.1 update
2 parents 5f62cf9 + ce16e47 commit 72342ad

File tree

8 files changed

+102
-54
lines changed

8 files changed

+102
-54
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
***
66

7+
### [v3.5.1]
8+
9+
**Optimized**:
10+
- Allow use project env vars(like: `${OutDir}, ${ProjectName} ...`) in shell flasher commandline.
11+
- Auto check program files for stvp flasher.
12+
- Optimize external tool executable path parser.
13+
- Optimize some message prompt.
14+
15+
***
16+
717
### [v3.5.0]
818

919
**Fixed**:

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,31 @@
88
"email": "[email protected]"
99
},
1010
"keywords": [
11+
"mcu",
1112
"arm",
12-
"cortex",
1313
"armcc",
14-
"gcc",
14+
"cortex",
1515
"risc-v",
1616
"riscv",
17-
"stm32",
18-
"c51",
1917
"8051",
20-
"avr",
2118
"mcs51",
19+
"c51",
20+
"avr",
2221
"stm8",
22+
"stm32",
23+
"z80",
24+
"pic",
25+
"msp430",
26+
"gcc",
2327
"sdcc",
24-
"eide",
2528
"keil",
26-
"embedded",
27-
"cmsis",
28-
"mcu"
29+
"eide",
30+
"cmsis"
2931
],
3032
"homepage": "https://github.com/github0null/eide/blob/master/README.md",
3133
"license": "MIT",
32-
"description": "An embedded development environment for 8051/AVR/STM8/Cortex-M/RISC-V",
33-
"version": "3.5.0",
34+
"description": "A mcu development environment for 8051/AVR/STM8/Cortex-M/RISC-V",
35+
"version": "3.5.1",
3436
"preview": false,
3537
"engines": {
3638
"vscode": "^1.63.0"

src/EIDEProject.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -977,34 +977,35 @@ export abstract class AbstractProject implements CustomConfigurationProvider {
977977

978978
private replacePathEnv(path: string): string {
979979

980+
// replace stable env
981+
path = this.replaceProjEnv(path);
982+
983+
// replace user env
984+
return this.replaceUserEnv(path, true);
985+
}
986+
987+
// project internal env vars
988+
replaceProjEnv(str: string): string {
989+
980990
const prjConfig = this.GetConfiguration();
981991
const prjRootDir = this.GetRootDir();
982992
const outDir = NodePath.normalize(prjRootDir.path + File.sep + prjConfig.getOutDir());
983993

984-
// replace stable env
985-
path = path
994+
return str
986995
.replace(/\$\(OutDir\)|\$\{OutDir\}/ig, outDir)
987996
.replace(/\$\(ProjectName\)|\$\{ProjectName\}/ig, prjConfig.config.name)
988997
.replace(/\$\(ExecutableName\)|\$\{ExecutableName\}/ig, `${outDir}${File.sep}${prjConfig.config.name}`)
989998
.replace(/\$\(ProjectRoot\)|\$\{ProjectRoot\}/ig, prjRootDir.path);
990-
991-
// replace user env
992-
const prjEnv = this.getProjectEnv();
993-
if (prjEnv) {
994-
for (const key in prjEnv) {
995-
const reg = new RegExp(String.raw`\$\(${key}\)|\$\{${key}\}`, 'ig');
996-
path = path.replace(reg, prjEnv[key]);
997-
}
998-
}
999-
1000-
return path;
1001999
}
10021000

1003-
replaceUserEnv(str: string): string {
1001+
// user defined env vars
1002+
replaceUserEnv(str: string, ignore_case_sensitivity: boolean = false): string {
10041003
const prjEnv = this.getProjectEnv();
10051004
if (prjEnv) {
10061005
for (const key in prjEnv) {
1007-
const reg = new RegExp(String.raw`\$\(${key}\)|\$\{${key}\}`, 'g');
1006+
let flag = 'g';
1007+
if (ignore_case_sensitivity) flag += 'i';
1008+
const reg = new RegExp(String.raw`\$\(${key}\)|\$\{${key}\}`, flag);
10081009
str = str.replace(reg, prjEnv[key]);
10091010
}
10101011
}
@@ -1765,8 +1766,7 @@ export abstract class AbstractProject implements CustomConfigurationProvider {
17651766
const toolchain = this.getToolchain();
17661767
if (!toolchainManager.isToolchainPathReady(toolchain.name)) {
17671768
const dir = toolchainManager.getToolchainExecutableFolder(toolchain.name);
1768-
const msg = view_str$prompt$not_found_compiler.replace('{}', toolchain.name)
1769-
+ `, [path]: ${dir?.path}`;
1769+
const msg = view_str$prompt$not_found_compiler.replace('{}', toolchain.name) + `, [path]: '${dir?.path}'`;
17701770
ResInstaller.instance().setOrInstallTools(toolchain.name, msg, toolchain.settingName);
17711771
return false;
17721772
}

src/EIDEProjectExplorer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3432,7 +3432,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
34323432

34333433
const exeFile = new File(path);
34343434
if (!exeFile.IsFile()) {
3435-
await ResInstaller.instance().setOrInstallTools('cppcheck', `Not found 'cppcheck${exeSuffix()}' ! [path]: ${exeFile.path}`);
3435+
await ResInstaller.instance().setOrInstallTools('cppcheck', `Not found 'cppcheck${exeSuffix()}', [path]: '${exeFile.path}'`);
34363436
return;
34373437
}
34383438

src/HexUploader.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,34 +731,51 @@ class STVPHexUploader extends HexUploader<string[]> {
731731
throw new Error(`no any program files !`);
732732
}
733733

734-
// not verify
735-
commands.push('-no_verif');
734+
let fileCount: number = 0;
736735

736+
// program
737737
const binFile = this.toAbsolute(programs[0].path);
738738
if (binFile.IsFile()) {
739739
commands.push('-FileProg=\"' + binFile.path + '\"');
740+
fileCount++;
740741
} else {
741742
commands.push('-no_progProg');
742743
}
743744

745+
// eeprom
744746
const eepromFile = this.toAbsolute(options.eepromFile);
745747
if (eepromFile.IsFile()) {
746748
commands.push('-FileData=\"' + eepromFile.path + '\"');
749+
fileCount++;
747750
} else {
748751
commands.push('-no_progData');
749752
}
750753

754+
// option bytes
751755
const opFile = this.toAbsolute(options.optionByteFile);
752756
if (opFile.IsFile()) {
753757
commands.push('-FileOption=\"' + opFile.path + '\"');
758+
fileCount++;
754759
} else {
755760
commands.push('-no_progOption');
756761
}
762+
763+
// verify prog
764+
if (fileCount > 0) {
765+
commands.push('-verif');
766+
}
767+
768+
// no files need be programed
769+
else {
770+
throw new Error('no any valid program files !');
771+
}
757772
}
758773

759774
// erase all
760775
else {
776+
commands.push('-no_progProg');
761777
commands.push('-erase');
778+
commands.push('-no_verif');
762779
}
763780

764781
return {
@@ -999,6 +1016,7 @@ class CustomUploader extends HexUploader<string> {
9991016
});
10001017

10011018
// replace env
1019+
commandLine = this.project.replaceProjEnv(commandLine);
10021020
commandLine = this.project.replaceUserEnv(commandLine);
10031021

10041022
return {

src/ResInstaller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import * as fs from 'fs';
2828

2929
import { HexUploaderType } from "./HexUploader";
3030
import { SettingManager } from './SettingManager';
31-
import { txt_install_now, txt_jump2settings } from './StringTable';
31+
import { txt_install_now, txt_jump2settings, view_str$prompt$install_tools_by_online } from './StringTable';
3232
import { ToolchainName } from "./ToolchainManager";
3333
import * as utility from './utility';
3434
import { File } from '../lib/node-utility/File';
@@ -286,7 +286,8 @@ export class ResInstaller {
286286
if (toolInfo.no_binaries) { // if no binaries, we only jump to settings
287287
item = await vscode.window.showWarningMessage(msg, txt_jump2settings);
288288
} else { // if have binaries, user need to do a select.
289-
item = await vscode.window.showWarningMessage(msg, txt_install_now, txt_jump2settings);
289+
item = await vscode.window.showWarningMessage(msg + `, ${view_str$prompt$install_tools_by_online}`,
290+
txt_install_now, txt_jump2settings);
290291
}
291292

292293
if (!item) { return false; } // user canceled, exit

src/SettingManager.ts

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,13 @@ export class SettingManager {
159159

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

162-
const path = this.getConfiguration().get<string>(confName);
162+
let defPath: string | undefined;
163163

164+
const path = this.getConfiguration().get<string>(confName);
164165
if (path) {
165-
const absPath = Utility.formatPath(this.replaceEnvVariable(path));
166-
if (File.IsExist(absPath)) {
167-
return absPath;
166+
defPath = Utility.formatPath(this.replaceEnvVariable(path));
167+
if (File.IsExist(defPath)) {
168+
return defPath;
168169
}
169170
}
170171

@@ -179,16 +180,19 @@ export class SettingManager {
179180
return absPath;
180181
}
181182
}
183+
184+
return defPath;
182185
}
183186

184187
private getGccFolderFromConfig(confName: string, execName: string): string | undefined {
185188

186-
const path = this.getConfiguration().get<string>(confName);
189+
let defPath: string | undefined;
187190

191+
const path = this.getConfiguration().get<string>(confName);
188192
if (path) {
189-
const absPath = Utility.formatPath(this.replaceEnvVariable(path));
190-
if (File.IsExist(absPath)) {
191-
return absPath;
193+
defPath = Utility.formatPath(this.replaceEnvVariable(path));
194+
if (File.IsExist(defPath)) {
195+
return defPath;
192196
}
193197
}
194198

@@ -204,6 +208,8 @@ export class SettingManager {
204208
return dirName;
205209
}
206210
}
211+
212+
return defPath;
207213
}
208214

209215
//-------------------------- Serialport --------------------------------
@@ -311,16 +317,18 @@ export class SettingManager {
311317

312318
getJlinkDir(): string {
313319

314-
const path = this.getConfiguration().get<string>('JLink.InstallDirectory');
315-
const execName = 'JLink';
320+
let defPath: string | undefined;
316321

322+
const path = this.getConfiguration().get<string>('JLink.InstallDirectory');
317323
if (path) {
318-
const absPath = Utility.formatPath(this.replaceEnvVariable(path));
319-
if (File.IsExist(absPath)) {
320-
return absPath;
324+
defPath = Utility.formatPath(this.replaceEnvVariable(path));
325+
if (File.IsExist(defPath)) {
326+
return defPath;
321327
}
322328
}
323329

330+
const execName = 'JLink';
331+
324332
if (this.envPathCache.has(execName)) {
325333
return <string>this.envPathCache.get(execName)
326334
}
@@ -332,8 +340,9 @@ export class SettingManager {
332340
this.envPathCache.set(execName, dirName);
333341
return dirName;
334342
}
335-
return 'null';
336343
}
344+
345+
return defPath || 'null';
337346
}
338347

339348
getJlinkDevXmlFile(): File | undefined {
@@ -371,16 +380,18 @@ export class SettingManager {
371380

372381
getIARForStm8Dir(): File {
373382

374-
const path = this.getConfiguration().get<string>('IAR.STM8.InstallDirectory');
375-
const execName = 'iccstm8';
383+
let defPath: string | undefined;
376384

385+
const path = this.getConfiguration().get<string>('IAR.STM8.InstallDirectory');
377386
if (path) {
378-
const absPath = Utility.formatPath(this.replaceEnvVariable(path));
379-
if (File.IsExist(absPath)) {
380-
return new File(absPath);
387+
defPath = Utility.formatPath(this.replaceEnvVariable(path));
388+
if (File.IsExist(defPath)) {
389+
return new File(defPath);
381390
}
382391
}
383392

393+
const execName = 'iccstm8';
394+
384395
if (this.envPathCache.has(execName)) {
385396
return new File(<string>this.envPathCache.get(execName))
386397
}
@@ -392,8 +403,9 @@ export class SettingManager {
392403
this.envPathCache.set(execName, dirName);
393404
return new File(dirName);
394405
}
395-
return new File('null');
396406
}
407+
408+
return new File(defPath || 'null');
397409
}
398410

399411
//---------------------------- ARM ----------------------------

src/StringTable.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,12 @@ export const view_str$prompt$select_file_or_folder = [
448448

449449
export const view_str$prompt$not_found_compiler = [
450450
`无法找到编译器 '{}' 的安装位置 !`,
451-
`Not found the compiler '{}' installation location !`
451+
`Not found the compiler '{}' location !`
452+
][langIndex];
453+
454+
export const view_str$prompt$install_tools_by_online = [
455+
`已找到在线资源包,需要安装它吗?`,
456+
`The online package was found. Do you want to install it ?`
452457
][langIndex];
453458

454459
export const view_str$placeHolder$selectCategory = [

0 commit comments

Comments
 (0)