From b4d3af459e0c55de0634b9662299191968d7ffc6 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 13 Jun 2022 11:48:30 +0200 Subject: [PATCH] Do library rescan on compile (if no profies are used) Fix #1755 --- arduino/cores/packagemanager/package_manager.go | 7 +++++++ arduino/cores/packagemanager/profiles.go | 2 ++ commands/compile/compile.go | 7 +++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arduino/cores/packagemanager/package_manager.go b/arduino/cores/packagemanager/package_manager.go index 960cea53827..dd98284b17f 100644 --- a/arduino/cores/packagemanager/package_manager.go +++ b/arduino/cores/packagemanager/package_manager.go @@ -24,6 +24,7 @@ import ( "github.com/arduino/arduino-cli/arduino/cores" "github.com/arduino/arduino-cli/arduino/cores/packageindex" "github.com/arduino/arduino-cli/arduino/discovery/discoverymanager" + "github.com/arduino/arduino-cli/arduino/sketch" "github.com/arduino/arduino-cli/i18n" paths "github.com/arduino/go-paths-helper" properties "github.com/arduino/go-properties-orderedmap" @@ -44,6 +45,7 @@ type PackageManager struct { DownloadDir *paths.Path TempDir *paths.Path CustomGlobalProperties *properties.Map + profile *sketch.Profile discoveryManager *discoverymanager.DiscoveryManager userAgent string } @@ -65,6 +67,11 @@ func NewPackageManager(indexDir, packagesDir, downloadDir, tempDir *paths.Path, } } +// GetProfile returns the active profile for this package manager, or nil if no profile is selected. +func (pm *PackageManager) GetProfile() *sketch.Profile { + return pm.profile +} + // GetEnvVarsForSpawnedProcess produces a set of environment variables that // must be sent to all processes spawned from the arduino-cli. func (pm *PackageManager) GetEnvVarsForSpawnedProcess() []string { diff --git a/arduino/cores/packagemanager/profiles.go b/arduino/cores/packagemanager/profiles.go index 30bf9a69cc5..abe74a36860 100644 --- a/arduino/cores/packagemanager/profiles.go +++ b/arduino/cores/packagemanager/profiles.go @@ -33,6 +33,8 @@ import ( // LoadHardwareForProfile load the hardware platforms for the given profile. // If installMissing is true then possibly missing tools and platforms will be downloaded and installed. func (pm *PackageManager) LoadHardwareForProfile(p *sketch.Profile, installMissing bool, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) []error { + pm.profile = p + // Load required platforms var merr []error var platformReleases []*cores.PlatformRelease diff --git a/commands/compile/compile.go b/commands/compile/compile.go index 234fed5b977..f0e3c01538b 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -111,7 +111,9 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream builderCtx := &types.Context{} builderCtx.PackageManager = pm - builderCtx.LibrariesManager = lm + if pm.GetProfile() != nil { + builderCtx.LibrariesManager = lm + } builderCtx.FQBN = fqbn builderCtx.SketchLocation = sk.FullPath builderCtx.ProgressCB = progressCB @@ -124,9 +126,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream builderCtx.OtherLibrariesDirs = paths.NewPathList(req.GetLibraries()...) builderCtx.OtherLibrariesDirs.Add(configuration.LibrariesDir(configuration.Settings)) builderCtx.LibraryDirs = paths.NewPathList(req.Library...) - if len(req.GetLibraries()) > 0 || len(req.GetLibrary()) > 0 { - builderCtx.LibrariesManager = nil // let the builder rebuild the library manager - } if req.GetBuildPath() == "" { builderCtx.BuildPath = sk.BuildPath } else {