Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

possible fix for #1473 #1486

Merged
merged 5 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,18 @@ export class ArduinoApp {
if (buildDir || dc.output) {
// 2020-02-29, EW: This whole code appears a bit wonky to me.
// What if the user specifies an output directory "../builds/my project"
buildDir = path.resolve(ArduinoWorkspace.rootPath, buildDir || dc.output);

// the first choice of the path should be from the users explicit settings.
if (dc.output) {
buildDir = path.resolve(ArduinoWorkspace.rootPath, dc.output);
} else {
buildDir = path.resolve(ArduinoWorkspace.rootPath, buildDir);
}


const dirPath = path.dirname(buildDir);
if (!util.directoryExistsSync(dirPath)) {
logger.notifyUserError("InvalidOutPutPath", new Error(constants.messages.INVALID_OUTPUT_PATH + buildDir));
return false;
util.mkdirRecursivelySync(dirPath);
}

if (this.useArduinoCli()) {
Expand Down
14 changes: 10 additions & 4 deletions src/debug/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,15 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat
const dc = DeviceContext.getInstance();

if (!config.program || config.program === "${file}") {
// make a unique temp folder because keeping same temp folder will corrupt the build when board is changed
const outputFolder = path.join(dc.output || `.build`, ArduinoContext.boardManager.currentBoard.board);
util.mkdirRecursivelySync(path.join(ArduinoWorkspace.rootPath, outputFolder));
const outputFolder = path.join(dc.output || `.build`);
const outputPath = path.join(ArduinoWorkspace.rootPath, outputFolder);

// if the directory was already there, clear the folder so that it's not corrupted from previous builds.
if (util.directoryExistsSync(outputPath)) {
util.rmdirRecursivelySync(outputPath);
}

util.mkdirRecursivelySync(outputPath);
if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) {
await dc.resolveMainSketch();
}
Expand All @@ -134,7 +140,7 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat
vscode.window.showErrorMessage(`Cannot find ${dc.sketch}, Please specify the sketch in the arduino.json file`);
return false;
}
config.program = path.join(ArduinoWorkspace.rootPath, outputFolder, `${path.basename(dc.sketch)}.elf`);
config.program = path.join(outputPath, `${path.basename(dc.sketch)}.elf`);

// always compile elf to make sure debug the right elf
if (!await ArduinoContext.arduinoApp.build(BuildMode.Verify, outputFolder)) {
Expand Down