Skip to content

Commit 0644bdc

Browse files
committed
Convert to action pattern to allow multiple actions
1 parent 2f65f5f commit 0644bdc

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ public boolean compile(boolean _verbose) throws RunnerException, PreferencesMapE
351351
sketchIsCompiled = false;
352352

353353
// Hook runs at Start of Compilation
354-
if (prefs.containsKey("recipe.hooks.prebuild"))
355-
runRecipe("recipe.hooks.prebuild");
354+
runActions("hooks.prebuild", prefs);
356355

357356
objectFiles = new ArrayList<File>();
358357

@@ -422,9 +421,8 @@ public boolean compile(boolean _verbose) throws RunnerException, PreferencesMapE
422421

423422
progressListener.progress(90);
424423

425-
// Hook runs at End of Compilation
426-
if (prefs.containsKey("recipe.hooks.postbuild"))
427-
runRecipe("recipe.hooks.postbuild");
424+
// Hook runs at End of Compilation
425+
runActions("hooks.postbuild", prefs);
428426

429427
return true;
430428
}
@@ -1047,6 +1045,18 @@ void compileLink()
10471045
execAsynchronously(cmdArray);
10481046
}
10491047

1048+
void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException, PreferencesMapException {
1049+
List<String> patterns = new ArrayList<String>();
1050+
for (String key : prefs.keySet()) {
1051+
if (key.startsWith("recipe."+recipeClass) && key.endsWith(".pattern"))
1052+
patterns.add(key);
1053+
}
1054+
Collections.sort(patterns);
1055+
for (String recipe : patterns) {
1056+
runRecipe(recipe);
1057+
}
1058+
}
1059+
10501060
void runRecipe(String recipe) throws RunnerException, PreferencesMapException {
10511061
PreferencesMap dict = new PreferencesMap(prefs);
10521062
dict.put("ide_version", "" + BaseNoGui.REVISION);

0 commit comments

Comments
 (0)