Skip to content

Commit 008e46e

Browse files
author
Federico Fissore
committed
Printing used and not used libraries despite of the success or failure of
compilation. Fixes #40 Signed-off-by: Federico Fissore <[email protected]>
1 parent 241ab69 commit 008e46e

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

Diff for: src/arduino.cc/builder/builder.go

+19-6
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,22 @@ func (s *Builder) Run(context map[string]interface{}) error {
110110
&MergeSketchWithBootloader{},
111111

112112
&RecipeByPrefixSuffixRunner{Prefix: constants.HOOKS_POSTBUILD, Suffix: constants.HOOKS_PATTERN_SUFFIX},
113+
}
114+
115+
mainErr := runCommands(context, commands, true)
113116

117+
commands = []types.Command{
114118
&PrintUsedAndNotUsedLibraries{},
115119

116120
&PrintUsedLibrariesIfVerbose{},
117121
}
122+
otherErr := runCommands(context, commands, false)
123+
124+
if mainErr != nil {
125+
return mainErr
126+
}
118127

119-
return runCommands(context, commands)
128+
return otherErr
120129
}
121130

122131
type ParseHardwareAndDumpBuildProperties struct{}
@@ -132,30 +141,34 @@ func (s *ParseHardwareAndDumpBuildProperties) Run(context map[string]interface{}
132141
&DumpBuildProperties{},
133142
}
134143

135-
return runCommands(context, commands)
144+
return runCommands(context, commands, true)
136145
}
137146

138-
func runCommands(context map[string]interface{}, commands []types.Command) error {
147+
func runCommands(context map[string]interface{}, commands []types.Command, progressEnabled bool) error {
139148
commandsLength := len(commands)
140149
progressForEachCommand := float32(100) / float32(commandsLength)
141150

142151
progress := float32(0)
143152
for _, command := range commands {
144153
PrintRingNameIfDebug(context, command)
145-
printProgressIfMachineLogger(context, progress)
154+
printProgressIfProgressEnabledAndMachineLogger(progressEnabled, context, progress)
146155
err := command.Run(context)
147156
if err != nil {
148157
return utils.WrapError(err)
149158
}
150159
progress += progressForEachCommand
151160
}
152161

153-
printProgressIfMachineLogger(context, 100)
162+
printProgressIfProgressEnabledAndMachineLogger(progressEnabled, context, 100)
154163

155164
return nil
156165
}
157166

158-
func printProgressIfMachineLogger(context map[string]interface{}, progress float32) {
167+
func printProgressIfProgressEnabledAndMachineLogger(progressEnabled bool, context map[string]interface{}, progress float32) {
168+
if !progressEnabled {
169+
return
170+
}
171+
159172
log := utils.Logger(context)
160173
if log.Name() == "machine" {
161174
log.Println(constants.MSG_PROGRESS, strconv.FormatFloat(float64(progress), 'f', 2, 32))

0 commit comments

Comments
 (0)