From 231a80bfe159b04b966883a69ec2f0fb0be38740 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 27 Apr 2016 13:27:18 +0200 Subject: [PATCH 1/2] Log some informative progress messages Before, only commands were logged (in verbose mode). However, all commands look similar and it is not quite clear what happens where. By adding some more informative messages, the commands are logically grouped and it is more clear what is happening exactly, which should also help users understand what is wrong when a command fails. Signed-off-by: Matthijs Kooijman --- src/arduino.cc/builder/builder.go | 7 ++++++ .../builder/phases/libraries_builder.go | 3 +++ src/arduino.cc/builder/utils/utils.go | 23 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/arduino.cc/builder/builder.go b/src/arduino.cc/builder/builder.go index 7e9d08a9..f2031ece 100644 --- a/src/arduino.cc/builder/builder.go +++ b/src/arduino.cc/builder/builder.go @@ -34,6 +34,7 @@ import ( "arduino.cc/builder/i18n" "arduino.cc/builder/phases" "arduino.cc/builder/types" + "arduino.cc/builder/utils" "os" "reflect" "strconv" @@ -81,25 +82,31 @@ func (s *Builder) Run(ctx *types.Context) error { &ContainerMergeCopySketchFiles{}, + utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Detecting libraries used..."), &ContainerFindIncludes{}, &WarnAboutArchIncompatibleLibraries{}, + utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Generating function prototypes..."), &ContainerAddPrototypes{}, + utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Compiling sketch..."), &RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_SKETCH_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX}, &phases.SketchBuilder{}, &RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_SKETCH_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX}, + utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Compiling libraries..."), &RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LIBRARIES_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX}, &UnusedCompiledLibrariesRemover{}, &phases.LibrariesBuilder{}, &RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LIBRARIES_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX}, + utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Compiling core..."), &RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_CORE_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX}, &phases.CoreBuilder{}, &RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_CORE_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX}, + utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Linking everything together..."), &RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LINKING_PRELINK, Suffix: constants.HOOKS_PATTERN_SUFFIX}, &phases.Linker{}, &RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LINKING_POSTLINK, Suffix: constants.HOOKS_PATTERN_SUFFIX}, diff --git a/src/arduino.cc/builder/phases/libraries_builder.go b/src/arduino.cc/builder/phases/libraries_builder.go index 5ebd9c6b..d78d3ec2 100644 --- a/src/arduino.cc/builder/phases/libraries_builder.go +++ b/src/arduino.cc/builder/phases/libraries_builder.go @@ -82,6 +82,9 @@ func compileLibraries(libraries []*types.Library, buildPath string, buildPropert } func compileLibrary(library *types.Library, buildPath string, buildProperties props.PropertiesMap, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) { + if verbose { + logger.Println(constants.LOG_LEVEL_INFO, "Compiling library \"{0}\"", library.Name) + } libraryBuildPath := filepath.Join(buildPath, library.Name) err := utils.EnsureFolderExists(libraryBuildPath) diff --git a/src/arduino.cc/builder/utils/utils.go b/src/arduino.cc/builder/utils/utils.go index 16a11d18..3f8898f3 100644 --- a/src/arduino.cc/builder/utils/utils.go +++ b/src/arduino.cc/builder/utils/utils.go @@ -33,6 +33,7 @@ import ( "arduino.cc/builder/constants" "arduino.cc/builder/gohasissues" "arduino.cc/builder/i18n" + "arduino.cc/builder/types" "crypto/md5" "encoding/hex" "io/ioutil" @@ -366,3 +367,25 @@ func MD5Sum(data []byte) string { md5sumBytes := md5.Sum(data) return hex.EncodeToString(md5sumBytes[:]) } + +type loggerAction struct { + onlyIfVerbose bool + level string + format string + args []interface{} +} + +func (l *loggerAction) Run(ctx *types.Context) error { + if !l.onlyIfVerbose || ctx.Verbose { + ctx.GetLogger().Println(l.level, l.format, l.args...) + } + return nil +} + +func LogIfVerbose(level string, format string, args ...interface{}) types.Command { + return &loggerAction{true, level, format, args} +} + +func LogThis(level string, format string, args ...interface{}) types.Command { + return &loggerAction{false, level, format, args} +} From 57c8c5b44f9a19590f3065f8019482156885e409 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 18 May 2016 16:19:31 +0200 Subject: [PATCH 2/2] Log messages about the platforms used in compilation This should help debugging problems based on verbose compilation output, especially if third-party boards and/or cores are involved. For example, this might output: Using board 'pinoccio' from platform in folder: /path/to/sketchbook/hardware/pinoccio/avr Using core 'arduino' from platform in folder: /path/to/arduino/hardware/arduino/avr Signed-off-by: Matthijs Kooijman --- src/arduino.cc/builder/constants/constants.go | 2 ++ src/arduino.cc/builder/target_board_resolver.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/arduino.cc/builder/constants/constants.go b/src/arduino.cc/builder/constants/constants.go index 90bff350..c9efbca5 100644 --- a/src/arduino.cc/builder/constants/constants.go +++ b/src/arduino.cc/builder/constants/constants.go @@ -177,6 +177,8 @@ const MSG_UNHANDLED_TYPE_IN_CONTEXT = "Unhandled type {0} in context key {1}" const MSG_UNKNOWN_SKETCH_EXT = "Unknown sketch file extension: {0}" const MSG_USING_LIBRARY_AT_VERSION = "Using library {0} at version {1} in folder: {2} {3}" const MSG_USING_LIBRARY = "Using library {0} in folder: {1} {2}" +const MSG_USING_BOARD = "Using board '{0}' from platform in folder: {1}" +const MSG_USING_CORE = "Using core '{0}' from platform in folder: {1}" const MSG_USING_PREVIOUS_COMPILED_FILE = "Using previously compiled file: {0}" const MSG_WARNING_LIB_INVALID_CATEGORY = "WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}'" const MSG_WARNING_PLATFORM_MISSING_VALUE = "Warning: platform.txt from core '{0}' misses property '{1}', using default value '{2}'. Consider upgrading this core." diff --git a/src/arduino.cc/builder/target_board_resolver.go b/src/arduino.cc/builder/target_board_resolver.go index b8f9b312..0484c3c9 100644 --- a/src/arduino.cc/builder/target_board_resolver.go +++ b/src/arduino.cc/builder/target_board_resolver.go @@ -100,6 +100,11 @@ func (s *TargetBoardResolver) Run(ctx *types.Context) error { actualPlatform = targetPlatform } + if ctx.Verbose { + logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_BOARD, targetBoard.BoardId, targetPlatform.Folder) + logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_CORE, core, actualPlatform.Folder) + } + ctx.BuildCore = core ctx.ActualPlatform = actualPlatform