Skip to content

Commit

Permalink
Merge pull request esp8266#2738 from Wackerbarth/Issue_2732
Browse files Browse the repository at this point in the history
Pre- & Post- Build Hooks
  • Loading branch information
ffissore committed Mar 12, 2015
2 parents 4a9c3b1 + 0644bdc commit 5468a91
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions arduino-core/src/processing/app/debug/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ public Compiler(SketchData _sketch, String _buildPath, String _primaryClassName)
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
Expand Down Expand Up @@ -346,6 +349,10 @@ public boolean compile(boolean _verbose) throws RunnerException, PreferencesMapE

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
Expand Down Expand Up @@ -413,6 +420,10 @@ public boolean compile(boolean _verbose) throws RunnerException, PreferencesMapE
}

progressListener.progress(90);

// Hook runs at End of Compilation
runActions("hooks.postbuild", prefs);

return true;
}

Expand Down Expand Up @@ -1034,6 +1045,18 @@ void compileLink()
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);
Expand Down

0 comments on commit 5468a91

Please sign in to comment.