Skip to content

Commit 3c1cda2

Browse files
committed
Builder allows loading of global user-customizable platform.txt
Fix #469
1 parent cf3750c commit 3c1cda2

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

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

+11
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
7777
for _, packagerPath := range files {
7878
packager := packagerPath.Base()
7979

80+
// Load custom platform properties if available
81+
if packager == "platform.txt" {
82+
pm.Log.Infof("Loading custom platform properties: %s", packagerPath)
83+
if p, err := properties.LoadFromPath(packagerPath); err != nil {
84+
pm.Log.WithError(err).Errorf("Error loading properties.")
85+
} else {
86+
pm.CustomGlobalProperties.Merge(p)
87+
}
88+
continue
89+
}
90+
8091
// First exclude all "tools" directory
8192
if packager == "tools" {
8293
pm.Log.Infof("Excluding directory: %s", packagerPath)

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

+14-12
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,25 @@ import (
3838
// The manager also keeps track of the status of the Packages (their Platform Releases, actually)
3939
// installed in the system.
4040
type PackageManager struct {
41-
Log logrus.FieldLogger
42-
Packages cores.Packages
43-
IndexDir *paths.Path
44-
PackagesDir *paths.Path
45-
DownloadDir *paths.Path
46-
TempDir *paths.Path
41+
Log logrus.FieldLogger
42+
Packages cores.Packages
43+
IndexDir *paths.Path
44+
PackagesDir *paths.Path
45+
DownloadDir *paths.Path
46+
TempDir *paths.Path
47+
CustomGlobalProperties *properties.Map
4748
}
4849

4950
// NewPackageManager returns a new instance of the PackageManager
5051
func NewPackageManager(indexDir, packagesDir, downloadDir, tempDir *paths.Path) *PackageManager {
5152
return &PackageManager{
52-
Log: logrus.StandardLogger(),
53-
Packages: cores.NewPackages(),
54-
IndexDir: indexDir,
55-
PackagesDir: packagesDir,
56-
DownloadDir: downloadDir,
57-
TempDir: tempDir,
53+
Log: logrus.StandardLogger(),
54+
Packages: cores.NewPackages(),
55+
IndexDir: indexDir,
56+
PackagesDir: packagesDir,
57+
DownloadDir: downloadDir,
58+
TempDir: tempDir,
59+
CustomGlobalProperties: properties.NewMap(),
5860
}
5961
}
6062

Diff for: legacy/builder/setup_build_properties.go

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ func (s *SetupBuildProperties) Run(ctx *types.Context) error {
127127
buildProperties.Set("extra.time.zone", strconv.Itoa(timeutils.TimezoneOffsetNoDST(now)))
128128
buildProperties.Set("extra.time.dst", strconv.Itoa(timeutils.DaylightSavingsOffset(now)))
129129

130+
buildProperties.Merge(ctx.PackageManager.CustomGlobalProperties)
131+
130132
ctx.BuildProperties = buildProperties
131133

132134
return nil

0 commit comments

Comments
 (0)