@@ -183,7 +183,9 @@ export class ArduinoApp {
183183 } )
184184 . catch ( ( reason ) => {
185185 this . _building = false ;
186- // TODO EW, 2020-02-19: Report unhandled error (Logger?)
186+ logger . notifyUserError ( "ArduinoApp.build" ,
187+ reason ,
188+ `Unhandled exception when cleaning up build (${ buildMode } ).` ) ;
187189 return false ;
188190 } ) ;
189191 }
@@ -328,13 +330,6 @@ export class ArduinoApp {
328330 arduinoChannel . show ( ) ;
329331 arduinoChannel . start ( `${ buildMode } sketch '${ dc . sketch } '` ) ;
330332
331- // TODO EW: What should we do with pre-/post build commands when running
332- // analysis? Some could use it to generate/manipulate code which could
333- // be a prerequisite for a successful build
334- if ( ! await this . runPrePostBuildCommand ( dc , "pre" ) ) {
335- return false ;
336- }
337-
338333 if ( ( buildDir || dc . output ) && compile ) {
339334 const outputPath = path . resolve ( ArduinoWorkspace . rootPath , buildDir || dc . output ) ;
340335 const dirPath = path . dirname ( outputPath ) ;
@@ -356,6 +351,13 @@ export class ArduinoApp {
356351 arduinoChannel . warning ( msg ) ;
357352 }
358353
354+ // TODO EW: What should we do with pre-/post build commands when running
355+ // analysis? Some could use it to generate/manipulate code which could
356+ // be a prerequisite for a successful build
357+ if ( ! await this . runPrePostBuildCommand ( dc , "pre" ) ) {
358+ return false ;
359+ }
360+
359361 // stop serial monitor when everything is prepared and good
360362 // what makes restoring of its previous state easier
361363 if ( buildMode === BuildMode . Upload || buildMode === BuildMode . UploadProgrammer ) {
@@ -365,10 +367,10 @@ export class ArduinoApp {
365367
366368 // Push sketch as last argument
367369 args . push ( path . join ( ArduinoWorkspace . rootPath , dc . sketch ) ) ;
368-
369370 const cleanup = async ( result : "ok" | "error" ) => {
371+ let ret = true ;
370372 if ( result === "ok" ) {
371- await this . runPrePostBuildCommand ( dc , "post" ) ;
373+ ret = await this . runPrePostBuildCommand ( dc , "post" ) ;
372374 }
373375 await cocopa . conclude ( ) ;
374376 if ( buildMode === BuildMode . Upload || buildMode === BuildMode . UploadProgrammer ) {
@@ -377,6 +379,7 @@ export class ArduinoApp {
377379 await SerialMonitor . getInstance ( ) . openSerialMonitor ( ) ;
378380 }
379381 }
382+ return ret ;
380383 }
381384 const stdoutcb = ( line : string ) => {
382385 if ( cocopa . callback ) {
@@ -396,17 +399,13 @@ export class ArduinoApp {
396399 line = `${ line } ${ os . EOL } ` ;
397400 }
398401 if ( ! verbose ) {
399- // Don't spill log with spurious info from the backend
400- // This list could be fetched from a config file to
401- // accommodate messages of unknown board packages, newer
402- // backend revisions etc.
402+ // Don't spill log with spurious info from the backend. This
403+ // list could be fetched from a config file to accommodate
404+ // messages of unknown board packages, newer backend revisions
403405 const filters = [
404406 / ^ 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 + / ,
405- / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s I N F O \s / ,
406- / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s W A R N \s / ,
407- / ^ D E B U G \s + / ,
408- / ^ T R A C E \s + / ,
409- / ^ I N F O \s + / ,
407+ / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s (?: I N F O | W A R N ) \s / ,
408+ / ^ (?: D E B U G | T R A C E | I N F O ) \s + / ,
410409 ] ;
411410 for ( const f of filters ) {
412411 if ( line . match ( f ) ) {
@@ -423,9 +422,11 @@ export class ArduinoApp {
423422 undefined ,
424423 { stdout : stdoutcb , stderr : stderrcb } ,
425424 ) . then ( async ( ) => {
426- await cleanup ( "ok" ) ;
427- arduinoChannel . end ( `${ buildMode } sketch '${ dc . sketch } '${ os . EOL } ` ) ;
428- return true ;
425+ const ret = await cleanup ( "ok" ) ;
426+ if ( ret ) {
427+ arduinoChannel . end ( `${ buildMode } sketch '${ dc . sketch } '${ os . EOL } ` ) ;
428+ }
429+ return ret ;
429430 } , async ( reason ) => {
430431 await cleanup ( "error" ) ;
431432 const msg = reason . code
0 commit comments