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

Commit 3319e8f

Browse files
* Run IntelliSense analysis for every build
* Added global enum for log level
1 parent 1b7eafe commit 3319e8f

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

src/arduino/arduino.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ Please make sure the folder is not occupied by other procedures .`);
439439
const dc = DeviceContext.getInstance();
440440
const args: string[] = [];
441441
let restoreSerialMonitor: boolean = false;
442-
let cocopa: ICoCoPaContext;
442+
const cocopa = makeCompilerParserContext(dc);
443+
const verbose = VscodeSettings.getInstance().logLevel === constants.LogLevel.Verbose;
443444

444445
if (!this.boardManager.currentBoard) {
445446
if (mode !== BuildMode.Analyze) {
@@ -499,18 +500,12 @@ Please make sure the folder is not occupied by other procedures .`);
499500
"--port", dc.port,
500501
"--useprogrammer",
501502
"--pref", "programmer=" + programmer);
502-
503-
} else if (mode === BuildMode.Analyze) {
504-
cocopa = makeCompilerParserContext(dc);
505-
args.push("--verify", "--verbose");
506503
} else {
507504
args.push("--verify");
508505
}
509506

510-
const verbose = VscodeSettings.getInstance().logLevel === "verbose";
511-
if (mode !== BuildMode.Analyze && verbose) {
512-
args.push("--verbose");
513-
}
507+
// We always build verbosely but filter the output based on the settings
508+
args.push("--verbose");
514509

515510
await vscode.workspace.saveAll(false);
516511

@@ -530,7 +525,6 @@ Please make sure the folder is not occupied by other procedures .`);
530525
logger.notifyUserError("InvalidOutPutPath", new Error(constants.messages.INVALID_OUTPUT_PATH + outputPath));
531526
return false;
532527
}
533-
534528
args.push("--pref", `build.path=${outputPath}`);
535529
arduinoChannel.info(`Please see the build logs in output path: ${outputPath}`);
536530
} else {
@@ -549,33 +543,31 @@ Please make sure the folder is not occupied by other procedures .`);
549543
args.push(path.join(ArduinoWorkspace.rootPath, dc.sketch));
550544

551545
const cleanup = async () => {
552-
if (cocopa) {
553-
await cocopa.conclude();
554-
}
546+
await cocopa.conclude();
555547
if (mode === BuildMode.Upload || mode === BuildMode.UploadProgrammer) {
556548
UsbDetector.getInstance().resumeListening();
557549
if (restoreSerialMonitor) {
558550
await SerialMonitor.getInstance().openSerialMonitor();
559551
}
560552
}
561553
}
554+
const stdoutcb = (line: string) => {
555+
cocopa.callback(line);
556+
if (verbose) {
557+
arduinoChannel.channel.append(line);
558+
}
559+
}
560+
const stderrcb = (line: string) => {
561+
arduinoChannel.channel.append(line);
562+
}
562563

563564
return await util.spawn(
564565
this._settings.commandPath,
565566
args,
566567
undefined,
567-
{
568-
channel: !cocopa || cocopa && verbose ? arduinoChannel.channel : undefined,
569-
stdout: cocopa ? cocopa.callback : undefined,
570-
},
568+
{ stdout: stdoutcb, stderr: stderrcb },
571569
).then(async () => {
572570
await cleanup();
573-
if (mode !== BuildMode.Analyze) {
574-
const cmd = os.platform() === "darwin"
575-
? "Cmd + Alt + I"
576-
: "Ctrl + Alt + I";
577-
arduinoChannel.info(`To rebuild your IntelliSense configuration run "${cmd}"`);
578-
}
579571
arduinoChannel.end(`${mode} sketch '${dc.sketch}${os.EOL}`);
580572
return true;
581573
}, async (reason) => {

src/arduino/intellisense.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import * as ccp from "cocopa";
55
import * as fs from "fs";
6+
import * as os from "os";
67
import * as path from "path";
78
import * as tp from "typed-promisify";
89

910
import * as constants from "../common/constants";
1011
import { arduinoChannel } from "../common/outputChannel";
1112
import { ArduinoWorkspace } from "../common/workspace";
1213
import { DeviceContext } from "../deviceContext";
13-
1414
import { VscodeSettings } from "./vscodeSettings";
1515

1616
export interface ICoCoPaContext {
@@ -103,6 +103,10 @@ export function makeCompilerParserContext(dc: DeviceContext): ICoCoPaContext {
103103
const estr = JSON.stringify(e);
104104
arduinoChannel.error(`Failed to read or write IntelliSense configuration: ${estr}`);
105105
}
106+
const cmd = os.platform() === "darwin"
107+
? "Cmd + Alt + I"
108+
: "Ctrl + Alt + I";
109+
arduinoChannel.info(`To manually rebuild your IntelliSense configuration run "${cmd}"`);
106110
};
107111
return {
108112
callback: runner.callback(),

src/common/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ export const CPP_CONFIG_FILE = path.join(".vscode", "c_cpp_properties.json");
1010
/** The name of the intellisense configuration managed by vscode-arduino. */
1111
export const C_CPP_PROPERTIES_CONFIG_NAME = "Arduino";
1212

13+
export enum LogLevel {
14+
Info = "info",
15+
Verbose = "verbose",
16+
};
17+
1318
export const ARDUINO_MODE: vscode.DocumentSelector = [
1419
{ language: "cpp", scheme: "file" },
1520
{ language: "arduino", scheme: "file" },

src/debug/configurationProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ArduinoActivator from "../arduinoActivator";
99
import ArduinoContext from "../arduinoContext";
1010

1111
import { VscodeSettings } from "../arduino/vscodeSettings";
12+
import * as constants from "../common/constants";
1213
import * as platform from "../common/platform";
1314
import * as util from "../common/util";
1415
import { ArduinoWorkspace } from "../common/workspace";
@@ -77,7 +78,7 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat
7778
await ArduinoActivator.activate();
7879
}
7980

80-
if (VscodeSettings.getInstance().logLevel === "verbose" && !config.logging) {
81+
if (VscodeSettings.getInstance().logLevel === constants.LogLevel.Verbose && !config.logging) {
8182
config = {
8283
...config, logging: {
8384
engineLogging: true,

0 commit comments

Comments
 (0)