Skip to content

Commit b4d3af4

Browse files
committed
Do library rescan on compile (if no profies are used)
Fix arduino#1755
1 parent 899dc91 commit b4d3af4

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/arduino/arduino-cli/arduino/cores"
2525
"github.com/arduino/arduino-cli/arduino/cores/packageindex"
2626
"github.com/arduino/arduino-cli/arduino/discovery/discoverymanager"
27+
"github.com/arduino/arduino-cli/arduino/sketch"
2728
"github.com/arduino/arduino-cli/i18n"
2829
paths "github.com/arduino/go-paths-helper"
2930
properties "github.com/arduino/go-properties-orderedmap"
@@ -44,6 +45,7 @@ type PackageManager struct {
4445
DownloadDir *paths.Path
4546
TempDir *paths.Path
4647
CustomGlobalProperties *properties.Map
48+
profile *sketch.Profile
4749
discoveryManager *discoverymanager.DiscoveryManager
4850
userAgent string
4951
}
@@ -65,6 +67,11 @@ func NewPackageManager(indexDir, packagesDir, downloadDir, tempDir *paths.Path,
6567
}
6668
}
6769

70+
// GetProfile returns the active profile for this package manager, or nil if no profile is selected.
71+
func (pm *PackageManager) GetProfile() *sketch.Profile {
72+
return pm.profile
73+
}
74+
6875
// GetEnvVarsForSpawnedProcess produces a set of environment variables that
6976
// must be sent to all processes spawned from the arduino-cli.
7077
func (pm *PackageManager) GetEnvVarsForSpawnedProcess() []string {

Diff for: arduino/cores/packagemanager/profiles.go

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import (
3333
// LoadHardwareForProfile load the hardware platforms for the given profile.
3434
// If installMissing is true then possibly missing tools and platforms will be downloaded and installed.
3535
func (pm *PackageManager) LoadHardwareForProfile(p *sketch.Profile, installMissing bool, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) []error {
36+
pm.profile = p
37+
3638
// Load required platforms
3739
var merr []error
3840
var platformReleases []*cores.PlatformRelease

Diff for: commands/compile/compile.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
111111

112112
builderCtx := &types.Context{}
113113
builderCtx.PackageManager = pm
114-
builderCtx.LibrariesManager = lm
114+
if pm.GetProfile() != nil {
115+
builderCtx.LibrariesManager = lm
116+
}
115117
builderCtx.FQBN = fqbn
116118
builderCtx.SketchLocation = sk.FullPath
117119
builderCtx.ProgressCB = progressCB
@@ -124,9 +126,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
124126
builderCtx.OtherLibrariesDirs = paths.NewPathList(req.GetLibraries()...)
125127
builderCtx.OtherLibrariesDirs.Add(configuration.LibrariesDir(configuration.Settings))
126128
builderCtx.LibraryDirs = paths.NewPathList(req.Library...)
127-
if len(req.GetLibraries()) > 0 || len(req.GetLibrary()) > 0 {
128-
builderCtx.LibrariesManager = nil // let the builder rebuild the library manager
129-
}
130129
if req.GetBuildPath() == "" {
131130
builderCtx.BuildPath = sk.BuildPath
132131
} else {

0 commit comments

Comments
 (0)