Skip to content

Commit 49ac8f1

Browse files
committed
Remove some constants indirection
1 parent 23e7cb5 commit 49ac8f1

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

legacy/builder/constants/constants.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,12 @@ const PLATFORM_REWRITE_NEW = "new"
6464
const PLATFORM_REWRITE_OLD = "old"
6565
const PLATFORM_URL = "url"
6666
const PLATFORM_VERSION = "version"
67-
const PROPERTY_WARN_DATA_PERCENT = "build.warn_data_percentage"
68-
const PROPERTY_UPLOAD_MAX_SIZE = "upload.maximum_size"
69-
const PROPERTY_UPLOAD_MAX_DATA_SIZE = "upload.maximum_data_size"
7067
const RECIPE_AR_PATTERN = "recipe.ar.pattern"
7168
const RECIPE_C_COMBINE_PATTERN = "recipe.c.combine.pattern"
7269
const RECIPE_C_PATTERN = "recipe.c.o.pattern"
7370
const RECIPE_CPP_PATTERN = "recipe.cpp.o.pattern"
74-
const RECIPE_SIZE_PATTERN = "recipe.size.pattern"
7571
const RECIPE_PREPROC_MACROS = "recipe.preproc.macros"
7672
const RECIPE_S_PATTERN = "recipe.S.o.pattern"
77-
const RECIPE_SIZE_REGEXP = "recipe.size.regex"
78-
const RECIPE_SIZE_REGEXP_DATA = "recipe.size.regex.data"
79-
const RECIPE_SIZE_REGEXP_EEPROM = "recipe.size.regex.eeprom"
8073
const REWRITING_DISABLED = "disabled"
8174
const REWRITING = "rewriting"
8275
const SPACE = " "

legacy/builder/merge_sketch_with_bootloader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (s *MergeSketchWithBootloader) Run(ctx *types.Context) error {
7575

7676
// Ignore merger errors for the first iteration
7777
maximumBinSize := 16000000
78-
if uploadMaxSize, ok := ctx.BuildProperties.GetOk(constants.PROPERTY_UPLOAD_MAX_SIZE); ok {
78+
if uploadMaxSize, ok := ctx.BuildProperties.GetOk("upload.maximum_size"); ok {
7979
maximumBinSize, _ = strconv.Atoi(uploadMaxSize)
8080
maximumBinSize *= 2
8181
}

legacy/builder/phases/sizer.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"strconv"
2222

2323
"github.com/arduino/arduino-cli/legacy/builder/builder_utils"
24-
"github.com/arduino/arduino-cli/legacy/builder/constants"
2524
"github.com/arduino/arduino-cli/legacy/builder/types"
2625
"github.com/arduino/arduino-cli/legacy/builder/utils"
2726
"github.com/arduino/go-properties-orderedmap"
@@ -52,10 +51,10 @@ func (s *Sizer) Run(ctx *types.Context) error {
5251

5352
func checkSize(ctx *types.Context, buildProperties *properties.Map) error {
5453
properties := buildProperties.Clone()
55-
properties.Set(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS, properties.Get(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS+"."+ctx.WarningsLevel))
54+
properties.Set("compiler.warning_flags", properties.Get("compiler.warning_flags."+ctx.WarningsLevel))
5655

57-
maxTextSizeString := properties.Get(constants.PROPERTY_UPLOAD_MAX_SIZE)
58-
maxDataSizeString := properties.Get(constants.PROPERTY_UPLOAD_MAX_DATA_SIZE)
56+
maxTextSizeString := properties.Get("upload.maximum_size")
57+
maxDataSizeString := properties.Get("upload.maximum_data_size")
5958

6059
if maxTextSizeString == "" {
6160
return nil
@@ -121,8 +120,8 @@ func checkSize(ctx *types.Context, buildProperties *properties.Map) error {
121120
return errors.New(tr("data section exceeds available space in board"))
122121
}
123122

124-
if properties.Get(constants.PROPERTY_WARN_DATA_PERCENT) != "" {
125-
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)
126125
if err != nil {
127126
return err
128127
}
@@ -135,7 +134,7 @@ func checkSize(ctx *types.Context, buildProperties *properties.Map) error {
135134
}
136135

137136
func execSizeRecipe(ctx *types.Context, properties *properties.Map) (textSize int, dataSize int, eepromSize int, resErr error) {
138-
command, err := builder_utils.PrepareCommandForRecipe(properties, constants.RECIPE_SIZE_PATTERN, false)
137+
command, err := builder_utils.PrepareCommandForRecipe(properties, "recipe.size.pattern", false)
139138
if err != nil {
140139
resErr = fmt.Errorf(tr("Error while determining sketch size: %s"), err)
141140
return
@@ -150,7 +149,7 @@ func execSizeRecipe(ctx *types.Context, properties *properties.Map) (textSize in
150149
// force multiline match prepending "(?m)" to the actual regexp
151150
// return an error if RECIPE_SIZE_REGEXP doesn't exist
152151

153-
textSize, err = computeSize(properties.Get(constants.RECIPE_SIZE_REGEXP), out)
152+
textSize, err = computeSize(properties.Get("recipe.size.regex"), out)
154153
if err != nil {
155154
resErr = fmt.Errorf(tr("Invalid size regexp: %s"), err)
156155
return
@@ -160,13 +159,13 @@ func execSizeRecipe(ctx *types.Context, properties *properties.Map) (textSize in
160159
return
161160
}
162161

163-
dataSize, err = computeSize(properties.Get(constants.RECIPE_SIZE_REGEXP_DATA), out)
162+
dataSize, err = computeSize(properties.Get("recipe.size.regex.data"), out)
164163
if err != nil {
165164
resErr = fmt.Errorf(tr("Invalid data size regexp: %s"), err)
166165
return
167166
}
168167

169-
eepromSize, err = computeSize(properties.Get(constants.RECIPE_SIZE_REGEXP_EEPROM), out)
168+
eepromSize, err = computeSize(properties.Get("recipe.size.regex.eeprom"), out)
170169
if err != nil {
171170
resErr = fmt.Errorf(tr("Invalid eeprom size regexp: %s"), err)
172171
return

0 commit comments

Comments
 (0)