Skip to content

Commit

Permalink
Fix too early initialization of cocopa
Browse files Browse the repository at this point in the history
* Fixed bug with build: initializing cocopa too early (was failing if sketch wasn't initialized)
* More info in error message for uncaught exception during build cleanup
* Note on output path preparation which seems to be a bit wonky
  • Loading branch information
elektronikworkshop authored and adiazulay committed Jan 19, 2021
1 parent 48c4c64 commit f9cd3c5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class ArduinoApp {
this._building = false;
logger.notifyUserError("ArduinoApp.build",
reason,
`Unhandled exception when cleaning up build (${buildMode}).`);
`Unhandled exception when cleaning up build "${buildMode}": ${JSON.stringify(reason)}`);
return false;
});
}
Expand All @@ -203,7 +203,6 @@ export class ArduinoApp {
const dc = DeviceContext.getInstance();
const args: string[] = [];
let restoreSerialMonitor: boolean = false;
const cocopa = makeCompilerParserContext(dc);
const verbose = VscodeSettings.getInstance().logLevel === constants.LogLevel.Verbose;

if (!this.boardManager.currentBoard) {
Expand Down Expand Up @@ -330,6 +329,8 @@ export class ArduinoApp {
arduinoChannel.start(`${buildMode} sketch '${dc.sketch}'`);

if ((buildDir || dc.output) && compile) {
// 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);
const dirPath = path.dirname(buildDir);
if (!util.directoryExistsSync(dirPath)) {
Expand Down Expand Up @@ -381,6 +382,9 @@ export class ArduinoApp {

// Push sketch as last argument
args.push(path.join(ArduinoWorkspace.rootPath, dc.sketch));

const cocopa = makeCompilerParserContext(dc);

const cleanup = async (result: "ok" | "error") => {
let ret = true;
if (result === "ok") {
Expand Down

0 comments on commit f9cd3c5

Please sign in to comment.