Skip to content

Commit 6183f3b

Browse files
committed
Signed-off-by: Cristian Maglie <[email protected]>
2 parents 405a24a + 57c8c5b commit 6183f3b

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

src/arduino.cc/builder/builder.go

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"arduino.cc/builder/i18n"
3535
"arduino.cc/builder/phases"
3636
"arduino.cc/builder/types"
37+
"arduino.cc/builder/utils"
3738
"os"
3839
"reflect"
3940
"strconv"
@@ -81,25 +82,31 @@ func (s *Builder) Run(ctx *types.Context) error {
8182

8283
&ContainerMergeCopySketchFiles{},
8384

85+
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Detecting libraries used..."),
8486
&ContainerFindIncludes{},
8587

8688
&WarnAboutArchIncompatibleLibraries{},
8789

90+
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Generating function prototypes..."),
8891
&ContainerAddPrototypes{},
8992

93+
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Compiling sketch..."),
9094
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_SKETCH_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
9195
&phases.SketchBuilder{},
9296
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_SKETCH_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
9397

98+
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Compiling libraries..."),
9499
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LIBRARIES_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
95100
&UnusedCompiledLibrariesRemover{},
96101
&phases.LibrariesBuilder{},
97102
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LIBRARIES_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
98103

104+
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Compiling core..."),
99105
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_CORE_PREBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
100106
&phases.CoreBuilder{},
101107
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_CORE_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
102108

109+
utils.LogIfVerbose(constants.LOG_LEVEL_INFO, "Linking everything together..."),
103110
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LINKING_PRELINK, Suffix: constants.HOOKS_PATTERN_SUFFIX},
104111
&phases.Linker{},
105112
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_LINKING_POSTLINK, Suffix: constants.HOOKS_PATTERN_SUFFIX},

src/arduino.cc/builder/constants/constants.go

+2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ const MSG_UNHANDLED_TYPE_IN_CONTEXT = "Unhandled type {0} in context key {1}"
177177
const MSG_UNKNOWN_SKETCH_EXT = "Unknown sketch file extension: {0}"
178178
const MSG_USING_LIBRARY_AT_VERSION = "Using library {0} at version {1} in folder: {2} {3}"
179179
const MSG_USING_LIBRARY = "Using library {0} in folder: {1} {2}"
180+
const MSG_USING_BOARD = "Using board '{0}' from platform in folder: {1}"
181+
const MSG_USING_CORE = "Using core '{0}' from platform in folder: {1}"
180182
const MSG_USING_PREVIOUS_COMPILED_FILE = "Using previously compiled file: {0}"
181183
const MSG_WARNING_LIB_INVALID_CATEGORY = "WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}'"
182184
const MSG_WARNING_PLATFORM_MISSING_VALUE = "Warning: platform.txt from core '{0}' misses property '{1}', using default value '{2}'. Consider upgrading this core."

src/arduino.cc/builder/phases/libraries_builder.go

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ func compileLibraries(libraries []*types.Library, buildPath string, buildPropert
8282
}
8383

8484
func compileLibrary(library *types.Library, buildPath string, buildProperties props.PropertiesMap, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) {
85+
if verbose {
86+
logger.Println(constants.LOG_LEVEL_INFO, "Compiling library \"{0}\"", library.Name)
87+
}
8588
libraryBuildPath := filepath.Join(buildPath, library.Name)
8689

8790
err := utils.EnsureFolderExists(libraryBuildPath)

src/arduino.cc/builder/target_board_resolver.go

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ func (s *TargetBoardResolver) Run(ctx *types.Context) error {
100100
actualPlatform = targetPlatform
101101
}
102102

103+
if ctx.Verbose {
104+
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_BOARD, targetBoard.BoardId, targetPlatform.Folder)
105+
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_CORE, core, actualPlatform.Folder)
106+
}
107+
103108
ctx.BuildCore = core
104109
ctx.ActualPlatform = actualPlatform
105110

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

+23
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"arduino.cc/builder/constants"
3434
"arduino.cc/builder/gohasissues"
3535
"arduino.cc/builder/i18n"
36+
"arduino.cc/builder/types"
3637
"crypto/md5"
3738
"encoding/hex"
3839
"io/ioutil"
@@ -384,3 +385,25 @@ func MD5Sum(data []byte) string {
384385
md5sumBytes := md5.Sum(data)
385386
return hex.EncodeToString(md5sumBytes[:])
386387
}
388+
389+
type loggerAction struct {
390+
onlyIfVerbose bool
391+
level string
392+
format string
393+
args []interface{}
394+
}
395+
396+
func (l *loggerAction) Run(ctx *types.Context) error {
397+
if !l.onlyIfVerbose || ctx.Verbose {
398+
ctx.GetLogger().Println(l.level, l.format, l.args...)
399+
}
400+
return nil
401+
}
402+
403+
func LogIfVerbose(level string, format string, args ...interface{}) types.Command {
404+
return &loggerAction{true, level, format, args}
405+
}
406+
407+
func LogThis(level string, format string, args ...interface{}) types.Command {
408+
return &loggerAction{false, level, format, args}
409+
}

0 commit comments

Comments
 (0)