From f9cd3c5c9c2229bc2ee2b88f8ef8c2b935661c51 Mon Sep 17 00:00:00 2001 From: Uli Franke Date: Sat, 29 Feb 2020 07:55:37 +0100 Subject: [PATCH] Fix too early initialization of cocopa * 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 --- src/arduino/arduino.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/arduino/arduino.ts b/src/arduino/arduino.ts index 5f2ed379..492bf57d 100644 --- a/src/arduino/arduino.ts +++ b/src/arduino/arduino.ts @@ -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; }); } @@ -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) { @@ -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)) { @@ -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") {