Skip to content

Commit 1b8bf63

Browse files
committed
Renamed field Folder->InstallDir
1 parent b5ce410 commit 1b8bf63

File tree

19 files changed

+95
-86
lines changed

19 files changed

+95
-86
lines changed

Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arduino/cores/cores.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type PlatformRelease struct {
6262
Boards map[string]*Board `json:"-"`
6363
Programmers map[string]properties.Map `json:"-"`
6464
Menus map[string]string `json:"-"`
65-
Folder string `json:"-"`
65+
InstallDir *paths.Path `json:"-"`
6666
}
6767

6868
// BoardManifest contains information about a board. These metadata are usually
@@ -166,7 +166,7 @@ func (platform *Platform) latestReleaseVersion() string {
166166
// arduino-builder, it will be probably removed in the future
167167
func (platform *Platform) GetInstalled() *PlatformRelease {
168168
for _, release := range platform.Releases {
169-
if release.Folder != "" {
169+
if release.InstallDir != nil {
170170
return release
171171
}
172172
}
@@ -195,14 +195,14 @@ func (release *PlatformRelease) GetOrCreateBoard(boardID string) *Board {
195195
// RuntimeProperties returns the runtime properties for this PlatformRelease
196196
func (release *PlatformRelease) RuntimeProperties() properties.Map {
197197
return properties.Map{
198-
"runtime.platform.path": release.Folder,
198+
"runtime.platform.path": release.InstallDir.String(),
199199
}
200200
}
201201

202202
// GetLibrariesDir returns the path to the core libraries or nil if not
203203
// present
204204
func (release *PlatformRelease) GetLibrariesDir() *paths.Path {
205-
libDir := paths.New(release.Folder).Join("libraries")
205+
libDir := release.InstallDir.Join("libraries")
206206
if isDir, _ := libDir.IsDir(); isDir {
207207
return libDir
208208
}

arduino/cores/packagemanager/loader.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,13 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageFol
231231
return nil
232232
}
233233

234-
func (pm *PackageManager) loadPlatformRelease(platform *cores.PlatformRelease, folder *paths.Path) error {
235-
// TODO: Change platform.Folder into *paths.Path
236-
platform.Folder = folder.String()
234+
func (pm *PackageManager) loadPlatformRelease(platform *cores.PlatformRelease, path *paths.Path) error {
235+
platform.InstallDir = path
237236

238237
// Some useful paths
239-
platformTxtPath := folder.Join("platform.txt")
240-
platformTxtLocalPath := folder.Join("platform.local.txt")
241-
programmersTxtPath := folder.Join("programmers.txt")
238+
platformTxtPath := path.Join("platform.txt")
239+
platformTxtLocalPath := path.Join("platform.local.txt")
240+
programmersTxtPath := path.Join("programmers.txt")
242241

243242
// Create platform properties
244243
platform.Properties = platform.Properties.Clone() // TODO: why CLONE?
@@ -271,17 +270,18 @@ func (pm *PackageManager) loadPlatformRelease(platform *cores.PlatformRelease, f
271270
}
272271

273272
func (pm *PackageManager) loadBoards(platform *cores.PlatformRelease) error {
274-
if platform.Folder == "" {
273+
if platform.InstallDir == nil {
275274
return fmt.Errorf("platform not installed")
276275
}
277-
boardsTxtPath := filepath.Join(platform.Folder, "boards.txt")
278-
boardsLocalTxtPath := filepath.Join(platform.Folder, "boards.local.txt")
279276

280-
boardsProperties, err := properties.Load(boardsTxtPath)
277+
boardsTxtPath := platform.InstallDir.Join("boards.txt")
278+
boardsProperties, err := properties.LoadFromPath(boardsTxtPath)
281279
if err != nil {
282280
return err
283281
}
284-
if localProperties, err := properties.SafeLoad(boardsLocalTxtPath); err == nil {
282+
283+
boardsLocalTxtPath := platform.InstallDir.Join("boards.local.txt")
284+
if localProperties, err := properties.SafeLoadFromPath(boardsLocalTxtPath); err == nil {
285285
boardsProperties.Merge(localProperties)
286286
} else {
287287
return err
@@ -333,7 +333,7 @@ func (pm *PackageManager) loadToolReleasesFromTool(tool *cores.Tool, toolPath *p
333333
if toolReleasePath, err := versionPath.Abs(); err == nil {
334334
release := tool.GetOrCreateRelease(version)
335335
// TODO: Make Folder a *paths.Path
336-
release.Folder = toolReleasePath.String()
336+
release.InstallDir = toolReleasePath
337337
pm.Log.WithField("tool", release).Infof("Loaded tool")
338338
} else {
339339
return err
@@ -388,7 +388,7 @@ func (pm *PackageManager) LoadToolsFromBundleDirectory(toolsPath *paths.Path) er
388388
// If builtin_tools_versions.txt is found create tools based on the info
389389
// contained in that file
390390
pm.Log.Infof("Found builtin_tools_versions.txt")
391-
toolPath, err := filepath.Abs(filepath.Dir(builtinToolsVersionsTxtPath))
391+
toolPath, err := paths.New(builtinToolsVersionsTxtPath).Parent().Abs()
392392
if err != nil {
393393
return fmt.Errorf("getting parent dir of %s: %s", builtinToolsVersionsTxtPath, err)
394394
}
@@ -404,7 +404,7 @@ func (pm *PackageManager) LoadToolsFromBundleDirectory(toolsPath *paths.Path) er
404404
for toolName, toolVersion := range toolsData {
405405
tool := targetPackage.GetOrCreateTool(toolName)
406406
release := tool.GetOrCreateRelease(toolVersion)
407-
release.Folder = toolPath
407+
release.InstallDir = toolPath
408408
pm.Log.WithField("tool", release).Infof("Loaded tool")
409409
}
410410
}

arduino/cores/tools.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import (
3434
"regexp"
3535
"runtime"
3636

37+
"github.com/arduino/go-paths-helper"
38+
3739
properties "github.com/arduino/go-properties-map"
3840
"github.com/bcmi-labs/arduino-cli/arduino/resources"
3941

@@ -49,10 +51,10 @@ type Tool struct {
4951

5052
// ToolRelease represents a single release of a tool
5153
type ToolRelease struct {
52-
Version string `json:"version,required"` // The version number of this Release.
53-
Flavours []*Flavour `json:"systems"` // Maps OS to Flavour
54-
Tool *Tool `json:"-"`
55-
Folder string `json:"-"`
54+
Version string `json:"version,required"` // The version number of this Release.
55+
Flavours []*Flavour `json:"systems"` // Maps OS to Flavour
56+
Tool *Tool `json:"-"`
57+
InstallDir *paths.Path `json:"-"`
5658
}
5759

5860
// Flavour represents a flavour of a Tool version.
@@ -139,7 +141,7 @@ func (tool *Tool) String() string {
139141

140142
// IsInstalled returns true if the ToolRelease is installed
141143
func (tr *ToolRelease) IsInstalled() bool {
142-
return tr.Folder != ""
144+
return tr.InstallDir != nil
143145
}
144146

145147
func (tr *ToolRelease) String() string {
@@ -149,8 +151,8 @@ func (tr *ToolRelease) String() string {
149151
// RuntimeProperties returns the runtime properties for this tool
150152
func (tr *ToolRelease) RuntimeProperties() properties.Map {
151153
return properties.Map{
152-
"runtime.tools." + tr.Tool.Name + ".path": tr.Folder,
153-
"runtime.tools." + tr.Tool.Name + "-" + tr.Version + ".path": tr.Folder,
154+
"runtime.tools." + tr.Tool.Name + ".path": tr.InstallDir.String(),
155+
"runtime.tools." + tr.Tool.Name + "-" + tr.Version + ".path": tr.InstallDir.String(),
154156
}
155157
}
156158

arduino/libraries/libraries.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ type Library struct {
6464

6565
Types []string `json:"types,omitempty"`
6666

67-
Folder *paths.Path
68-
SrcFolder *paths.Path
69-
UtilityFolder *paths.Path
67+
InstallDir *paths.Path
68+
SourceDir *paths.Path
69+
UtilityDir *paths.Path
7070
Location LibraryLocation
7171
ContainerPlatform *cores.PlatformRelease `json:""`
7272
Layout LibraryLayout
@@ -154,7 +154,7 @@ func (library *Library) PriorityForArchitecture(arch string) uint8 {
154154

155155
// SourceDir represents a source dir of a library
156156
type SourceDir struct {
157-
Folder *paths.Path
157+
Dir *paths.Path
158158
Recurse bool
159159
}
160160

@@ -163,13 +163,13 @@ func (library *Library) SourceDirs() []SourceDir {
163163
dirs := []SourceDir{}
164164
dirs = append(dirs,
165165
SourceDir{
166-
Folder: library.SrcFolder,
166+
Dir: library.SourceDir,
167167
Recurse: library.Layout == RecursiveLayout,
168168
})
169-
if library.UtilityFolder != nil {
169+
if library.UtilityDir != nil {
170170
dirs = append(dirs,
171171
SourceDir{
172-
Folder: library.UtilityFolder,
172+
Dir: library.UtilityDir,
173173
Recurse: false,
174174
})
175175
}

arduino/libraries/librariesmanager/install.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release) (*path
5050
continue
5151
}
5252
if installedLib.Version == indexLibrary.Version {
53-
return installedLib.Folder, fmt.Errorf("%s is already installed", indexLibrary.String())
53+
return installedLib.InstallDir, fmt.Errorf("%s is already installed", indexLibrary.String())
5454
}
5555
replaced = installedLib
5656
}
@@ -62,7 +62,7 @@ func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release) (*path
6262
}
6363

6464
libPath := libsDir.Join(utils.SanitizeName(indexLibrary.Library.Name))
65-
if replaced != nil && replaced.Folder.EquivalentTo(libPath) {
65+
if replaced != nil && replaced.InstallDir.EquivalentTo(libPath) {
6666
formatter.Print(fmt.Sprintf("Replacing %s with %s", replaced, indexLibrary))
6767
} else if isdir, _ := libPath.IsDir(); isdir {
6868
return nil, fmt.Errorf("destination dir %s already exists, cannot install", libPath)
@@ -72,7 +72,7 @@ func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release) (*path
7272

7373
// Uninstall removes a Library
7474
func (lm *LibrariesManager) Uninstall(lib *libraries.Library) error {
75-
if err := lib.Folder.RemoveAll(); err != nil {
75+
if err := lib.InstallDir.RemoveAll(); err != nil {
7676
return fmt.Errorf("removing lib directory: %s", err)
7777
}
7878

arduino/libraries/librariesresolver/cpp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (resolver *Cpp) ScanFromLibrariesManager(lm *librariesmanager.LibrariesMana
6565

6666
// ScanLibrary reads a library to find and cache C++ headers for later retrieval
6767
func (resolver *Cpp) ScanLibrary(lib *libraries.Library) error {
68-
cppHeaders, err := lib.SrcFolder.ReadDir()
68+
cppHeaders, err := lib.SourceDir.ReadDir()
6969
if err != nil {
7070
return fmt.Errorf("reading lib src dir: %s", err)
7171
}

arduino/libraries/loader.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ func Load(libDir *paths.Path, location LibraryLocation) (*Library, error) {
4646
}
4747

4848
func addUtilityFolder(library *Library) {
49-
utilitySourcePath := library.Folder.Join("utility")
49+
utilitySourcePath := library.InstallDir.Join("utility")
5050
if isDir, _ := utilitySourcePath.IsDir(); isDir {
51-
library.UtilityFolder = utilitySourcePath
51+
library.UtilityDir = utilitySourcePath
5252
}
5353
}
5454

@@ -70,13 +70,13 @@ func makeNewLibrary(libraryFolder *paths.Path, location LibraryLocation) (*Libra
7070

7171
library := &Library{}
7272
library.Location = location
73-
library.Folder = libraryFolder
73+
library.InstallDir = libraryFolder
7474
if exist, _ := libraryFolder.Join("src").Exist(); exist {
7575
library.Layout = RecursiveLayout
76-
library.SrcFolder = libraryFolder.Join("src")
76+
library.SourceDir = libraryFolder.Join("src")
7777
} else {
7878
library.Layout = FlatLayout
79-
library.SrcFolder = libraryFolder
79+
library.SourceDir = libraryFolder
8080
addUtilityFolder(library)
8181
}
8282

@@ -118,9 +118,9 @@ func makeNewLibrary(libraryFolder *paths.Path, location LibraryLocation) (*Libra
118118

119119
func makeLegacyLibrary(path *paths.Path, location LibraryLocation) (*Library, error) {
120120
library := &Library{
121-
Folder: path,
121+
InstallDir: path,
122122
Location: location,
123-
SrcFolder: path,
123+
SourceDir: path,
124124
Layout: FlatLayout,
125125
Name: path.Base(),
126126
Architectures: []string{"*"},

common/formatter/output/core_structs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (is PlatformReleases) String() string {
7777
sort.Sort(is)
7878
for _, item := range is {
7979
installed := "No"
80-
if item.Folder != "" {
80+
if item.InstallDir != nil {
8181
installed = "Yes"
8282
}
8383
table.AddRow(item.Platform.String(), item.Version, installed, item.Platform.Name)

vendor/github.com/arduino/arduino-builder/container_find_includes.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/arduino/arduino-builder/create_cmake_rule.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/arduino/arduino-builder/fail_if_imported_library_is_wrong.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)