Skip to content

Commit

Permalink
Pruned more constants
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Sep 8, 2023
1 parent 69a0aae commit 830cbcb
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 14 deletions.
3 changes: 0 additions & 3 deletions legacy/builder/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ const BUILD_PROPERTIES_ARCH_OVERRIDE_CHECK = "architecture.override_check"
const BUILD_PROPERTIES_BOOTLOADER_FILE = "bootloader.file"
const BUILD_PROPERTIES_BOOTLOADER_NOBLINK = "bootloader.noblink"
const BUILD_PROPERTIES_BUILD_BOARD = "build.board"
const BUILD_PROPERTIES_BUILD_MCU = "build.mcu"
const BUILD_PROPERTIES_COMPILER_LDFLAGS = "compiler.ldflags"
const BUILD_PROPERTIES_COMPILER_CPP_FLAGS = "compiler.cpp.flags"
const BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH = "runtime.platform.path"
const EMPTY_STRING = ""
const FOLDER_BOOTLOADERS = "bootloaders"
const FOLDER_CORE = "core"
const FOLDER_SKETCH = "sketch"
Expand Down
2 changes: 1 addition & 1 deletion legacy/builder/create_cmake_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
for _, library := range ctx.SketchLibrariesDetector.ImportedLibraries() {
// Copy used libraries in the correct folder
libDir := libBaseFolder.Join(library.DirName)
mcu := ctx.BuildProperties.Get(constants.BUILD_PROPERTIES_BUILD_MCU)
mcu := ctx.BuildProperties.Get("build.mcu")
copyDir(library.InstallDir.String(), libDir.String(), validExportExtensions)

// Read cmake options if available
Expand Down
4 changes: 2 additions & 2 deletions legacy/builder/merge_sketch_with_bootloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ func (s *MergeSketchWithBootloader) Run(ctx *types.Context) error {
return nil
}

bootloader := constants.EMPTY_STRING
bootloader := ""
if bootloaderNoBlink, ok := buildProperties.GetOk(constants.BUILD_PROPERTIES_BOOTLOADER_NOBLINK); ok {
bootloader = bootloaderNoBlink
} else {
bootloader = buildProperties.Get(constants.BUILD_PROPERTIES_BOOTLOADER_FILE)
}
bootloader = buildProperties.ExpandPropsInString(bootloader)

bootloaderPath := buildProperties.GetPath(constants.BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH).Join(constants.FOLDER_BOOTLOADERS, bootloader)
bootloaderPath := buildProperties.GetPath("runtime.platform.path").Join(constants.FOLDER_BOOTLOADERS, bootloader)
if bootloaderPath.NotExist() {
if ctx.Verbose {
ctx.Warn(tr("Bootloader file specified but missing: %[1]s", bootloaderPath))
Expand Down
3 changes: 1 addition & 2 deletions legacy/builder/phases/core_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/arduino/arduino-cli/buildcache"
"github.com/arduino/arduino-cli/i18n"
f "github.com/arduino/arduino-cli/internal/algorithms"
"github.com/arduino/arduino-cli/legacy/builder/constants"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-properties-orderedmap"
Expand Down Expand Up @@ -102,7 +101,7 @@ func compileCore(
) (*paths.Path, paths.PathList, error) {
coreFolder := buildProperties.GetPath("build.core.path")
variantFolder := buildProperties.GetPath("build.variant.path")
targetCoreFolder := buildProperties.GetPath(constants.BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH)
targetCoreFolder := buildProperties.GetPath("runtime.platform.path")

includes := []string{coreFolder.String()}
if variantFolder != nil && variantFolder.IsDir() {
Expand Down
3 changes: 1 addition & 2 deletions legacy/builder/phases/libraries_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/arduino/arduino-cli/arduino/builder/utils"
"github.com/arduino/arduino-cli/arduino/libraries"
f "github.com/arduino/arduino-cli/internal/algorithms"
"github.com/arduino/arduino-cli/legacy/builder/constants"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-properties-orderedmap"
Expand Down Expand Up @@ -87,7 +86,7 @@ func findExpectedPrecompiledLibFolder(
buildProperties *properties.Map,
verboseInfoFn func(msg string),
) *paths.Path {
mcu := buildProperties.Get(constants.BUILD_PROPERTIES_BUILD_MCU)
mcu := buildProperties.Get("build.mcu")
// Add fpu specifications if they exist
// To do so, resolve recipe.cpp.o.pattern,
// search for -mfpu=xxx -mfloat-abi=yyy and add to a subfolder
Expand Down
6 changes: 3 additions & 3 deletions legacy/builder/test/helper_tools_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func findCoreUrl(index map[string]interface{}, core Core) (string, error) {
}
}

return constants.EMPTY_STRING, errors.Errorf("Unable to find tool " + core.Maintainer + " " + core.Arch + " " + core.Version)
return "", errors.Errorf("Unable to find tool " + core.Maintainer + " " + core.Arch + " " + core.Version)
}

func downloadTools(tools []Tool, index map[string]interface{}) error {
Expand Down Expand Up @@ -664,7 +664,7 @@ func findToolUrl(index map[string]interface{}, tool Tool, host []string) (string
}
}

return constants.EMPTY_STRING, errors.Errorf("Unable to find tool " + tool.Name + " " + tool.Version)
return "", errors.Errorf("Unable to find tool " + tool.Name + " " + tool.Version)
}

func downloadLibraries(libraries []Library, index map[string]interface{}) error {
Expand Down Expand Up @@ -694,7 +694,7 @@ func findLibraryUrl(index map[string]interface{}, library Library) (string, erro
}
}

return constants.EMPTY_STRING, errors.Errorf("Unable to find library " + library.Name + " " + library.Version)
return "", errors.Errorf("Unable to find library " + library.Name + " " + library.Version)
}

func downloadAndUnpackLibrary(library Library, url string, targetPath *paths.Path) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
// since the json was generated - like platform.txt or similar
// if so, trigger a "safety" wipe
buildProperties := ctx.BuildProperties
targetCoreFolder := buildProperties.GetPath(constants.BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH)
targetCoreFolder := buildProperties.GetPath("runtime.platform.path")
coreFolder := buildProperties.GetPath("build.core.path")
realCoreFolder := coreFolder.Parent().Parent()
jsonPath := ctx.BuildPath.Join(constants.BUILD_OPTIONS_FILE)
Expand Down

0 comments on commit 830cbcb

Please sign in to comment.