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