Skip to content

Commit f3748a5

Browse files
authored
Merge pull request #288 from facchinm/improve_core_archive_info
Improve core archive info
2 parents f432aa3 + d2a559f commit f3748a5

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

builder_utils/utils.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,5 +558,10 @@ func GetCachedCoreArchiveFileName(fqbn, coreFolder string) string {
558558
coreFolder = absCoreFolder
559559
} // silently continue if absolute path can't be detected
560560
hash := utils.MD5Sum([]byte(coreFolder))
561-
return "core_" + fqbnToUnderscore + "_" + hash + ".a"
561+
realName := "core_" + fqbnToUnderscore + "_" + hash + ".a"
562+
if len(realName) > 100 {
563+
// avoid really long names, simply hash the final part
564+
realName = "core_" + utils.MD5Sum([]byte(fqbnToUnderscore+"_"+hash)) + ".a"
565+
}
566+
return realName
562567
}

constants/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ const LOG_LEVEL_INFO = "info"
154154
const LOG_LEVEL_WARN = "warn"
155155
const MSG_ARCH_FOLDER_NOT_SUPPORTED = "'arch' folder is no longer supported! See http://goo.gl/gfFJzU for more information"
156156
const MSG_ARCHIVING_CORE_CACHE = "Archiving built core (caching) in: {0}"
157+
const MSG_ERROR_ARCHIVING_CORE_CACHE = "Error archiving built core (caching) in {0}: {1}"
158+
const MSG_CORE_CACHE_UNAVAILABLE = "Unable to cache built core, please tell {0} maintainers to follow http://goo.gl/QdCUjo"
157159
const MSG_BOARD_UNKNOWN = "Board {0} (platform {1}, package {2}) is unknown"
158160
const MSG_BOOTLOADER_FILE_MISSING = "Bootloader file specified but missing: {0}"
159161
const MSG_BUILD_OPTIONS_CHANGED = "Build options changed, rebuilding all"

phases/core_builder.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
package phases
3131

3232
import (
33+
"os"
3334
"path/filepath"
3435

3536
"github.com/arduino/arduino-builder/builder_utils"
@@ -124,10 +125,16 @@ func compileCore(ctx *types.Context, buildPath string, buildCachePath string, bu
124125

125126
// archive core.a
126127
if targetArchivedCore != "" {
128+
err := builder_utils.CopyFile(archiveFile, targetArchivedCore)
127129
if ctx.Verbose {
128-
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_ARCHIVING_CORE_CACHE, targetArchivedCore)
130+
if err == nil {
131+
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_ARCHIVING_CORE_CACHE, targetArchivedCore)
132+
} else if os.IsNotExist(err) {
133+
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_CORE_CACHE_UNAVAILABLE, ctx.ActualPlatform.PlatformId)
134+
} else {
135+
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_ERROR_ARCHIVING_CORE_CACHE, targetArchivedCore, err)
136+
}
129137
}
130-
builder_utils.CopyFile(archiveFile, targetArchivedCore)
131138
}
132139

133140
return archiveFile, variantObjectFiles, nil

0 commit comments

Comments
 (0)