From 830cbcb93387cd3c5fc0002e73d5c23d185aedda Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 8 Sep 2023 15:29:28 +0200 Subject: [PATCH] Pruned more constants --- legacy/builder/constants/constants.go | 3 --- legacy/builder/create_cmake_rule.go | 2 +- legacy/builder/merge_sketch_with_bootloader.go | 4 ++-- legacy/builder/phases/core_builder.go | 3 +-- legacy/builder/phases/libraries_builder.go | 3 +-- legacy/builder/test/helper_tools_downloader.go | 6 +++--- .../builder/wipeout_build_path_if_build_options_changed.go | 2 +- 7 files changed, 9 insertions(+), 14 deletions(-) diff --git a/legacy/builder/constants/constants.go b/legacy/builder/constants/constants.go index d1a6e4887c6..31287e769da 100644 --- a/legacy/builder/constants/constants.go +++ b/legacy/builder/constants/constants.go @@ -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" diff --git a/legacy/builder/create_cmake_rule.go b/legacy/builder/create_cmake_rule.go index 9ce4b068832..262218150f2 100644 --- a/legacy/builder/create_cmake_rule.go +++ b/legacy/builder/create_cmake_rule.go @@ -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 diff --git a/legacy/builder/merge_sketch_with_bootloader.go b/legacy/builder/merge_sketch_with_bootloader.go index b16b293ea44..7b9f0da3542 100644 --- a/legacy/builder/merge_sketch_with_bootloader.go +++ b/legacy/builder/merge_sketch_with_bootloader.go @@ -55,7 +55,7 @@ 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 { @@ -63,7 +63,7 @@ func (s *MergeSketchWithBootloader) Run(ctx *types.Context) error { } 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)) diff --git a/legacy/builder/phases/core_builder.go b/legacy/builder/phases/core_builder.go index 5c5e0339e41..9c49fe6d787 100644 --- a/legacy/builder/phases/core_builder.go +++ b/legacy/builder/phases/core_builder.go @@ -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" @@ -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() { diff --git a/legacy/builder/phases/libraries_builder.go b/legacy/builder/phases/libraries_builder.go index 8608b292916..9bd03c95f0a 100644 --- a/legacy/builder/phases/libraries_builder.go +++ b/legacy/builder/phases/libraries_builder.go @@ -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" @@ -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 diff --git a/legacy/builder/test/helper_tools_downloader.go b/legacy/builder/test/helper_tools_downloader.go index f28c29c1c5e..2d80f0417fe 100644 --- a/legacy/builder/test/helper_tools_downloader.go +++ b/legacy/builder/test/helper_tools_downloader.go @@ -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 { @@ -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 { @@ -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 { diff --git a/legacy/builder/wipeout_build_path_if_build_options_changed.go b/legacy/builder/wipeout_build_path_if_build_options_changed.go index 72b00b8671a..5b429971901 100644 --- a/legacy/builder/wipeout_build_path_if_build_options_changed.go +++ b/legacy/builder/wipeout_build_path_if_build_options_changed.go @@ -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)