Skip to content

Add some messages during verbose compilation #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/arduino.cc/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"arduino.cc/builder/i18n"
"arduino.cc/builder/phases"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"os"
"reflect"
"strconv"
Expand Down Expand Up @@ -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},
Expand Down
2 changes: 2 additions & 0 deletions src/arduino.cc/builder/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
3 changes: 3 additions & 0 deletions src/arduino.cc/builder/phases/libraries_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/arduino.cc/builder/target_board_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions src/arduino.cc/builder/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}
}