Skip to content

Commit 68dcd24

Browse files
committed
Fix i18n and syncing problems
1 parent 7fdae39 commit 68dcd24

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

+14-8
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ package phases
3131

3232
import (
3333
"errors"
34-
"os"
3534
"regexp"
3635
"strconv"
36+
"time"
3737

3838
"arduino.cc/builder/builder_utils"
3939
"arduino.cc/builder/constants"
@@ -52,6 +52,9 @@ func (s *Sizer) Run(ctx *types.Context) error {
5252

5353
err := checkSize(buildProperties, verbose, warningsLevel, logger)
5454
if err != nil {
55+
// HACK: we are bailing out badly and we just wrote on stdout,
56+
// wait 200 ms to let the IDE's MessageSiphon flush
57+
time.Sleep(200 * time.Millisecond)
5558
return i18n.WrapError(err)
5659
}
5760

@@ -86,27 +89,29 @@ func checkSize(buildProperties properties.Map, verbose bool, warningsLevel strin
8689
return err
8790
}
8891

89-
logger.Fprintln(os.Stdout, logLevel, "Sketch uses {0} bytes ({2}%%) of program storage space. Maximum is {1} bytes.", strconv.Itoa(textSize), strconv.Itoa(maxTextSize), strconv.Itoa(textSize*100/maxTextSize))
92+
logger.Println(logLevel, "Sketch uses {0} bytes ({2}%%) of program storage space. Maximum is {1} bytes.", strconv.Itoa(textSize), strconv.Itoa(maxTextSize), strconv.Itoa(textSize*100/maxTextSize))
9093
if dataSize > 0 {
9194
if maxDataSize > 0 {
92-
logger.Fprintln(os.Stdout, logLevel, "Global variables use {0} bytes ({2}%%) of dynamic memory, leaving {3} bytes for local variables. Maximum is {1} bytes.", strconv.Itoa(dataSize), strconv.Itoa(maxDataSize), strconv.Itoa(dataSize*100/maxDataSize), strconv.Itoa(maxDataSize-dataSize))
95+
logger.Println(logLevel, "Global variables use {0} bytes ({2}%%) of dynamic memory, leaving {3} bytes for local variables. Maximum is {1} bytes.", strconv.Itoa(dataSize), strconv.Itoa(maxDataSize), strconv.Itoa(dataSize*100/maxDataSize), strconv.Itoa(maxDataSize-dataSize))
9396
} else {
94-
logger.Fprintln(os.Stdout, logLevel, "Global variables use {0} bytes of dynamic memory.", strconv.Itoa(dataSize))
97+
logger.Println(logLevel, "Global variables use {0} bytes of dynamic memory.", strconv.Itoa(dataSize))
9598
}
9699
}
97100

98101
if textSize > maxTextSize {
99-
return errors.New("Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.")
102+
i18n.ErrorfWithLogger(logger, "Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.")
103+
return errors.New("")
100104
}
101105

102106
if maxDataSize > 0 && dataSize > maxDataSize {
103-
return errors.New("Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.")
107+
i18n.ErrorfWithLogger(logger, "Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.")
108+
return errors.New("")
104109
}
105110

106111
if properties["build.warn_data_percentage"] != "" {
107112
warnDataPercentage, _ := strconv.Atoi(properties["build.warn_data_percentage"])
108113
if maxDataSize > 0 && dataSize > maxDataSize*warnDataPercentage/100 {
109-
logger.Fprintln(os.Stdout, logLevel, "Low memory available, stability problems may occur.")
114+
logger.Println(logLevel, "Low memory available, stability problems may occur.")
110115
}
111116
}
112117

@@ -118,7 +123,8 @@ func execSizeReceipe(properties properties.Map, logger i18n.Logger, textSize *in
118123
out, err := builder_utils.ExecRecipe(properties, constants.RECIPE_SIZE_PATTERN, false, false, false, logger)
119124

120125
if err != nil {
121-
return errors.New("Couldn't determine program size: {0}")
126+
i18n.ErrorfWithLogger(logger, "Couldn't determine program size")
127+
return errors.New("")
122128
}
123129

124130
// force multiline match prepending "(?m)" to the actual regexp

0 commit comments

Comments
 (0)