Skip to content

Commit

Permalink
Add buildMode argument to verify
Browse files Browse the repository at this point in the history
  • Loading branch information
hlovdal authored and adiazulay committed Jan 19, 2021
1 parent e4a70b0 commit 4aa7ddc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
21 changes: 12 additions & 9 deletions src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { makeCompilerParserContext } from "./intellisense";
import { ProgrammerManager } from "./programmerManager";

export enum BuildMode {
Verify = "Verifying",
Upload = "Uploading",
UploadProgrammer = "Uploading (programmer)",
};
Expand Down Expand Up @@ -271,7 +272,7 @@ export class ArduinoApp {
});
}

public async verify(output: string = "") {
public async verify(buildMode: BuildMode, output: string = "") {
const dc = DeviceContext.getInstance();
const args: string[] = [];
const boardDescriptor = this.getBoardBuildString();
Expand All @@ -291,10 +292,12 @@ export class ArduinoApp {
await this.getMainSketch(dc);
}

if (!this.useArduinoCli()) {
args.push("--verify");
} else {
args.push("compile", "-b", boardDescriptor);
if (buildMode === BuildMode.Verify) {
if (!this.useArduinoCli()) {
args.push("--verify");
} else {
args.push("compile", "-b", boardDescriptor);
}
}

const verbose = VscodeSettings.getInstance().logLevel === "verbose";
Expand All @@ -305,7 +308,7 @@ export class ArduinoApp {
await vscode.workspace.saveAll(false);

arduinoChannel.show();
arduinoChannel.start(`Verify sketch - ${dc.sketch}`);
arduinoChannel.start(`${buildMode} sketch '${dc.sketch}'`);

if (!await this.runPreBuildCommand(dc)) {
return false;
Expand Down Expand Up @@ -350,16 +353,16 @@ export class ArduinoApp {
compilerParserContext.callback,
).then(async () => {
await cleanup();
arduinoChannel.end(`Finished verifying sketch - ${dc.sketch}${os.EOL}`);
arduinoChannel.end(`${buildMode} sketch '${dc.sketch}'${os.EOL}`);
success = true;
}, async (reason) => {
await cleanup();
const msg = reason.code ?
`Exit with code=${reason.code}${os.EOL}` :
`Exit with code=${reason.code}` :
reason.message ?
reason.message :
JSON.stringify(reason);
arduinoChannel.error(msg);
arduinoChannel.error(`${buildMode} sketch '${dc.sketch}': ${msg}${os.EOL}`);
});

if (compilerParserContext.conclude) {
Expand Down
4 changes: 2 additions & 2 deletions src/debug/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import * as path from "path";
import * as vscode from "vscode";

import { ArduinoApp } from "../arduino/arduino";
import { ArduinoApp, BuildMode } from "../arduino/arduino";
import ArduinoActivator from "../arduinoActivator";
import ArduinoContext from "../arduinoContext";

Expand Down Expand Up @@ -136,7 +136,7 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat
config.program = path.join(ArduinoWorkspace.rootPath, outputFolder, `${path.basename(dc.sketch)}.elf`);

// always compile elf to make sure debug the right elf
if (!await ArduinoContext.arduinoApp.verify(outputFolder)) {
if (!await ArduinoContext.arduinoApp.verify(BuildMode.Verify, outputFolder)) {
vscode.window.showErrorMessage("Failure to verify the program, please check output for details.");
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function activate(context: vscode.ExtensionContext) {
location: vscode.ProgressLocation.Window,
title: "Arduino: Verifying...",
}, async () => {
await arduinoContextModule.default.arduinoApp.verify();
await arduinoContextModule.default.arduinoApp.verify(BuildMode.Verify);
});
} catch (ex) {
}
Expand Down

0 comments on commit 4aa7ddc

Please sign in to comment.