Skip to content

Commit 269fb70

Browse files
committed
Use previously compiled "core.a" if core files are unmodified
Solves arduino#193 Needs to add -MMD to .S.flags targets on all cores (otherwise the core gets recompiled everytime) Signed-off-by: Martino Facchin <[email protected]>
1 parent eb6d705 commit 269fb70

File tree

1 file changed

+25
-4
lines changed
  • src/arduino.cc/builder/builder_utils

1 file changed

+25
-4
lines changed

src/arduino.cc/builder/builder_utils/utils.go

+25-4
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,31 @@ func nonEmptyString(s string) bool {
260260

261261
func ArchiveCompiledFiles(buildPath string, archiveFile string, objectFiles []string, buildProperties properties.Map, verbose bool, logger i18n.Logger) (string, error) {
262262
archiveFilePath := filepath.Join(buildPath, archiveFile)
263-
if _, err := os.Stat(archiveFilePath); err == nil {
264-
err = os.Remove(archiveFilePath)
265-
if err != nil {
266-
return "", i18n.WrapError(err)
263+
264+
rebuildArchive := false
265+
266+
if archiveFileStat, err := os.Stat(archiveFilePath); err == nil {
267+
268+
for _, objectFile := range objectFiles {
269+
objectFileStat, _ := os.Stat(objectFile)
270+
if objectFileStat.ModTime().After(archiveFileStat.ModTime()) {
271+
// need to rebuild the archive
272+
rebuildArchive = true
273+
break
274+
}
275+
}
276+
277+
// something changed, rebuild the core archive
278+
if rebuildArchive {
279+
err = os.Remove(archiveFilePath)
280+
if err != nil {
281+
return "", i18n.WrapError(err)
282+
}
283+
} else {
284+
if verbose {
285+
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_PREVIOUS_COMPILED_FILE, archiveFilePath)
286+
}
287+
return archiveFilePath, nil
267288
}
268289
}
269290

0 commit comments

Comments
 (0)