@@ -20,7 +20,6 @@ import (
20
20
"strconv"
21
21
22
22
"github.com/arduino/arduino-cli/legacy/builder/builder_utils"
23
- "github.com/arduino/arduino-cli/legacy/builder/constants"
24
23
"github.com/arduino/arduino-cli/legacy/builder/types"
25
24
"github.com/arduino/arduino-cli/legacy/builder/utils"
26
25
"github.com/arduino/go-properties-orderedmap"
@@ -53,10 +52,10 @@ func checkSize(ctx *types.Context, buildProperties *properties.Map) error {
53
52
logger := ctx .GetLogger ()
54
53
55
54
properties := buildProperties .Clone ()
56
- properties .Set (constants . BUILD_PROPERTIES_COMPILER_WARNING_FLAGS , properties .Get (constants . BUILD_PROPERTIES_COMPILER_WARNING_FLAGS + " ."+ ctx .WarningsLevel ))
55
+ properties .Set ("compiler.warning_flags" , properties .Get ("compiler.warning_flags ."+ ctx .WarningsLevel ))
57
56
58
- maxTextSizeString := properties .Get (constants . PROPERTY_UPLOAD_MAX_SIZE )
59
- maxDataSizeString := properties .Get (constants . PROPERTY_UPLOAD_MAX_DATA_SIZE )
57
+ maxTextSizeString := properties .Get ("upload.maximum_size" )
58
+ maxDataSizeString := properties .Get ("upload.maximum_data_size" )
60
59
61
60
if maxTextSizeString == "" {
62
61
return nil
@@ -77,16 +76,22 @@ func checkSize(ctx *types.Context, buildProperties *properties.Map) error {
77
76
78
77
textSize , dataSize , _ , err := execSizeRecipe (ctx , properties )
79
78
if err != nil {
80
- logger .Println (constants . LOG_LEVEL_WARN , constants . MSG_SIZER_ERROR_NO_RULE )
79
+ logger .Println ("warn" , "Couldn't determine program size" )
81
80
return nil
82
81
}
83
82
84
- logger .Println (constants .LOG_LEVEL_INFO , constants .MSG_SIZER_TEXT_FULL , strconv .Itoa (textSize ), strconv .Itoa (maxTextSize ), strconv .Itoa (textSize * 100 / maxTextSize ))
83
+ logger .Println ("info" ,
84
+ "Sketch uses {0} bytes ({2}%%) of program storage space. Maximum is {1} bytes." ,
85
+ strconv .Itoa (textSize ), strconv .Itoa (maxTextSize ), strconv .Itoa (textSize * 100 / maxTextSize ))
85
86
if dataSize >= 0 {
86
87
if maxDataSize > 0 {
87
- logger .Println (constants .LOG_LEVEL_INFO , constants .MSG_SIZER_DATA_FULL , strconv .Itoa (dataSize ), strconv .Itoa (maxDataSize ), strconv .Itoa (dataSize * 100 / maxDataSize ), strconv .Itoa (maxDataSize - dataSize ))
88
+ logger .Println ("info" ,
89
+ "Global variables use {0} bytes ({2}%%) of dynamic memory, leaving {3} bytes for local variables. Maximum is {1} bytes." ,
90
+ strconv .Itoa (dataSize ), strconv .Itoa (maxDataSize ), strconv .Itoa (dataSize * 100 / maxDataSize ), strconv .Itoa (maxDataSize - dataSize ))
88
91
} else {
89
- logger .Println (constants .LOG_LEVEL_INFO , constants .MSG_SIZER_DATA , strconv .Itoa (dataSize ))
92
+ logger .Println ("info" ,
93
+ "Global variables use {0} bytes of dynamic memory." ,
94
+ strconv .Itoa (dataSize ))
90
95
}
91
96
}
92
97
@@ -106,30 +111,30 @@ func checkSize(ctx *types.Context, buildProperties *properties.Map) error {
106
111
}
107
112
108
113
if textSize > maxTextSize {
109
- logger .Println (constants . LOG_LEVEL_ERROR , constants . MSG_SIZER_TEXT_TOO_BIG )
114
+ logger .Println ("error" , "Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it." )
110
115
return errors .New ("text section exceeds available space in board" )
111
116
}
112
117
113
118
if maxDataSize > 0 && dataSize > maxDataSize {
114
- logger .Println (constants . LOG_LEVEL_ERROR , constants . MSG_SIZER_DATA_TOO_BIG )
119
+ logger .Println ("error" , "Not enough memory; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing your footprint." )
115
120
return errors .New ("data section exceeds available space in board" )
116
121
}
117
122
118
- if properties .Get (constants . PROPERTY_WARN_DATA_PERCENT ) != "" {
119
- warnDataPercentage , err := strconv .Atoi (properties . Get ( constants . PROPERTY_WARN_DATA_PERCENT ) )
123
+ if w := properties .Get ("build.warn_data_percentage" ); w != "" {
124
+ warnDataPercentage , err := strconv .Atoi (w )
120
125
if err != nil {
121
126
return err
122
127
}
123
128
if maxDataSize > 0 && dataSize > maxDataSize * warnDataPercentage / 100 {
124
- logger .Println (constants . LOG_LEVEL_WARN , constants . MSG_SIZER_LOW_MEMORY )
129
+ logger .Println ("warn" , "Low memory available, stability problems may occur." )
125
130
}
126
131
}
127
132
128
133
return nil
129
134
}
130
135
131
136
func execSizeRecipe (ctx * types.Context , properties * properties.Map ) (textSize int , dataSize int , eepromSize int , resErr error ) {
132
- command , err := builder_utils .PrepareCommandForRecipe (properties , constants . RECIPE_SIZE_PATTERN , false )
137
+ command , err := builder_utils .PrepareCommandForRecipe (properties , "recipe.size.pattern" , false )
133
138
if err != nil {
134
139
resErr = errors .New ("Error while determining sketch size: " + err .Error ())
135
140
return
@@ -144,7 +149,7 @@ func execSizeRecipe(ctx *types.Context, properties *properties.Map) (textSize in
144
149
// force multiline match prepending "(?m)" to the actual regexp
145
150
// return an error if RECIPE_SIZE_REGEXP doesn't exist
146
151
147
- textSize , err = computeSize (properties .Get (constants . RECIPE_SIZE_REGEXP ), out )
152
+ textSize , err = computeSize (properties .Get ("recipe.size.regex" ), out )
148
153
if err != nil {
149
154
resErr = errors .New ("Invalid size regexp: " + err .Error ())
150
155
return
@@ -154,13 +159,13 @@ func execSizeRecipe(ctx *types.Context, properties *properties.Map) (textSize in
154
159
return
155
160
}
156
161
157
- dataSize , err = computeSize (properties .Get (constants . RECIPE_SIZE_REGEXP_DATA ), out )
162
+ dataSize , err = computeSize (properties .Get ("recipe.size.regex.data" ), out )
158
163
if err != nil {
159
164
resErr = errors .New ("Invalid data size regexp: " + err .Error ())
160
165
return
161
166
}
162
167
163
- eepromSize , err = computeSize (properties .Get (constants . RECIPE_SIZE_REGEXP_EEPROM ), out )
168
+ eepromSize , err = computeSize (properties .Get ("recipe.size.regex.eeprom" ), out )
164
169
if err != nil {
165
170
resErr = errors .New ("Invalid eeprom size regexp: " + err .Error ())
166
171
return
0 commit comments