Skip to content

Commit

Permalink
Do library rescan on compile (if no profies are used) (#1758)
Browse files Browse the repository at this point in the history
Fix #1755
  • Loading branch information
cmaglie authored Jun 13, 2022
1 parent c350e88 commit 427af56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions arduino/cores/packagemanager/package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -44,6 +45,7 @@ type PackageManager struct {
DownloadDir *paths.Path
TempDir *paths.Path
CustomGlobalProperties *properties.Map
profile *sketch.Profile
discoveryManager *discoverymanager.DiscoveryManager
userAgent string
}
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions arduino/cores/packagemanager/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 427af56

Please sign in to comment.