@@ -182,7 +182,9 @@ export class ArduinoApp {
182
182
} )
183
183
. catch ( ( reason ) => {
184
184
this . _building = false ;
185
- // TODO EW, 2020-02-19: Report unhandled error (Logger?)
185
+ logger . notifyUserError ( "ArduinoApp.build" ,
186
+ reason ,
187
+ `Unhandled exception when cleaning up build (${ mode } ).` ) ;
186
188
return false ;
187
189
} ) ;
188
190
}
@@ -457,7 +459,7 @@ Please make sure the folder is not occupied by other procedures .`);
457
459
458
460
if ( ! this . boardManager . currentBoard ) {
459
461
if ( mode !== BuildMode . Analyze ) {
460
- logger . notifyUserError ( "getBoardBuildString " , new Error ( constants . messages . NO_BOARD_SELECTED ) ) ;
462
+ logger . notifyUserError ( "boardManager.currentBoard " , new Error ( constants . messages . NO_BOARD_SELECTED ) ) ;
461
463
}
462
464
return false ;
463
465
}
@@ -530,13 +532,6 @@ Please make sure the folder is not occupied by other procedures .`);
530
532
arduinoChannel . show ( ) ;
531
533
arduinoChannel . start ( `${ mode } sketch '${ dc . sketch } '` ) ;
532
534
533
- // TODO EW: What should we do with pre-/post build commands when running
534
- // analysis? Some could use it to generate/manipulate code which could
535
- // be a prerequisite for a successful build
536
- if ( ! await this . runPrePostBuildCommand ( dc , "pre" ) ) {
537
- return false ;
538
- }
539
-
540
535
if ( buildDir || dc . output ) {
541
536
const outputPath = path . resolve ( ArduinoWorkspace . rootPath , buildDir || dc . output ) ;
542
537
const dirPath = path . dirname ( outputPath ) ;
@@ -551,6 +546,13 @@ Please make sure the folder is not occupied by other procedures .`);
551
546
arduinoChannel . warning ( msg ) ;
552
547
}
553
548
549
+ // TODO EW: What should we do with pre-/post build commands when running
550
+ // analysis? Some could use it to generate/manipulate code which could
551
+ // be a prerequisite for a successful build
552
+ if ( ! await this . runPrePostBuildCommand ( dc , "pre" ) ) {
553
+ return false ;
554
+ }
555
+
554
556
// stop serial monitor when everything is prepared and good
555
557
// what makes restoring of its previous state easier
556
558
if ( mode === BuildMode . Upload || mode === BuildMode . UploadProgrammer ) {
@@ -562,8 +564,9 @@ Please make sure the folder is not occupied by other procedures .`);
562
564
args . push ( path . join ( ArduinoWorkspace . rootPath , dc . sketch ) ) ;
563
565
564
566
const cleanup = async ( result : "ok" | "error" ) => {
567
+ let ret = true ;
565
568
if ( result === "ok" ) {
566
- await this . runPrePostBuildCommand ( dc , "post" ) ;
569
+ ret = await this . runPrePostBuildCommand ( dc , "post" ) ;
567
570
}
568
571
await cocopa . conclude ( ) ;
569
572
if ( mode === BuildMode . Upload || mode === BuildMode . UploadProgrammer ) {
@@ -572,6 +575,7 @@ Please make sure the folder is not occupied by other procedures .`);
572
575
await SerialMonitor . getInstance ( ) . openSerialMonitor ( ) ;
573
576
}
574
577
}
578
+ return ret ;
575
579
}
576
580
const stdoutcb = ( line : string ) => {
577
581
if ( cocopa . callback ) {
@@ -591,17 +595,13 @@ Please make sure the folder is not occupied by other procedures .`);
591
595
line = `${ line } ${ os . EOL } ` ;
592
596
}
593
597
if ( ! verbose ) {
594
- // Don't spill log with spurious info from the backend
595
- // This list could be fetched from a config file to
596
- // accommodate messages of unknown board packages, newer
597
- // backend revisions etc.
598
+ // Don't spill log with spurious info from the backend. This
599
+ // list could be fetched from a config file to accommodate
600
+ // messages of unknown board packages, newer backend revisions
598
601
const filters = [
599
602
/ ^ P i c k e d \s u p \s J A V A _ T O O L _ O P T I O N S : \s + / ,
600
- / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s I N F O \s / ,
601
- / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s W A R N \s / ,
602
- / ^ D E B U G \s + / ,
603
- / ^ T R A C E \s + / ,
604
- / ^ I N F O \s + / ,
603
+ / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s (?: I N F O | W A R N ) \s / ,
604
+ / ^ (?: D E B U G | T R A C E | I N F O ) \s + / ,
605
605
] ;
606
606
for ( const f of filters ) {
607
607
if ( line . match ( f ) ) {
@@ -618,9 +618,11 @@ Please make sure the folder is not occupied by other procedures .`);
618
618
undefined ,
619
619
{ stdout : stdoutcb , stderr : stderrcb } ,
620
620
) . then ( async ( ) => {
621
- await cleanup ( "ok" ) ;
622
- arduinoChannel . end ( `${ mode } sketch '${ dc . sketch } '${ os . EOL } ` ) ;
623
- return true ;
621
+ const ret = await cleanup ( "ok" ) ;
622
+ if ( ret ) {
623
+ arduinoChannel . end ( `${ mode } sketch '${ dc . sketch } '${ os . EOL } ` ) ;
624
+ }
625
+ return ret ;
624
626
} , async ( reason ) => {
625
627
await cleanup ( "error" ) ;
626
628
const msg = reason . code
0 commit comments