Skip to content

Commit a274e0d

Browse files
committed
allow nested env variables
1 parent e4ffcbe commit a274e0d

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/EIDEProject.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,17 +1062,25 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
10621062
return this.configMap;
10631063
}
10641064

1065-
private replacePathEnv(path: string): string {
1065+
replacePathEnv(path: string): string {
10661066

1067-
// replace stable env
1068-
path = this.replaceProjEnv(path);
1067+
for (let cnt = 0; cnt < 5; cnt++) {
10691068

1070-
// replace user env
1071-
return this.replaceUserEnv(path, true);
1069+
if (!File.isEnvPath(path))
1070+
break; // not have any env var, end
1071+
1072+
// replace stable env
1073+
path = this._replaceProjEnv(path);
1074+
1075+
// replace user env
1076+
path = this._replaceUserEnv(path, true);
1077+
}
1078+
1079+
return path;
10721080
}
10731081

10741082
// project internal env vars
1075-
replaceProjEnv(str: string): string {
1083+
private _replaceProjEnv(str: string): string {
10761084

10771085
const prjConfig = this.GetConfiguration();
10781086
const prjRootDir = this.GetRootDir();
@@ -1103,7 +1111,7 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
11031111
}
11041112

11051113
// user defined env vars
1106-
replaceUserEnv(str: string, ignore_case_sensitivity: boolean = false): string {
1114+
private _replaceUserEnv(str: string, ignore_case_sensitivity: boolean = false): string {
11071115
const prjEnv = this.getProjectEnv();
11081116
if (prjEnv) {
11091117
for (const key in prjEnv) {
@@ -2828,24 +2836,24 @@ class EIDEProject extends AbstractProject {
28282836
// replace env variables for config
28292837
{
28302838
this.cppToolsConfig.defines = this.cppToolsConfig.defines.map((arg) => {
2831-
return this.replaceUserEnv(arg);
2839+
return this.replacePathEnv(arg);
28322840
});
28332841

28342842
if (this.cppToolsConfig.compilerArgs) {
28352843
this.cppToolsConfig.compilerArgs = (<string[]>this.cppToolsConfig.compilerArgs).map((arg) => {
2836-
return this.replaceUserEnv(arg);
2844+
return this.replacePathEnv(arg);
28372845
});
28382846
}
28392847

28402848
if (this.cppToolsConfig.cCompilerArgs) {
28412849
this.cppToolsConfig.cCompilerArgs = (<string[]>this.cppToolsConfig.cCompilerArgs).map((arg) => {
2842-
return this.replaceUserEnv(arg);
2850+
return this.replacePathEnv(arg);
28432851
});
28442852
}
28452853

28462854
if (this.cppToolsConfig.cppCompilerArgs) {
28472855
this.cppToolsConfig.cppCompilerArgs = (<string[]>this.cppToolsConfig.cppCompilerArgs).map((arg) => {
2848-
return this.replaceUserEnv(arg);
2856+
return this.replacePathEnv(arg);
28492857
});
28502858
}
28512859
}

src/HexUploader.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,7 @@ class CustomUploader extends HexUploader<string> {
10271027
});
10281028

10291029
// replace env
1030-
commandLine = this.project.replaceProjEnv(commandLine);
1031-
commandLine = this.project.replaceUserEnv(commandLine);
1030+
commandLine = this.project.replacePathEnv(commandLine);
10321031

10331032
return {
10341033
isOk: true,

0 commit comments

Comments
 (0)