Skip to content

Commit

Permalink
do not duplicate python in path env var (#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianignacio5 authored Jan 10, 2025
1 parent 5aefc5d commit 94f967f
Showing 1 changed file with 44 additions and 26 deletions.
70 changes: 44 additions & 26 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,25 +1052,6 @@ export async function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) {
path.join(modifiedEnv.IDF_TOOLS_PATH, "tools"),
["cmake", "ninja"]
);
const customExtraVars = idfConf.readParameter(
"idf.customExtraVars",
curWorkspace
) as { [key: string]: string };
if (customExtraVars) {
try {
for (const envVar in customExtraVars) {
if (envVar) {
modifiedEnv[envVar] = customExtraVars[envVar];
}
}
} catch (error) {
Logger.errorNotify(
"Invalid user environment variables format",
error,
"appendIdfAndToolsToPath idf.customExtraVars"
);
}
}
const customVars = await idfToolsManager.exportVars(
path.join(modifiedEnv.IDF_TOOLS_PATH, "tools")
);
Expand Down Expand Up @@ -1178,6 +1159,26 @@ export async function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) {
}
}

const customExtraVars = idfConf.readParameter(
"idf.customExtraVars",
curWorkspace
) as { [key: string]: string };
if (customExtraVars) {
try {
for (const envVar in customExtraVars) {
if (envVar) {
modifiedEnv[envVar] = customExtraVars[envVar];
}
}
} catch (error) {
Logger.errorNotify(
"Invalid user environment variables format",
error,
"appendIdfAndToolsToPath idf.customExtraVars"
);
}
}

if (pathToGitDir) {
modifiedEnv[pathNameInEnv] =
pathToGitDir + path.delimiter + modifiedEnv[pathNameInEnv];
Expand All @@ -1186,12 +1187,28 @@ export async function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) {
modifiedEnv[pathNameInEnv] =
pathToPigweed + path.delimiter + modifiedEnv[pathNameInEnv];
}
modifiedEnv[pathNameInEnv] =
path.dirname(modifiedEnv.PYTHON) +
path.delimiter +
path.join(modifiedEnv.IDF_PATH, "tools") +
path.delimiter +
modifiedEnv[pathNameInEnv];

if (
modifiedEnv[pathNameInEnv] &&
!modifiedEnv[pathNameInEnv].includes(path.dirname(modifiedEnv.PYTHON))
) {
modifiedEnv[pathNameInEnv] =
path.dirname(modifiedEnv.PYTHON) +
path.delimiter +
modifiedEnv[pathNameInEnv];
}

if (
modifiedEnv[pathNameInEnv] &&
!modifiedEnv[pathNameInEnv].includes(
path.join(modifiedEnv.IDF_PATH, "tools")
)
) {
modifiedEnv[pathNameInEnv] =
path.join(modifiedEnv.IDF_PATH, "tools") +
path.delimiter +
modifiedEnv[pathNameInEnv];
}

const extraPathsArray = extraPaths.split(path.delimiter);
for (let extraPath of extraPathsArray) {
Expand All @@ -1210,7 +1227,8 @@ export async function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) {

let idfTarget = await getIdfTargetFromSdkconfig(curWorkspace);
if (idfTarget) {
modifiedEnv.IDF_TARGET = idfTarget || process.env.IDF_TARGET;
modifiedEnv.IDF_TARGET =
modifiedEnv.IDF_TARGET || idfTarget || process.env.IDF_TARGET;
}

let enableComponentManager = idfConf.readParameter(
Expand Down

0 comments on commit 94f967f

Please sign in to comment.