Skip to content

Commit 07cf265

Browse files
Drop support of package_bundled_index.json and builtin_tools_versions.txt (#2424)
1 parent 1911448 commit 07cf265

File tree

11 files changed

+74
-153
lines changed

11 files changed

+74
-153
lines changed

Diff for: commands/compile/compile.go

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
187187
int(req.GetJobs()),
188188
req.GetBuildProperties(),
189189
configuration.HardwareDirectories(configuration.Settings),
190-
configuration.BuiltinToolsDirectories(configuration.Settings),
191190
otherLibrariesDirs,
192191
configuration.IDEBuiltinLibrariesDir(configuration.Settings),
193192
fqbn,

Diff for: docs/UPGRADING.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Here you can find a list of migration guides to handle breaking changes between
44

55
## 0.36.0
66

7+
### Drop support for `builtin.tools`
8+
9+
We're dropping the `builtin.tools` support. It was the equivalent of Arduino IDE 1.x bundled tools directory.
10+
711
### Some golang modules from `github.com/arduino/arduino-cli/*` have been made private.
812

913
The following golang modules are no longer available as public API:

Diff for: docs/configuration.md

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
- `builtin.libraries` - the libraries in this directory will be available to all platforms without the need for the
1313
user to install them, but with the lowest priority over other installed libraries with the same name, it's the
1414
equivalent of the Arduino IDE's bundled libraries directory.
15-
- `builtin.tools` - it's a list of directories of tools that will be available to all platforms without the need for
16-
the user to install them, it's the equivalent of the Arduino IDE 1.x bundled tools directory.
1715
- `library` - configuration options relating to Arduino libraries.
1816
- `enable_unsafe_install` - set to `true` to enable the use of the `--git-url` and `--zip-file` flags with
1917
[`arduino-cli lib install`][arduino cli lib install]. These are considered "unsafe" installation methods because

Diff for: internal/arduino/builder/build_options_manager.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type buildOptions struct {
3333
currentOptions *properties.Map
3434

3535
hardwareDirs paths.PathList
36-
builtInToolsDirs paths.PathList
3736
otherLibrariesDirs paths.PathList
3837
builtInLibrariesDirs *paths.Path
3938
buildPath *paths.Path
@@ -47,7 +46,7 @@ type buildOptions struct {
4746

4847
// newBuildOptions fixdoc
4948
func newBuildOptions(
50-
hardwareDirs, builtInToolsDirs, otherLibrariesDirs paths.PathList,
49+
hardwareDirs, otherLibrariesDirs paths.PathList,
5150
builtInLibrariesDirs, buildPath *paths.Path,
5251
sketch *sketch.Sketch,
5352
customBuildProperties []string,
@@ -59,7 +58,6 @@ func newBuildOptions(
5958
opts := properties.NewMap()
6059

6160
opts.Set("hardwareFolders", strings.Join(hardwareDirs.AsStrings(), ","))
62-
opts.Set("builtInToolsFolders", strings.Join(builtInToolsDirs.AsStrings(), ","))
6361
opts.Set("otherLibrariesFolders", strings.Join(otherLibrariesDirs.AsStrings(), ","))
6462
opts.SetPath("sketchLocation", sketch.FullPath)
6563
opts.Set("fqbn", fqbn.String())
@@ -84,7 +82,6 @@ func newBuildOptions(
8482
return &buildOptions{
8583
currentOptions: opts,
8684
hardwareDirs: hardwareDirs,
87-
builtInToolsDirs: builtInToolsDirs,
8885
otherLibrariesDirs: otherLibrariesDirs,
8986
builtInLibrariesDirs: builtInLibrariesDirs,
9087
buildPath: buildPath,

Diff for: internal/arduino/builder/builder.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func NewBuilder(
121121
coreBuildCachePath *paths.Path,
122122
jobs int,
123123
requestBuildProperties []string,
124-
hardwareDirs, builtInToolsDirs, otherLibrariesDirs paths.PathList,
124+
hardwareDirs, otherLibrariesDirs paths.PathList,
125125
builtInLibrariesDirs *paths.Path,
126126
fqbn *cores.FQBN,
127127
clean bool,
@@ -223,7 +223,7 @@ func NewBuilder(
223223
logger,
224224
),
225225
buildOptions: newBuildOptions(
226-
hardwareDirs, builtInToolsDirs, otherLibrariesDirs,
226+
hardwareDirs, otherLibrariesDirs,
227227
builtInLibrariesDirs, buildPath,
228228
sk,
229229
customBuildPropertiesArgs,

Diff for: internal/arduino/cores/cores.go

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ type PlatformRelease struct {
7070
Programmers map[string]*Programmer `json:"-"`
7171
Menus *properties.Map `json:"-"`
7272
InstallDir *paths.Path `json:"-"`
73-
IsIDEBundled bool `json:"-"`
7473
IsTrusted bool `json:"-"`
7574
PluggableDiscoveryAware bool `json:"-"` // true if the Platform supports pluggable discovery (no compatibility layer required)
7675
Monitors map[string]*MonitorDependency `json:"-"`

Diff for: internal/arduino/cores/packagemanager/loader.go

+2-126
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package packagemanager
1818
import (
1919
"errors"
2020
"fmt"
21-
"os"
22-
"path/filepath"
2321
"regexp"
2422
"strconv"
2523
"strings"
@@ -36,12 +34,7 @@ import (
3634
// LoadHardware read all plaforms from the configured paths
3735
func (pm *Builder) LoadHardware() []error {
3836
hardwareDirs := configuration.HardwareDirectories(configuration.Settings)
39-
merr := pm.LoadHardwareFromDirectories(hardwareDirs)
40-
41-
bundleToolDirs := configuration.BuiltinToolsDirectories(configuration.Settings)
42-
merr = append(merr, pm.LoadToolsFromBundleDirectories(bundleToolDirs)...)
43-
44-
return merr
37+
return pm.LoadHardwareFromDirectories(hardwareDirs)
4538
}
4639

4740
// LoadHardwareFromDirectories load plaforms from a set of directories
@@ -203,49 +196,9 @@ func (pm *Builder) loadPlatform(targetPackage *cores.Package, architecture strin
203196
return &cmderrors.InvalidVersionError{Cause: fmt.Errorf("%s: %s", platformTxtPath, err)}
204197
}
205198

206-
// Check if package_bundled_index.json exists.
207-
// This is used indirectly by the Java IDE since it's necessary for the arduino-builder
208-
// to find cores bundled with that version of the IDE.
209-
// TODO: This piece of logic MUST be removed as soon as the Java IDE stops using the arduino-builder.
210-
isIDEBundled := false
211-
packageBundledIndexPath := platformPath.Parent().Parent().Join("package_index_bundled.json")
212-
if packageBundledIndexPath.Exist() {
213-
// particular case: ARCHITECTURE/boards.txt with package_bundled_index.json
214-
215-
// this is an unversioned Platform with a package_index_bundled.json that
216-
// gives information about the version and tools needed
217-
218-
// Parse the bundled index and merge to the general index
219-
index, err := pm.LoadPackageIndexFromFile(packageBundledIndexPath)
220-
if err != nil {
221-
return fmt.Errorf("%s: %w", tr("parsing IDE bundled index"), err)
222-
}
223-
224-
// Now export the bundled index in a temporary core.Packages to retrieve the bundled package version
225-
tmp := cores.NewPackages()
226-
index.MergeIntoPackages(tmp)
227-
if tmpPackage := tmp.GetOrCreatePackage(targetPackage.Name); tmpPackage == nil {
228-
pm.log.Warnf("Can't determine bundle platform version for %s", targetPackage.Name)
229-
} else if tmpPlatform := tmpPackage.GetOrCreatePlatform(architecture); tmpPlatform == nil {
230-
pm.log.Warnf("Can't determine bundle platform version for %s:%s", targetPackage.Name, architecture)
231-
} else if tmpPlatformRelease := tmpPlatform.GetLatestRelease(); tmpPlatformRelease == nil {
232-
pm.log.Warnf("Can't determine bundle platform version for %s:%s, no valid release found", targetPackage.Name, architecture)
233-
} else {
234-
version = tmpPlatformRelease.Version
235-
}
236-
237-
isIDEBundled = true
238-
}
239-
240199
platform := targetPackage.GetOrCreatePlatform(architecture)
241-
if !isIDEBundled {
242-
platform.ManuallyInstalled = true
243-
}
200+
platform.ManuallyInstalled = true
244201
release := platform.GetOrCreateRelease(version)
245-
release.IsIDEBundled = isIDEBundled
246-
if isIDEBundled {
247-
pm.log.Infof("Package is built-in")
248-
}
249202
if err := pm.loadPlatformRelease(release, platformPath); err != nil {
250203
return fmt.Errorf("%s: %w", tr("loading platform release %s", release), err)
251204
}
@@ -658,83 +611,6 @@ func (pm *Builder) loadToolReleaseFromDirectory(tool *cores.Tool, version *semve
658611
}
659612
}
660613

661-
// LoadToolsFromBundleDirectories FIXMEDOC
662-
func (pm *Builder) LoadToolsFromBundleDirectories(dirs paths.PathList) []error {
663-
var merr []error
664-
for _, dir := range dirs {
665-
if err := pm.LoadToolsFromBundleDirectory(dir); err != nil {
666-
merr = append(merr, fmt.Errorf("%s: %w", tr("loading bundled tools from %s", dir), err))
667-
}
668-
}
669-
return merr
670-
}
671-
672-
// LoadToolsFromBundleDirectory FIXMEDOC
673-
func (pm *Builder) LoadToolsFromBundleDirectory(toolsPath *paths.Path) error {
674-
pm.log.Infof("Loading tools from bundle dir: %s", toolsPath)
675-
676-
// We scan toolsPath content to find a "builtin_tools_versions.txt", if such file exists
677-
// then the all the tools are available in the same directory, mixed together, and their
678-
// name and version are written in the "builtin_tools_versions.txt" file.
679-
// If no "builtin_tools_versions.txt" is found, then the directory structure is the classic
680-
// TOOLSPATH/TOOL-NAME/TOOL-VERSION and it will be parsed as such and associated to an
681-
// "unnamed" packager.
682-
683-
// TODO: get rid of "builtin_tools_versions.txt"
684-
685-
// Search for builtin_tools_versions.txt
686-
builtinToolsVersionsTxtPath := ""
687-
findBuiltInToolsVersionsTxt := func(currentPath string, info os.FileInfo, err error) error {
688-
if err != nil {
689-
// Ignore errors
690-
return nil
691-
}
692-
if builtinToolsVersionsTxtPath != "" {
693-
return filepath.SkipDir
694-
}
695-
if info.Name() == "builtin_tools_versions.txt" {
696-
builtinToolsVersionsTxtPath = currentPath
697-
return filepath.SkipDir
698-
}
699-
return nil
700-
}
701-
if err := filepath.Walk(toolsPath.String(), findBuiltInToolsVersionsTxt); err != nil {
702-
return fmt.Errorf(tr("searching for builtin_tools_versions.txt in %[1]s: %[2]s"), toolsPath, err)
703-
}
704-
705-
if builtinToolsVersionsTxtPath != "" {
706-
// If builtin_tools_versions.txt is found create tools based on the info
707-
// contained in that file
708-
pm.log.Infof("Found builtin_tools_versions.txt")
709-
toolPath, err := paths.New(builtinToolsVersionsTxtPath).Parent().Abs()
710-
if err != nil {
711-
return fmt.Errorf(tr("getting parent dir of %[1]s: %[2]s"), builtinToolsVersionsTxtPath, err)
712-
}
713-
714-
all, err := properties.Load(builtinToolsVersionsTxtPath)
715-
if err != nil {
716-
return fmt.Errorf(tr("reading %[1]s: %[2]s"), builtinToolsVersionsTxtPath, err)
717-
}
718-
719-
for packager, toolsData := range all.FirstLevelOf() {
720-
targetPackage := pm.packages.GetOrCreatePackage(packager)
721-
722-
for toolName, toolVersion := range toolsData.AsMap() {
723-
tool := targetPackage.GetOrCreateTool(toolName)
724-
version := semver.ParseRelaxed(toolVersion)
725-
release := tool.GetOrCreateRelease(version)
726-
release.InstallDir = toolPath
727-
pm.log.WithField("tool", release).Infof("Loaded tool")
728-
}
729-
}
730-
} else {
731-
// otherwise load the tools inside the unnamed package
732-
unnamedPackage := pm.packages.GetOrCreatePackage("")
733-
pm.LoadToolsFromPackageDir(unnamedPackage, toolsPath)
734-
}
735-
return nil
736-
}
737-
738614
// LoadDiscoveries load all discoveries for all loaded platforms
739615
// Returns error if:
740616
// * A PluggableDiscovery instance can't be created

Diff for: internal/arduino/cores/packagemanager/package_manager.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,7 @@ func (pme *Explorer) GetInstalledPlatformRelease(platform *cores.Platform) *core
621621
}
622622

623623
debug := func(msg string, pl *cores.PlatformRelease) {
624-
pme.log.WithField("bundle", pl.IsIDEBundled).
625-
WithField("version", pl.Version).
624+
pme.log.WithField("version", pl.Version).
626625
WithField("managed", pme.IsManagedPlatformRelease(pl)).
627626
Debugf("%s: %s", msg, pl)
628627
}
@@ -634,20 +633,20 @@ func (pme *Explorer) GetInstalledPlatformRelease(platform *cores.Platform) *core
634633
for _, candidate := range releases[1:] {
635634
candidateIsManaged := pme.IsManagedPlatformRelease(candidate)
636635
debug("candidate", candidate)
637-
// TODO: Disentangle this algorithm and make it more straightforward
638-
if bestIsManaged == candidateIsManaged {
639-
if best.IsIDEBundled == candidate.IsIDEBundled {
640-
if candidate.Version.GreaterThan(best.Version) {
641-
best = candidate
642-
}
643-
}
644-
if best.IsIDEBundled && !candidate.IsIDEBundled {
636+
if !candidateIsManaged && !bestIsManaged {
637+
if candidate.Version.GreaterThan(best.Version) {
645638
best = candidate
646639
}
640+
continue
647641
}
648-
if !bestIsManaged && candidateIsManaged {
642+
if !candidateIsManaged {
643+
continue
644+
}
645+
if !bestIsManaged {
649646
best = candidate
650647
bestIsManaged = true
648+
} else if candidate.Version.GreaterThan(best.Version) {
649+
best = candidate
651650
}
652651
debug("current best", best)
653652
}

Diff for: internal/cli/configuration/directories.go

-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ func HardwareDirectories(settings *viper.Viper) paths.PathList {
4242
return res
4343
}
4444

45-
// BuiltinToolsDirectories returns all paths that may contains bundled-tools.
46-
func BuiltinToolsDirectories(settings *viper.Viper) paths.PathList {
47-
return paths.NewPathList(settings.GetStringSlice("directories.builtin.Tools")...)
48-
}
49-
5045
// IDEBuiltinLibrariesDir returns the IDE-bundled libraries path. Usually
5146
// this directory is present in the Arduino IDE.
5247
func IDEBuiltinLibrariesDir(settings *viper.Viper) *paths.Path {

Diff for: internal/integrationtest/compile_4/compile_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,6 @@ func TestBuildOptionsFile(t *testing.T) {
10301030

10311031
requirejson.Query(t, buildOptionsBytes, "keys", `[
10321032
"additionalFiles",
1033-
"builtInToolsFolders",
10341033
"compiler.optimization_flags",
10351034
"customBuildProperties",
10361035
"fqbn",

Diff for: internal/integrationtest/core/core_test.go

+55
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/hex"
2121
"fmt"
2222
"os"
23+
"path/filepath"
2324
"runtime"
2425
"sort"
2526
"strconv"
@@ -518,6 +519,60 @@ func TestCoreListAllManuallyInstalledCore(t *testing.T) {
518519
]}`)
519520
}
520521

522+
func TestCoreListShowsLatestVersionWhenMultipleReleasesOfAManuallyInstalledCoreArePresent(t *testing.T) {
523+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
524+
defer env.CleanUp()
525+
526+
_, _, err := cli.Run("core", "update-index")
527+
require.NoError(t, err)
528+
529+
// Verifies only cores in board manager are shown
530+
stdout, _, err := cli.Run("core", "list", "--all", "--format", "json")
531+
require.NoError(t, err)
532+
requirejson.Query(t, stdout, `.platforms | length > 0`, `true`)
533+
length, err := strconv.Atoi(requirejson.Parse(t, stdout).Query(".platforms | length").String())
534+
require.NoError(t, err)
535+
536+
// Manually installs a core in sketchbooks hardware folder
537+
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
538+
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr")
539+
_, err = git.PlainClone(filepath.Join(repoDir.String(), "1.8.3"), false, &git.CloneOptions{
540+
URL: gitUrl,
541+
ReferenceName: plumbing.NewTagReferenceName("1.8.3"),
542+
})
543+
require.NoError(t, err)
544+
545+
tmp := paths.New(t.TempDir(), "1.8.4")
546+
_, err = git.PlainClone(tmp.String(), false, &git.CloneOptions{
547+
URL: gitUrl,
548+
ReferenceName: plumbing.NewTagReferenceName("1.8.4"),
549+
})
550+
require.NoError(t, err)
551+
552+
err = tmp.Rename(repoDir.Join("1.8.4"))
553+
require.NoError(t, err)
554+
555+
// When manually installing 2 releases of the same core, the newest one takes precedence
556+
stdout, _, err = cli.Run("core", "list", "--all", "--format", "json")
557+
require.NoError(t, err)
558+
requirejson.Query(t, stdout, `.platforms | length`, fmt.Sprint(length+1))
559+
requirejson.Contains(t, stdout, `{"platforms":[
560+
{
561+
"id": "arduino-beta-development:avr",
562+
"latest_version": "1.8.4",
563+
"installed_version": "1.8.4",
564+
"releases": {
565+
"1.8.3": {
566+
"name": "Arduino AVR Boards"
567+
},
568+
"1.8.3": {
569+
"name": "Arduino AVR Boards"
570+
}
571+
}
572+
}
573+
]}`)
574+
}
575+
521576
func TestCoreListUpdatableAllFlags(t *testing.T) {
522577
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
523578
defer env.CleanUp()

0 commit comments

Comments
 (0)