Skip to content

Commit 886590e

Browse files
committed
Merge pull request #3236 from ffissore/build-hooks
Additional build hooks
2 parents 5490b96 + b11d54e commit 886590e

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import java.util.Map;
3535
import java.util.SortedSet;
3636
import java.util.TreeSet;
37+
import java.util.Date;
38+
import java.util.GregorianCalendar;
3739

3840
import cc.arduino.MyStreamPumper;
3941
import cc.arduino.packages.BoardPort;
@@ -403,26 +405,44 @@ public boolean compile(boolean _verbose, boolean _save) throws RunnerException,
403405
System.err.println();
404406
}
405407
}
406-
408+
409+
runActions("hooks.sketch.prebuild", prefs);
410+
407411
// 1. compile the sketch (already in the buildPath)
408412
progressListener.progress(20);
409413
compileSketch(includeFolders);
410414
sketchIsCompiled = true;
411415

416+
runActions("hooks.sketch.postbuild", prefs);
417+
418+
runActions("hooks.libraries.prebuild", prefs);
419+
412420
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
413421
// Doesn't really use configPreferences
414422
progressListener.progress(30);
415423
compileLibraries(includeFolders);
416424

425+
runActions("hooks.libraries.postbuild", prefs);
426+
427+
runActions("hooks.core.prebuild", prefs);
428+
417429
// 3. compile the core, outputting .o files to <buildPath> and then
418430
// collecting them into the core.a library file.
419431
progressListener.progress(40);
420432
compileCore();
421433

434+
runActions("hooks.core.postbuild", prefs);
435+
436+
runActions("hooks.linking.prelink", prefs);
437+
422438
// 4. link it all together into the .elf file
423439
progressListener.progress(50);
424440
compileLink();
425441

442+
runActions("hooks.linking.postlink", prefs);
443+
444+
runActions("hooks.objcopy.preobjcopy", prefs);
445+
426446
// 5. run objcopy to generate output files
427447
progressListener.progress(60);
428448
List<String> objcopyPatterns = new ArrayList<String>();
@@ -435,10 +455,16 @@ public boolean compile(boolean _verbose, boolean _save) throws RunnerException,
435455
runRecipe(recipe);
436456
}
437457

458+
runActions("hooks.objcopy.postobjcopy", prefs);
459+
438460
// 7. save the hex file
439461
if (saveHex) {
462+
runActions("hooks.savehex.presavehex", prefs);
463+
440464
progressListener.progress(80);
441465
saveHex();
466+
467+
runActions("hooks.savehex.postsavehex", prefs);
442468
}
443469

444470
progressListener.progress(90);
@@ -554,6 +580,17 @@ private PreferencesMap createBuildPreferences(String _buildPath,
554580
p.put("build.variant.path", "");
555581
}
556582

583+
// Build Time
584+
Date d = new Date();
585+
GregorianCalendar cal = new GregorianCalendar();
586+
long current = d.getTime()/1000;
587+
long timezone = cal.get(cal.ZONE_OFFSET)/1000;
588+
long daylight = cal.get(cal.DST_OFFSET)/1000;
589+
p.put("extra.time.utc", Long.toString(current));
590+
p.put("extra.time.local", Long.toString(current + timezone + daylight));
591+
p.put("extra.time.zone", Long.toString(timezone));
592+
p.put("extra.time.dst", Long.toString(daylight));
593+
557594
return p;
558595
}
559596

@@ -1124,6 +1161,7 @@ void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException
11241161
void runRecipe(String recipe) throws RunnerException, PreferencesMapException {
11251162
PreferencesMap dict = new PreferencesMap(prefs);
11261163
dict.put("ide_version", "" + BaseNoGui.REVISION);
1164+
dict.put("sketch_path", sketch.getFolder().getAbsolutePath());
11271165

11281166
String[] cmdArray;
11291167
String cmd = prefs.getOrExcept(recipe);

0 commit comments

Comments
 (0)