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

re-allow global user-customizable platform.txt #472

Merged
merged 1 commit into from
Nov 8, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions arduino/cores/packagemanager/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
for _, packagerPath := range files {
packager := packagerPath.Base()

// Load custom platform properties if available
if packager == "platform.txt" {
pm.Log.Infof("Loading custom platform properties: %s", packagerPath)
if p, err := properties.LoadFromPath(packagerPath); err != nil {
pm.Log.WithError(err).Errorf("Error loading properties.")
} else {
pm.CustomGlobalProperties.Merge(p)
}
continue
}

// First exclude all "tools" directory
if packager == "tools" {
pm.Log.Infof("Excluding directory: %s", packagerPath)
Expand Down
26 changes: 14 additions & 12 deletions arduino/cores/packagemanager/package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,25 @@ import (
// The manager also keeps track of the status of the Packages (their Platform Releases, actually)
// installed in the system.
type PackageManager struct {
Log logrus.FieldLogger
Packages cores.Packages
IndexDir *paths.Path
PackagesDir *paths.Path
DownloadDir *paths.Path
TempDir *paths.Path
Log logrus.FieldLogger
Packages cores.Packages
IndexDir *paths.Path
PackagesDir *paths.Path
DownloadDir *paths.Path
TempDir *paths.Path
CustomGlobalProperties *properties.Map
}

// NewPackageManager returns a new instance of the PackageManager
func NewPackageManager(indexDir, packagesDir, downloadDir, tempDir *paths.Path) *PackageManager {
return &PackageManager{
Log: logrus.StandardLogger(),
Packages: cores.NewPackages(),
IndexDir: indexDir,
PackagesDir: packagesDir,
DownloadDir: downloadDir,
TempDir: tempDir,
Log: logrus.StandardLogger(),
Packages: cores.NewPackages(),
IndexDir: indexDir,
PackagesDir: packagesDir,
DownloadDir: downloadDir,
TempDir: tempDir,
CustomGlobalProperties: properties.NewMap(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions legacy/builder/setup_build_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func (s *SetupBuildProperties) Run(ctx *types.Context) error {
buildProperties.Set("extra.time.zone", strconv.Itoa(timeutils.TimezoneOffsetNoDST(now)))
buildProperties.Set("extra.time.dst", strconv.Itoa(timeutils.DaylightSavingsOffset(now)))

buildProperties.Merge(ctx.PackageManager.CustomGlobalProperties)

ctx.BuildProperties = buildProperties

return nil
Expand Down