Skip to content

Commit b4f2af4

Browse files
committed
Merge remote-tracking branch 'ide-1.5.x-core.a-rebuild' into ide-1.5.x
2 parents 841b264 + b783392 commit b4f2af4

File tree

2 files changed

+52
-15
lines changed

2 files changed

+52
-15
lines changed

app/src/processing/app/debug/Compiler.java

+50-15
Original file line numberDiff line numberDiff line change
@@ -718,28 +718,63 @@ void compileCore()
718718
if (variantFolder != null)
719719
includeFolders.add(variantFolder);
720720

721+
722+
if (variantFolder != null)
723+
objectFiles.addAll(compileFiles(buildFolder, variantFolder, true,
724+
includeFolders));
725+
726+
File afile = new File(buildFolder, "core.a");
727+
721728
List<File> coreObjectFiles = compileFiles(buildFolder, coreFolder, true,
722729
includeFolders);
723-
for (File file : coreObjectFiles) {
724730

725-
PreferencesMap dict = new PreferencesMap(prefs);
726-
dict.put("ide_version", "" + Base.REVISION);
727-
dict.put("archive_file", "core.a");
728-
dict.put("object_file", file.getAbsolutePath());
731+
// See if the .a file is already uptodate
732+
if (afile.exists()) {
733+
boolean changed = false;
734+
for (File file : coreObjectFiles) {
735+
if (file.lastModified() > afile.lastModified()) {
736+
changed = true;
737+
break;
738+
}
739+
}
729740

730-
String[] cmdArray;
731-
try {
732-
String cmd = prefs.get("recipe.ar.pattern");
733-
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
734-
} catch (Exception e) {
735-
throw new RunnerException(e);
741+
// If none of the object files is newer than the .a file, don't
742+
// bother rebuilding the .a file. There is a small corner case
743+
// here: If a source file was removed, but no other source file
744+
// was modified, this will not rebuild core.a even when it
745+
// should. It's hard to fix and not a realistic case, so it
746+
// shouldn't be a problem.
747+
if (!changed) {
748+
if (verbose)
749+
System.out.println(I18n.format(_("Using previously compiled file: {0}"), afile.getPath()));
750+
return;
736751
}
737-
execAsynchronously(cmdArray);
738752
}
739753

740-
if (variantFolder != null)
741-
objectFiles.addAll(compileFiles(buildFolder, variantFolder, true,
742-
includeFolders));
754+
// Delete the .a file, to prevent any previous code from lingering
755+
afile.delete();
756+
757+
try {
758+
for (File file : coreObjectFiles) {
759+
760+
PreferencesMap dict = new PreferencesMap(prefs);
761+
dict.put("ide_version", "" + Base.REVISION);
762+
dict.put("archive_file", afile.getName());
763+
dict.put("object_file", file.getAbsolutePath());
764+
765+
String[] cmdArray;
766+
try {
767+
String cmd = prefs.get("recipe.ar.pattern");
768+
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
769+
} catch (Exception e) {
770+
throw new RunnerException(e);
771+
}
772+
execAsynchronously(cmdArray);
773+
}
774+
} catch (RunnerException e) {
775+
afile.delete();
776+
throw e;
777+
}
743778
}
744779

745780
// 4. link it all together into the .elf file

build/shared/revisions.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
ARDUINO 1.5.9
33

44
[ide]
5+
* Sketch build process: fixed full rebuild on windows even if not needed
6+
* Sketch build process: core.a rebuild only if needed (Matthijs Kooijman)
57
* Updated AStyle formatter to v2.04: http://astyle.sourceforge.net/notes.html
68

79
[core]

0 commit comments

Comments
 (0)