@@ -16,7 +16,6 @@ import { IArduinoSettings } from "./arduinoSettings";
16
16
import { BoardManager } from "./boardManager" ;
17
17
import { ExampleManager } from "./exampleManager" ;
18
18
import { AnalysisManager ,
19
- ICoCoPaContext ,
20
19
isCompilerParserEnabled ,
21
20
makeCompilerParserContext } from "./intellisense" ;
22
21
import { LibraryManager } from "./libraryManager" ;
@@ -202,7 +201,8 @@ export class ArduinoApp {
202
201
const dc = DeviceContext . getInstance ( ) ;
203
202
const args : string [ ] = [ ] ;
204
203
let restoreSerialMonitor : boolean = false ;
205
- let cocopa : ICoCoPaContext ;
204
+ const cocopa = makeCompilerParserContext ( dc ) ;
205
+ const verbose = VscodeSettings . getInstance ( ) . logLevel === constants . LogLevel . Verbose ;
206
206
207
207
if ( ! this . boardManager . currentBoard ) {
208
208
if ( buildMode !== BuildMode . Analyze ) {
@@ -277,7 +277,6 @@ export class ArduinoApp {
277
277
await selectSerial ( ) ;
278
278
return false ;
279
279
}
280
-
281
280
if ( ! compile && ! this . useArduinoCli ( ) ) {
282
281
arduinoChannel . error ( "This command is only available when using the Arduino CLI" ) ;
283
282
return false ;
@@ -302,12 +301,10 @@ export class ArduinoApp {
302
301
}
303
302
304
303
args . push ( "--port" , dc . port ) ;
305
- } else if ( buildMode === BuildMode . Analyze ) {
306
- cocopa = makeCompilerParserContext ( dc ) ;
307
304
if ( ! this . useArduinoCli ( ) ) {
308
- args . push ( "--verify" , "--verbose" ) ;
305
+ args . push ( "--verify" ) ;
309
306
} else {
310
- args . push ( "compile" , "--verbose" , "- b", boardDescriptor ) ;
307
+ args . push ( "compile" , "-b" , boardDescriptor ) ;
311
308
}
312
309
} else {
313
310
if ( ! this . useArduinoCli ( ) ) {
@@ -317,10 +314,8 @@ export class ArduinoApp {
317
314
}
318
315
}
319
316
320
- const verbose = VscodeSettings . getInstance ( ) . logLevel === "verbose" ;
321
- if ( buildMode !== BuildMode . Analyze && verbose ) {
322
- args . push ( "--verbose" ) ;
323
- }
317
+ // We always build verbosely but filter the output based on the settings
318
+ args . push ( "--verbose" ) ;
324
319
325
320
await vscode . workspace . saveAll ( false ) ;
326
321
@@ -365,33 +360,31 @@ export class ArduinoApp {
365
360
args . push ( path . join ( ArduinoWorkspace . rootPath , dc . sketch ) ) ;
366
361
367
362
const cleanup = async ( ) => {
368
- if ( cocopa ) {
369
- await cocopa . conclude ( ) ;
370
- }
363
+ await cocopa . conclude ( ) ;
371
364
if ( buildMode === BuildMode . Upload || buildMode === BuildMode . UploadProgrammer ) {
372
365
UsbDetector . getInstance ( ) . resumeListening ( ) ;
373
366
if ( restoreSerialMonitor ) {
374
367
await SerialMonitor . getInstance ( ) . openSerialMonitor ( ) ;
375
368
}
376
369
}
377
370
}
371
+ const stdoutcb = ( line : string ) => {
372
+ cocopa . callback ( line ) ;
373
+ if ( verbose ) {
374
+ arduinoChannel . channel . append ( line ) ;
375
+ }
376
+ }
377
+ const stderrcb = ( line : string ) => {
378
+ arduinoChannel . channel . append ( line ) ;
379
+ }
378
380
379
381
return await util . spawn (
380
382
this . _settings . commandPath ,
381
383
args ,
382
384
undefined ,
383
- {
384
- channel : ! cocopa || cocopa && verbose ? arduinoChannel . channel : undefined ,
385
- stdout : cocopa ? cocopa . callback : undefined ,
386
- } ,
385
+ { stdout : stdoutcb , stderr : stderrcb } ,
387
386
) . then ( async ( ) => {
388
387
await cleanup ( ) ;
389
- if ( buildMode !== BuildMode . Analyze ) {
390
- const cmd = os . platform ( ) === "darwin"
391
- ? "Cmd + Alt + I"
392
- : "Ctrl + Alt + I" ;
393
- arduinoChannel . info ( `To rebuild your IntelliSense configuration run "${ cmd } "` ) ;
394
- }
395
388
arduinoChannel . end ( `${ buildMode } sketch '${ dc . sketch } '${ os . EOL } ` ) ;
396
389
return true ;
397
390
} , async ( reason ) => {
0 commit comments