Skip to content

Commit

Permalink
Change compiler path to user relative path (#1012)
Browse files Browse the repository at this point in the history
* Change compiler path to user relative path

* Fix format

* Update project.test.ts
  • Loading branch information
radurentea authored Jul 25, 2023
1 parent 125a313 commit 5e80b82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/test/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
Expand Down
9 changes: 7 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down

0 comments on commit 5e80b82

Please sign in to comment.