34
34
import java .util .Map ;
35
35
import java .util .SortedSet ;
36
36
import java .util .TreeSet ;
37
+ import java .util .Date ;
38
+ import java .util .GregorianCalendar ;
37
39
38
40
import cc .arduino .MyStreamPumper ;
39
41
import cc .arduino .packages .BoardPort ;
@@ -403,26 +405,44 @@ public boolean compile(boolean _verbose, boolean _save) throws RunnerException,
403
405
System .err .println ();
404
406
}
405
407
}
406
-
408
+
409
+ runActions ("hooks.sketch.prebuild" , prefs );
410
+
407
411
// 1. compile the sketch (already in the buildPath)
408
412
progressListener .progress (20 );
409
413
compileSketch (includeFolders );
410
414
sketchIsCompiled = true ;
411
415
416
+ runActions ("hooks.sketch.postbuild" , prefs );
417
+
418
+ runActions ("hooks.libraries.prebuild" , prefs );
419
+
412
420
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
413
421
// Doesn't really use configPreferences
414
422
progressListener .progress (30 );
415
423
compileLibraries (includeFolders );
416
424
425
+ runActions ("hooks.libraries.postbuild" , prefs );
426
+
427
+ runActions ("hooks.core.prebuild" , prefs );
428
+
417
429
// 3. compile the core, outputting .o files to <buildPath> and then
418
430
// collecting them into the core.a library file.
419
431
progressListener .progress (40 );
420
432
compileCore ();
421
433
434
+ runActions ("hooks.core.postbuild" , prefs );
435
+
436
+ runActions ("hooks.linking.prelink" , prefs );
437
+
422
438
// 4. link it all together into the .elf file
423
439
progressListener .progress (50 );
424
440
compileLink ();
425
441
442
+ runActions ("hooks.linking.postlink" , prefs );
443
+
444
+ runActions ("hooks.objcopy.preobjcopy" , prefs );
445
+
426
446
// 5. run objcopy to generate output files
427
447
progressListener .progress (60 );
428
448
List <String > objcopyPatterns = new ArrayList <String >();
@@ -435,10 +455,16 @@ public boolean compile(boolean _verbose, boolean _save) throws RunnerException,
435
455
runRecipe (recipe );
436
456
}
437
457
458
+ runActions ("hooks.objcopy.postobjcopy" , prefs );
459
+
438
460
// 7. save the hex file
439
461
if (saveHex ) {
462
+ runActions ("hooks.savehex.presavehex" , prefs );
463
+
440
464
progressListener .progress (80 );
441
465
saveHex ();
466
+
467
+ runActions ("hooks.savehex.postsavehex" , prefs );
442
468
}
443
469
444
470
progressListener .progress (90 );
@@ -554,6 +580,17 @@ private PreferencesMap createBuildPreferences(String _buildPath,
554
580
p .put ("build.variant.path" , "" );
555
581
}
556
582
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
+
557
594
return p ;
558
595
}
559
596
@@ -1124,6 +1161,7 @@ void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException
1124
1161
void runRecipe (String recipe ) throws RunnerException , PreferencesMapException {
1125
1162
PreferencesMap dict = new PreferencesMap (prefs );
1126
1163
dict .put ("ide_version" , "" + BaseNoGui .REVISION );
1164
+ dict .put ("sketch_path" , sketch .getFolder ().getAbsolutePath ());
1127
1165
1128
1166
String [] cmdArray ;
1129
1167
String cmd = prefs .getOrExcept (recipe );
0 commit comments