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

Commit 3777ed7

Browse files
authored
Merge pull request #1486 from microsoft/dev/gcampbell/OutputFolder
possible fix for #1473
2 parents 0890134 + 17d78d7 commit 3777ed7

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/arduino/arduino.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,17 @@ export class ArduinoApp {
675675
if (buildDir || dc.output) {
676676
// 2020-02-29, EW: This whole code appears a bit wonky to me.
677677
// What if the user specifies an output directory "../builds/my project"
678-
buildDir = path.resolve(ArduinoWorkspace.rootPath, buildDir || dc.output);
678+
679+
// the first choice of the path should be from the users explicit settings.
680+
if (dc.output) {
681+
buildDir = path.resolve(ArduinoWorkspace.rootPath, dc.output);
682+
} else {
683+
buildDir = path.resolve(ArduinoWorkspace.rootPath, buildDir);
684+
}
685+
679686
const dirPath = path.dirname(buildDir);
680687
if (!util.directoryExistsSync(dirPath)) {
681-
logger.notifyUserError("InvalidOutPutPath", new Error(constants.messages.INVALID_OUTPUT_PATH + buildDir));
682-
return false;
688+
util.mkdirRecursivelySync(dirPath);
683689
}
684690

685691
if (this.useArduinoCli()) {

src/common/constants.ts

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export const messages = {
3636
SERIAL_PORT_NOT_STARTED: "Serial Monitor has not been started.",
3737
SEND_BEFORE_OPEN_SERIALPORT: "Please open a serial port first.",
3838
NO_PROGRAMMMER_SELECTED: "Please select the programmer first.",
39-
INVALID_OUTPUT_PATH: "Please check the \"output\" in the sketch Settings.Cannot find the output path:",
4039
};
4140

4241
export const statusBarPriority = {

src/debug/configurationProvider.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,15 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat
118118
const dc = DeviceContext.getInstance();
119119

120120
if (!config.program || config.program === "${file}") {
121-
// make a unique temp folder because keeping same temp folder will corrupt the build when board is changed
122-
const outputFolder = path.join(dc.output || `.build`, ArduinoContext.boardManager.currentBoard.board);
123-
util.mkdirRecursivelySync(path.join(ArduinoWorkspace.rootPath, outputFolder));
121+
const outputFolder = path.join(dc.output || `.build`);
122+
const outputPath = path.join(ArduinoWorkspace.rootPath, outputFolder);
123+
124+
// if the directory was already there, clear the folder so that it's not corrupted from previous builds.
125+
if (util.directoryExistsSync(outputPath)) {
126+
util.rmdirRecursivelySync(outputPath);
127+
}
128+
129+
util.mkdirRecursivelySync(outputPath);
124130
if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) {
125131
await dc.resolveMainSketch();
126132
}
@@ -134,7 +140,7 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat
134140
vscode.window.showErrorMessage(`Cannot find ${dc.sketch}, Please specify the sketch in the arduino.json file`);
135141
return false;
136142
}
137-
config.program = path.join(ArduinoWorkspace.rootPath, outputFolder, `${path.basename(dc.sketch)}.elf`);
143+
config.program = path.join(outputPath, `${path.basename(dc.sketch)}.elf`);
138144

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

0 commit comments

Comments
 (0)