Skip to content

Commit c1440d0

Browse files
Drop support of package_bundled_index.json and builtin_tools_versions.txt
1 parent 0e21e6f commit c1440d0

File tree

8 files changed

+11
-153
lines changed

8 files changed

+11
-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: 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

+6-13
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,14 @@ 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 {
645-
best = candidate
646-
}
636+
if !candidateIsManaged {
637+
continue
647638
}
648-
if !bestIsManaged && candidateIsManaged {
639+
if !bestIsManaged {
649640
best = candidate
650641
bestIsManaged = true
642+
} else if candidate.Version.GreaterThan(best.Version) {
643+
best = candidate
651644
}
652645
debug("current best", best)
653646
}

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",

0 commit comments

Comments
 (0)