diff --git a/src/test/project.test.ts b/src/test/project.test.ts index 69d1ccd4d..7170b6da7 100644 --- a/src/test/project.test.ts +++ b/src/test/project.test.ts @@ -74,12 +74,16 @@ suite("Project tests", () => { const templateCCppPropertiesJsonJson = await readJson( join(templateFolder, ".vscode", "c_cpp_properties.json") ); - const compilerPath = await isBinInPath( + const compilerAbsolutePath = await isBinInPath( "xtensa-esp32-elf-gcc", targetFolder, process.env ); - templateCCppPropertiesJsonJson.configurations[0].compilerPath = compilerPath; + let compilerRelativePath = compilerAbsolutePath.split( + process.env.IDF_TOOLS_PATH + )[1]; + templateCCppPropertiesJsonJson.configurations[0].compilerPath = + "${config:idf.toolsPath}" + compilerRelativePath; const targetCCppPropertiesJsonJson = await readJson( join(targetFolder, ".vscode", "c_cpp_properties.json") ); diff --git a/src/utils.ts b/src/utils.ts index efeb3d692..b2a916b6e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -231,18 +231,23 @@ export async function setCCppPropertiesJsonCompilerPath( const modifiedEnv = appendIdfAndToolsToPath(curWorkspaceFsPath); const idfTarget = modifiedEnv.IDF_TARGET || "esp32"; const gccTool = getToolchainToolName(idfTarget, "gcc"); - const compilerPath = await isBinInPath( + const compilerAbsolutePath = await isBinInPath( gccTool, curWorkspaceFsPath.fsPath, modifiedEnv ); + const cCppPropertiesJson = await readJSON(cCppPropertiesJsonPath); if ( cCppPropertiesJson && cCppPropertiesJson.configurations && cCppPropertiesJson.configurations.length ) { - cCppPropertiesJson.configurations[0].compilerPath = compilerPath; + let compilerRelativePath = compilerAbsolutePath.split( + modifiedEnv.IDF_TOOLS_PATH + )[1]; + cCppPropertiesJson.configurations[0].compilerPath = + "${config:idf.toolsPath}" + compilerRelativePath; await writeJSON(cCppPropertiesJsonPath, cCppPropertiesJson, { spaces: vscode.workspace.getConfiguration().get("editor.tabSize") || 2, });