Skip to content

Commit 29f8215

Browse files
move some legacy constans in builder package
1 parent 19906a7 commit 29f8215

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

Diff for: arduino/builder/builder.go

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ package builder
1717

1818
import "github.com/arduino/arduino-cli/arduino/sketch"
1919

20+
const (
21+
BuildPropertiesArchiveFile = "archive_file"
22+
BuildPropertiesArchiveFilePath = "archive_file_path"
23+
BuildPropertiesObjectFile = "object_file"
24+
RecipeARPattern = "recipe.ar.pattern"
25+
BuildPropertiesIncludes = "includes"
26+
BuildPropertiesCompilerWarningFlags = "compiler.warning_flags"
27+
Space = " "
28+
)
29+
2030
// Builder is a Sketch builder.
2131
type Builder struct {
2232
sketch *sketch.Sketch

Diff for: legacy/builder/builder_utils/utils.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/arduino/arduino-cli/arduino/globals"
3232
"github.com/arduino/arduino-cli/executils"
3333
"github.com/arduino/arduino-cli/i18n"
34-
"github.com/arduino/arduino-cli/legacy/builder/constants"
3534
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3635
"github.com/arduino/go-paths-helper"
3736
"github.com/arduino/go-properties-orderedmap"
@@ -251,8 +250,8 @@ func compileFileWithRecipe(
251250
verboseStdout, verboseInfo, errOut := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}
252251

253252
properties := buildProperties.Clone()
254-
properties.Set(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS, properties.Get(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS+"."+warningsLevel))
255-
properties.Set(constants.BUILD_PROPERTIES_INCLUDES, strings.Join(includes, constants.SPACE))
253+
properties.Set(builder.BuildPropertiesCompilerWarningFlags, properties.Get(builder.BuildPropertiesCompilerWarningFlags+"."+warningsLevel))
254+
properties.Set(builder.BuildPropertiesIncludes, strings.Join(includes, builder.Space))
256255
properties.SetPath("source_file", source)
257256
relativeSource, err := sourcePath.RelTo(source)
258257
if err != nil {
@@ -261,7 +260,7 @@ func compileFileWithRecipe(
261260
depsFile := buildPath.Join(relativeSource.String() + ".d")
262261
objectFile := buildPath.Join(relativeSource.String() + ".o")
263262

264-
properties.SetPath(constants.BUILD_PROPERTIES_OBJECT_FILE, objectFile)
263+
properties.SetPath(builder.BuildPropertiesObjectFile, objectFile)
265264
err = objectFile.Parent().MkdirAll()
266265
if err != nil {
267266
return nil, nil, nil, nil, errors.WithStack(err)
@@ -345,11 +344,11 @@ func ArchiveCompiledFiles(
345344

346345
for _, objectFile := range objectFilesToArchive {
347346
properties := buildProperties.Clone()
348-
properties.Set(constants.BUILD_PROPERTIES_ARCHIVE_FILE, archiveFilePath.Base())
349-
properties.SetPath(constants.BUILD_PROPERTIES_ARCHIVE_FILE_PATH, archiveFilePath)
350-
properties.SetPath(constants.BUILD_PROPERTIES_OBJECT_FILE, objectFile)
347+
properties.Set(builder.BuildPropertiesArchiveFile, archiveFilePath.Base())
348+
properties.SetPath(builder.BuildPropertiesArchiveFilePath, archiveFilePath)
349+
properties.SetPath(builder.BuildPropertiesObjectFile, objectFile)
351350

352-
command, err := PrepareCommandForRecipe(properties, constants.RECIPE_AR_PATTERN, false)
351+
command, err := PrepareCommandForRecipe(properties, builder.RecipeARPattern, false)
353352
if err != nil {
354353
return nil, verboseInfobuf.Bytes(), errors.WithStack(err)
355354
}

Diff for: legacy/builder/constants/constants.go

-7
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package constants
1818

1919
const BUILD_OPTIONS_FILE = "build.options.json"
20-
const BUILD_PROPERTIES_ARCHIVE_FILE = "archive_file"
21-
const BUILD_PROPERTIES_ARCHIVE_FILE_PATH = "archive_file_path"
2220
const BUILD_PROPERTIES_ARCH_OVERRIDE_CHECK = "architecture.override_check"
2321
const BUILD_PROPERTIES_BOOTLOADER_FILE = "bootloader.file"
2422
const BUILD_PROPERTIES_BOOTLOADER_NOBLINK = "bootloader.noblink"
@@ -27,9 +25,6 @@ const BUILD_PROPERTIES_BUILD_MCU = "build.mcu"
2725
const BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS = "compiler.c.elf.flags"
2826
const BUILD_PROPERTIES_COMPILER_LDFLAGS = "compiler.ldflags"
2927
const BUILD_PROPERTIES_COMPILER_CPP_FLAGS = "compiler.cpp.flags"
30-
const BUILD_PROPERTIES_COMPILER_WARNING_FLAGS = "compiler.warning_flags"
31-
const BUILD_PROPERTIES_INCLUDES = "includes"
32-
const BUILD_PROPERTIES_OBJECT_FILE = "object_file"
3328
const BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH = "runtime.platform.path"
3429
const EMPTY_STRING = ""
3530
const FOLDER_BOOTLOADERS = "bootloaders"
@@ -50,9 +45,7 @@ const PACKAGE_TOOLS = "tools"
5045
const PLATFORM_ARCHITECTURE = "architecture"
5146
const PLATFORM_URL = "url"
5247
const PLATFORM_VERSION = "version"
53-
const RECIPE_AR_PATTERN = "recipe.ar.pattern"
5448
const RECIPE_C_COMBINE_PATTERN = "recipe.c.combine.pattern"
55-
const SPACE = " "
5649
const TOOL_NAME = "name"
5750
const TOOL_URL = "url"
5851
const TOOL_VERSION = "version"

Diff for: legacy/builder/phases/linker.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package phases
1818
import (
1919
"strings"
2020

21+
"github.com/arduino/arduino-cli/arduino/builder"
2122
"github.com/arduino/arduino-cli/arduino/builder/utils"
2223
f "github.com/arduino/arduino-cli/internal/algorithms"
2324
"github.com/arduino/arduino-cli/legacy/builder/builder_utils"
@@ -93,7 +94,7 @@ func link(ctx *types.Context, objectFiles paths.PathList, coreDotARelPath *paths
9394
properties.SetPath("archive_file_path", archive)
9495
properties.SetPath("object_file", object)
9596

96-
command, err := builder_utils.PrepareCommandForRecipe(properties, constants.RECIPE_AR_PATTERN, false)
97+
command, err := builder_utils.PrepareCommandForRecipe(properties, builder.RecipeARPattern, false)
9798
if err != nil {
9899
return errors.WithStack(err)
99100
}
@@ -112,9 +113,9 @@ func link(ctx *types.Context, objectFiles paths.PathList, coreDotARelPath *paths
112113

113114
properties := buildProperties.Clone()
114115
properties.Set(constants.BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS, properties.Get(constants.BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS))
115-
properties.Set(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS, properties.Get(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS+"."+ctx.WarningsLevel))
116-
properties.Set(constants.BUILD_PROPERTIES_ARCHIVE_FILE, coreDotARelPath.String())
117-
properties.Set(constants.BUILD_PROPERTIES_ARCHIVE_FILE_PATH, coreArchiveFilePath.String())
116+
properties.Set(builder.BuildPropertiesCompilerWarningFlags, properties.Get(builder.BuildPropertiesCompilerWarningFlags+"."+ctx.WarningsLevel))
117+
properties.Set(builder.BuildPropertiesArchiveFile, coreDotARelPath.String())
118+
properties.Set(builder.BuildPropertiesArchiveFilePath, coreArchiveFilePath.String())
118119
properties.Set("object_files", objectFileList)
119120

120121
command, err := builder_utils.PrepareCommandForRecipe(properties, constants.RECIPE_C_COMBINE_PATTERN, false)

0 commit comments

Comments
 (0)