Merge pull request #2738 from Wackerbarth/Issue_2732

Pre- & Post- Build Hooks
This commit is contained in:
Federico Fissore 2015-03-12 09:07:44 +01:00
commit 5468a91dfd
1 changed files with 23 additions and 0 deletions

View File

@ -183,6 +183,9 @@ public class Compiler implements MessageConsumer {
sketch = _sketch;
prefs = createBuildPreferences(_buildPath, _primaryClassName);
// provide access to the source tree
prefs.put("build.source.path", _sketch.getFolder().getAbsolutePath());
// Start with an empty progress listener
progressListener = new ProgressListener() {
@Override
@ -346,6 +349,10 @@ public class Compiler implements MessageConsumer {
verbose = _verbose || PreferencesData.getBoolean("build.verbose");
sketchIsCompiled = false;
// Hook runs at Start of Compilation
runActions("hooks.prebuild", prefs);
objectFiles = new ArrayList<File>();
// 0. include paths for core + all libraries
@ -413,6 +420,10 @@ public class Compiler implements MessageConsumer {
}
progressListener.progress(90);
// Hook runs at End of Compilation
runActions("hooks.postbuild", prefs);
return true;
}
@ -1034,6 +1045,18 @@ public class Compiler implements MessageConsumer {
execAsynchronously(cmdArray);
}
void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException, PreferencesMapException {
List<String> patterns = new ArrayList<String>();
for (String key : prefs.keySet()) {
if (key.startsWith("recipe."+recipeClass) && key.endsWith(".pattern"))
patterns.add(key);
}
Collections.sort(patterns);
for (String recipe : patterns) {
runRecipe(recipe);
}
}
void runRecipe(String recipe) throws RunnerException, PreferencesMapException {
PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + BaseNoGui.REVISION);