From c1002e247f50325ac649144cb31d889ae1efd557 Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Tue, 5 May 2015 12:32:49 -0700 Subject: [PATCH 1/2] Add build symbols for compile time and sketch path --- .../src/processing/app/debug/Compiler.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arduino-core/src/processing/app/debug/Compiler.java b/arduino-core/src/processing/app/debug/Compiler.java index 34edc08b0d9..37be0ee8518 100644 --- a/arduino-core/src/processing/app/debug/Compiler.java +++ b/arduino-core/src/processing/app/debug/Compiler.java @@ -34,6 +34,8 @@ import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; +import java.util.Date; +import java.util.GregorianCalendar; import cc.arduino.MyStreamPumper; import cc.arduino.packages.BoardPort; @@ -554,6 +556,17 @@ private PreferencesMap createBuildPreferences(String _buildPath, 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; } @@ -1124,6 +1137,7 @@ void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException void runRecipe(String recipe) throws RunnerException, PreferencesMapException { PreferencesMap dict = new PreferencesMap(prefs); dict.put("ide_version", "" + BaseNoGui.REVISION); + dict.put("sketch_path", sketch.getFolder().getAbsolutePath()); String[] cmdArray; String cmd = prefs.getOrExcept(recipe); From b11d54e5038f36192cf66074f2ee6cdcb20c5d26 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Tue, 26 May 2015 15:29:47 +0200 Subject: [PATCH 2/2] 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 --- .../src/processing/app/debug/Compiler.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/arduino-core/src/processing/app/debug/Compiler.java b/arduino-core/src/processing/app/debug/Compiler.java index 37be0ee8518..528b353aa88 100644 --- a/arduino-core/src/processing/app/debug/Compiler.java +++ b/arduino-core/src/processing/app/debug/Compiler.java @@ -405,26 +405,44 @@ public boolean compile(boolean _verbose, boolean _save) throws RunnerException, System.err.println(); } } - + + runActions("hooks.sketch.prebuild", prefs); + // 1. compile the sketch (already in the buildPath) progressListener.progress(20); compileSketch(includeFolders); sketchIsCompiled = true; + runActions("hooks.sketch.postbuild", prefs); + + runActions("hooks.libraries.prebuild", prefs); + // 2. compile the libraries, outputting .o files to: // // Doesn't really use configPreferences progressListener.progress(30); compileLibraries(includeFolders); + runActions("hooks.libraries.postbuild", prefs); + + runActions("hooks.core.prebuild", prefs); + // 3. compile the core, outputting .o files to and then // collecting them into the core.a library file. progressListener.progress(40); compileCore(); + runActions("hooks.core.postbuild", prefs); + + runActions("hooks.linking.prelink", prefs); + // 4. link it all together into the .elf file progressListener.progress(50); compileLink(); + runActions("hooks.linking.postlink", prefs); + + runActions("hooks.objcopy.preobjcopy", prefs); + // 5. run objcopy to generate output files progressListener.progress(60); List objcopyPatterns = new ArrayList(); @@ -437,10 +455,16 @@ public boolean compile(boolean _verbose, boolean _save) throws RunnerException, runRecipe(recipe); } + runActions("hooks.objcopy.postobjcopy", prefs); + // 7. save the hex file if (saveHex) { + runActions("hooks.savehex.presavehex", prefs); + progressListener.progress(80); saveHex(); + + runActions("hooks.savehex.postsavehex", prefs); } progressListener.progress(90);