Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do library rescan on compile (if no profies are used) #1758

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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