Skip to content

Commit

Permalink
remove legacy/constans pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Sep 12, 2023
1 parent 7748942 commit da308d8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 66 deletions.
3 changes: 1 addition & 2 deletions arduino/builder/export_cmake.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/arduino/arduino-cli/arduino/builder/utils"
"github.com/arduino/arduino-cli/arduino/globals"
"github.com/arduino/arduino-cli/arduino/libraries"
"github.com/arduino/arduino-cli/legacy/builder/constants"
)

var lineMatcher = regexp.MustCompile(`^#line\s\d+\s"`)
Expand Down Expand Up @@ -283,7 +282,7 @@ func (b *Builder) ExportProjectCMake(
var dynamicLibsFromGccMinusL []string
var linkDirectories []string

extractCompileFlags(b.buildProperties, constants.RECIPE_C_COMBINE_PATTERN, &defines, &dynamicLibsFromGccMinusL, &linkerflags, &linkDirectories)
extractCompileFlags(b.buildProperties, "recipe.c.combine.pattern", &defines, &dynamicLibsFromGccMinusL, &linkerflags, &linkDirectories)
extractCompileFlags(b.buildProperties, "recipe.c.o.pattern", &defines, &dynamicLibsFromGccMinusL, &linkerflags, &linkDirectories)
extractCompileFlags(b.buildProperties, "recipe.cpp.o.pattern", &defines, &dynamicLibsFromGccMinusL, &linkerflags, &linkDirectories)

Expand Down
47 changes: 0 additions & 47 deletions legacy/builder/constants/constants.go

This file was deleted.

21 changes: 10 additions & 11 deletions legacy/builder/test/helper_tools_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"strings"
"testing"

"github.com/arduino/arduino-cli/legacy/builder/constants"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-properties-orderedmap"
"github.com/pkg/errors"
Expand Down Expand Up @@ -264,12 +263,12 @@ func findCoreUrl(index map[string]interface{}, core Core) (string, error) {
packages := index["packages"].([]interface{})
for _, p := range packages {
pack := p.(map[string]interface{})
if pack[constants.PACKAGE_NAME].(string) == core.Maintainer {
if pack["name"].(string) == core.Maintainer {
packagePlatforms := pack["platforms"].([]interface{})
for _, pt := range packagePlatforms {
packagePlatform := pt.(map[string]interface{})
if packagePlatform[constants.PLATFORM_ARCHITECTURE] == core.Arch && packagePlatform[constants.PLATFORM_VERSION] == core.Version {
return packagePlatform[constants.PLATFORM_URL].(string), nil
if packagePlatform["architecture"] == core.Arch && packagePlatform["version"] == core.Version {
return packagePlatform["url"].(string), nil
}
}
}
Expand Down Expand Up @@ -394,7 +393,7 @@ func allBoardsManagerToolsAlreadyDownloadedAndUnpacked(targetPath *paths.Path, t
}

func boardManagerToolAlreadyDownloadedAndUnpacked(targetPath *paths.Path, tool Tool) bool {
return targetPath.Join(tool.Package, constants.FOLDER_TOOLS, tool.Name, tool.Version).Exist()
return targetPath.Join(tool.Package, "tools", tool.Name, tool.Version).Exist()
}

func allToolsAlreadyDownloadedAndUnpacked(targetPath *paths.Path, tools []Tool) bool {
Expand Down Expand Up @@ -513,10 +512,10 @@ func downloadAndUnpackBoardsManagerTool(tool Tool, url string, targetPath *paths
}
defer unpackFolder.RemoveAll()

if err := targetPath.Join(tool.Package, constants.FOLDER_TOOLS, tool.Name).MkdirAll(); err != nil {
if err := targetPath.Join(tool.Package, "tools", tool.Name).MkdirAll(); err != nil {
return errors.WithStack(err)
}
if err := unpackFolder.Join(files[0].Base()).CopyDirTo(targetPath.Join(tool.Package, constants.FOLDER_TOOLS, tool.Name, tool.Version)); err != nil {
if err := unpackFolder.Join(files[0].Base()).CopyDirTo(targetPath.Join(tool.Package, "tools", tool.Name, tool.Version)); err != nil {
return errors.WithStack(err)
}
return nil
Expand Down Expand Up @@ -646,17 +645,17 @@ func findToolUrl(index map[string]interface{}, tool Tool, host []string) (string
packages := index["packages"].([]interface{})
for _, p := range packages {
pack := p.(map[string]interface{})
packageTools := pack[constants.PACKAGE_TOOLS].([]interface{})
packageTools := pack["tools"].([]interface{})
for _, pt := range packageTools {
packageTool := pt.(map[string]interface{})
name := packageTool[constants.TOOL_NAME].(string)
version := packageTool[constants.TOOL_VERSION].(string)
name := packageTool["name"].(string)
version := packageTool["version"].(string)
if name == tool.Name && version == tool.Version {
systems := packageTool["systems"].([]interface{})
for _, s := range systems {
system := s.(map[string]interface{})
if slices.Contains(host, system["host"].(string)) {
return system[constants.TOOL_URL].(string), nil
return system["url"].(string), nil
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions legacy/builder/test/libraries_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/arduino/arduino-cli/arduino/builder/detector"
"github.com/arduino/arduino-cli/arduino/libraries"
"github.com/arduino/arduino-cli/legacy/builder/constants"
"github.com/arduino/arduino-cli/legacy/builder/types"
paths "github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -74,7 +73,7 @@ func TestLoadLibrariesAVR(t *testing.T) {
require.True(t, Abs(t, paths.New("downloaded_libraries/Adafruit_PN532")).EquivalentTo(libs[idx].InstallDir))
require.True(t, Abs(t, paths.New("downloaded_libraries/Adafruit_PN532")).EquivalentTo(libs[idx].SourceDir))
require.Equal(t, 1, len(libs[idx].Architectures))
require.Equal(t, constants.LIBRARY_ALL_ARCHS, libs[idx].Architectures[0])
require.Equal(t, "*", libs[idx].Architectures[0])
require.False(t, libs[idx].IsLegacy)

idx++
Expand All @@ -90,7 +89,7 @@ func TestLoadLibrariesAVR(t *testing.T) {
require.True(t, Abs(t, paths.New("downloaded_libraries/Bridge")).EquivalentTo(bridgeLib.InstallDir))
require.True(t, Abs(t, paths.New("downloaded_libraries/Bridge/src")).EquivalentTo(bridgeLib.SourceDir))
require.Equal(t, 1, len(bridgeLib.Architectures))
require.Equal(t, constants.LIBRARY_ALL_ARCHS, bridgeLib.Architectures[0])
require.Equal(t, "*", bridgeLib.Architectures[0])
require.Equal(t, "Arduino", bridgeLib.Author)
require.Equal(t, "Arduino <[email protected]>", bridgeLib.Maintainer)

Expand Down
5 changes: 2 additions & 3 deletions legacy/builder/test/merge_sketch_with_bootloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"
"testing"

"github.com/arduino/arduino-cli/legacy/builder/constants"
"github.com/arduino/arduino-cli/legacy/builder/types"
paths "github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -138,8 +137,8 @@ func TestMergeSketchWithBootloaderWhenNoBootloaderAvailable(t *testing.T) {

buildPath := ctx.Builder.GetBuildPath()
buildProperties := ctx.Builder.GetBuildProperties()
buildProperties.Remove(constants.BUILD_PROPERTIES_BOOTLOADER_NOBLINK)
buildProperties.Remove(constants.BUILD_PROPERTIES_BOOTLOADER_FILE)
buildProperties.Remove("bootloader.noblink")
buildProperties.Remove("bootloader.file")

err := ctx.Builder.MergeSketchWithBootloader(ctx.OnlyUpdateCompilationDatabase)
require.NoError(t, err)
Expand Down

0 comments on commit da308d8

Please sign in to comment.