Skip to content

Commit b11d54e

Browse files
author
Federico Fissore
committed
Compiler: adding hooks (custom recipes) between the main phases. New hooks are:
hooks.sketch.prebuild, hooks.sketch.postbuild, hooks.libraries.prebuild, hooks.libraries.postbuild, hooks.core.prebuild, hooks.core.postbuild, hooks.linking.prelink, hooks.linking.postlink, hooks.objcopy.preobjcopy, hooks.objcopy.postobjcopy, hooks.savehex.presavehex, hooks.savehex.postsavehex
1 parent c1002e2 commit b11d54e

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

arduino-core/src/processing/app/debug/Compiler.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,26 +405,44 @@ public boolean compile(boolean _verbose, boolean _save) throws RunnerException,
405405
System.err.println();
406406
}
407407
}
408-
408+
409+
runActions("hooks.sketch.prebuild", prefs);
410+
409411
// 1. compile the sketch (already in the buildPath)
410412
progressListener.progress(20);
411413
compileSketch(includeFolders);
412414
sketchIsCompiled = true;
413415

416+
runActions("hooks.sketch.postbuild", prefs);
417+
418+
runActions("hooks.libraries.prebuild", prefs);
419+
414420
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
415421
// Doesn't really use configPreferences
416422
progressListener.progress(30);
417423
compileLibraries(includeFolders);
418424

425+
runActions("hooks.libraries.postbuild", prefs);
426+
427+
runActions("hooks.core.prebuild", prefs);
428+
419429
// 3. compile the core, outputting .o files to <buildPath> and then
420430
// collecting them into the core.a library file.
421431
progressListener.progress(40);
422432
compileCore();
423433

434+
runActions("hooks.core.postbuild", prefs);
435+
436+
runActions("hooks.linking.prelink", prefs);
437+
424438
// 4. link it all together into the .elf file
425439
progressListener.progress(50);
426440
compileLink();
427441

442+
runActions("hooks.linking.postlink", prefs);
443+
444+
runActions("hooks.objcopy.preobjcopy", prefs);
445+
428446
// 5. run objcopy to generate output files
429447
progressListener.progress(60);
430448
List<String> objcopyPatterns = new ArrayList<String>();
@@ -437,10 +455,16 @@ public boolean compile(boolean _verbose, boolean _save) throws RunnerException,
437455
runRecipe(recipe);
438456
}
439457

458+
runActions("hooks.objcopy.postobjcopy", prefs);
459+
440460
// 7. save the hex file
441461
if (saveHex) {
462+
runActions("hooks.savehex.presavehex", prefs);
463+
442464
progressListener.progress(80);
443465
saveHex();
466+
467+
runActions("hooks.savehex.postsavehex", prefs);
444468
}
445469

446470
progressListener.progress(90);

0 commit comments

Comments
 (0)