From ab41198a9a3a9da3e04ca493fd245d0e87b4785c Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 4 Sep 2018 10:41:11 +0200 Subject: [PATCH 1/3] Avoid very long core archive names Fixes https://github.com/arduino/arduino-builder/issues/284 --- builder_utils/utils.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builder_utils/utils.go b/builder_utils/utils.go index 276cfd19..9b4cb536 100644 --- a/builder_utils/utils.go +++ b/builder_utils/utils.go @@ -558,5 +558,10 @@ func GetCachedCoreArchiveFileName(fqbn, coreFolder string) string { coreFolder = absCoreFolder } // silently continue if absolute path can't be detected hash := utils.MD5Sum([]byte(coreFolder)) - return "core_" + fqbnToUnderscore + "_" + hash + ".a" + realName := "core_" + fqbnToUnderscore + "_" + hash + ".a" + if len(realName) > 100 { + // avoid really long names, simply hash the final part + realName = "core_" + utils.MD5Sum([]byte(fqbnToUnderscore+"_"+hash)) + ".a" + } + return realName } From 2242b5c95e751f8ef22348fb07b112e66dc345d4 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 4 Sep 2018 10:41:32 +0200 Subject: [PATCH 2/3] Improve error reporting on core archive creation --- constants/constants.go | 1 + phases/core_builder.go | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/constants/constants.go b/constants/constants.go index 7254c2df..903ad693 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -154,6 +154,7 @@ const LOG_LEVEL_INFO = "info" const LOG_LEVEL_WARN = "warn" const MSG_ARCH_FOLDER_NOT_SUPPORTED = "'arch' folder is no longer supported! See http://goo.gl/gfFJzU for more information" const MSG_ARCHIVING_CORE_CACHE = "Archiving built core (caching) in: {0}" +const MSG_CORE_CACHE_UNAVAILABLE = "Unable to cache built core, please tell {0} maintainers to follow http://goo.gl/QdCUjo" const MSG_BOARD_UNKNOWN = "Board {0} (platform {1}, package {2}) is unknown" const MSG_BOOTLOADER_FILE_MISSING = "Bootloader file specified but missing: {0}" const MSG_BUILD_OPTIONS_CHANGED = "Build options changed, rebuilding all" diff --git a/phases/core_builder.go b/phases/core_builder.go index cecea3de..99d24666 100644 --- a/phases/core_builder.go +++ b/phases/core_builder.go @@ -124,10 +124,14 @@ func compileCore(ctx *types.Context, buildPath string, buildCachePath string, bu // archive core.a if targetArchivedCore != "" { + err := builder_utils.CopyFile(archiveFile, targetArchivedCore) if ctx.Verbose { - logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_ARCHIVING_CORE_CACHE, targetArchivedCore) + if err == nil { + logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_ARCHIVING_CORE_CACHE, targetArchivedCore) + } else { + logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_CORE_CACHE_UNAVAILABLE, ctx.ActualPlatform.PlatformId) + } } - builder_utils.CopyFile(archiveFile, targetArchivedCore) } return archiveFile, variantObjectFiles, nil From d2a559f3043f3ffb86014c8116884959f0afe8e7 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 7 Sep 2018 15:49:51 +0200 Subject: [PATCH 3/3] Complain core maintainers only when appropriate --- constants/constants.go | 1 + phases/core_builder.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/constants/constants.go b/constants/constants.go index 903ad693..cb512f25 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -154,6 +154,7 @@ const LOG_LEVEL_INFO = "info" const LOG_LEVEL_WARN = "warn" const MSG_ARCH_FOLDER_NOT_SUPPORTED = "'arch' folder is no longer supported! See http://goo.gl/gfFJzU for more information" const MSG_ARCHIVING_CORE_CACHE = "Archiving built core (caching) in: {0}" +const MSG_ERROR_ARCHIVING_CORE_CACHE = "Error archiving built core (caching) in {0}: {1}" const MSG_CORE_CACHE_UNAVAILABLE = "Unable to cache built core, please tell {0} maintainers to follow http://goo.gl/QdCUjo" const MSG_BOARD_UNKNOWN = "Board {0} (platform {1}, package {2}) is unknown" const MSG_BOOTLOADER_FILE_MISSING = "Bootloader file specified but missing: {0}" diff --git a/phases/core_builder.go b/phases/core_builder.go index 99d24666..ee5d9c72 100644 --- a/phases/core_builder.go +++ b/phases/core_builder.go @@ -30,6 +30,7 @@ package phases import ( + "os" "path/filepath" "github.com/arduino/arduino-builder/builder_utils" @@ -128,8 +129,10 @@ func compileCore(ctx *types.Context, buildPath string, buildCachePath string, bu if ctx.Verbose { if err == nil { logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_ARCHIVING_CORE_CACHE, targetArchivedCore) - } else { + } else if os.IsNotExist(err) { logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_CORE_CACHE_UNAVAILABLE, ctx.ActualPlatform.PlatformId) + } else { + logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_ERROR_ARCHIVING_CORE_CACHE, targetArchivedCore, err) } } }