mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-06 01:08:25 +01:00
Merge pull request #3236 from ffissore/build-hooks
Additional build hooks
This commit is contained in:
commit
886590e015
@ -34,6 +34,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import cc.arduino.MyStreamPumper;
|
import cc.arduino.MyStreamPumper;
|
||||||
import cc.arduino.packages.BoardPort;
|
import cc.arduino.packages.BoardPort;
|
||||||
@ -403,26 +405,44 @@ public class Compiler implements MessageConsumer {
|
|||||||
System.err.println();
|
System.err.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runActions("hooks.sketch.prebuild", prefs);
|
||||||
|
|
||||||
// 1. compile the sketch (already in the buildPath)
|
// 1. compile the sketch (already in the buildPath)
|
||||||
progressListener.progress(20);
|
progressListener.progress(20);
|
||||||
compileSketch(includeFolders);
|
compileSketch(includeFolders);
|
||||||
sketchIsCompiled = true;
|
sketchIsCompiled = true;
|
||||||
|
|
||||||
|
runActions("hooks.sketch.postbuild", prefs);
|
||||||
|
|
||||||
|
runActions("hooks.libraries.prebuild", prefs);
|
||||||
|
|
||||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||||
// Doesn't really use configPreferences
|
// Doesn't really use configPreferences
|
||||||
progressListener.progress(30);
|
progressListener.progress(30);
|
||||||
compileLibraries(includeFolders);
|
compileLibraries(includeFolders);
|
||||||
|
|
||||||
|
runActions("hooks.libraries.postbuild", prefs);
|
||||||
|
|
||||||
|
runActions("hooks.core.prebuild", prefs);
|
||||||
|
|
||||||
// 3. compile the core, outputting .o files to <buildPath> and then
|
// 3. compile the core, outputting .o files to <buildPath> and then
|
||||||
// collecting them into the core.a library file.
|
// collecting them into the core.a library file.
|
||||||
progressListener.progress(40);
|
progressListener.progress(40);
|
||||||
compileCore();
|
compileCore();
|
||||||
|
|
||||||
|
runActions("hooks.core.postbuild", prefs);
|
||||||
|
|
||||||
|
runActions("hooks.linking.prelink", prefs);
|
||||||
|
|
||||||
// 4. link it all together into the .elf file
|
// 4. link it all together into the .elf file
|
||||||
progressListener.progress(50);
|
progressListener.progress(50);
|
||||||
compileLink();
|
compileLink();
|
||||||
|
|
||||||
|
runActions("hooks.linking.postlink", prefs);
|
||||||
|
|
||||||
|
runActions("hooks.objcopy.preobjcopy", prefs);
|
||||||
|
|
||||||
// 5. run objcopy to generate output files
|
// 5. run objcopy to generate output files
|
||||||
progressListener.progress(60);
|
progressListener.progress(60);
|
||||||
List<String> objcopyPatterns = new ArrayList<String>();
|
List<String> objcopyPatterns = new ArrayList<String>();
|
||||||
@ -435,10 +455,16 @@ public class Compiler implements MessageConsumer {
|
|||||||
runRecipe(recipe);
|
runRecipe(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runActions("hooks.objcopy.postobjcopy", prefs);
|
||||||
|
|
||||||
// 7. save the hex file
|
// 7. save the hex file
|
||||||
if (saveHex) {
|
if (saveHex) {
|
||||||
|
runActions("hooks.savehex.presavehex", prefs);
|
||||||
|
|
||||||
progressListener.progress(80);
|
progressListener.progress(80);
|
||||||
saveHex();
|
saveHex();
|
||||||
|
|
||||||
|
runActions("hooks.savehex.postsavehex", prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
progressListener.progress(90);
|
progressListener.progress(90);
|
||||||
@ -554,6 +580,17 @@ public class Compiler implements MessageConsumer {
|
|||||||
p.put("build.variant.path", "");
|
p.put("build.variant.path", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build Time
|
||||||
|
Date d = new Date();
|
||||||
|
GregorianCalendar cal = new GregorianCalendar();
|
||||||
|
long current = d.getTime()/1000;
|
||||||
|
long timezone = cal.get(cal.ZONE_OFFSET)/1000;
|
||||||
|
long daylight = cal.get(cal.DST_OFFSET)/1000;
|
||||||
|
p.put("extra.time.utc", Long.toString(current));
|
||||||
|
p.put("extra.time.local", Long.toString(current + timezone + daylight));
|
||||||
|
p.put("extra.time.zone", Long.toString(timezone));
|
||||||
|
p.put("extra.time.dst", Long.toString(daylight));
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1124,6 +1161,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
void runRecipe(String recipe) throws RunnerException, PreferencesMapException {
|
void runRecipe(String recipe) throws RunnerException, PreferencesMapException {
|
||||||
PreferencesMap dict = new PreferencesMap(prefs);
|
PreferencesMap dict = new PreferencesMap(prefs);
|
||||||
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
||||||
|
dict.put("sketch_path", sketch.getFolder().getAbsolutePath());
|
||||||
|
|
||||||
String[] cmdArray;
|
String[] cmdArray;
|
||||||
String cmd = prefs.getOrExcept(recipe);
|
String cmd = prefs.getOrExcept(recipe);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user