Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
0888f0f5
Commit
0888f0f5
authored
Sep 12, 2018
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pick the correct version for packages bundled in the IDE
See #28
parent
88f08c07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
3 deletions
+37
-3
arduino/cores/packagemanager/loader.go
arduino/cores/packagemanager/loader.go
+29
-0
arduino/cores/packagemanager/package_manager.go
arduino/cores/packagemanager/package_manager.go
+8
-3
No files found.
arduino/cores/packagemanager/loader.go
View file @
0888f0f5
...
...
@@ -164,6 +164,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
}
else
if
exist
{
// case: ARCHITECTURE/boards.txt
// this is the general case for unversioned Platform
version
:=
semver
.
MustParse
(
""
)
// FIXME: this check is duplicated, find a better way to handle this
...
...
@@ -173,6 +174,34 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
continue
}
// check if package_bundled_index.json exists
packageBundledIndexPath
:=
packageDir
.
Parent
()
.
Join
(
"package_index_bundled.json"
)
if
packageBundledIndexPath
.
Exist
()
{
// particular case: ARCHITECTURE/boards.txt with package_bundled_index.json
// this is an unversioned Platform with a package_index_bundled.json that
// gives information about the version and tools needed
// Parse the bundled index and merge to the general index
index
,
err
:=
pm
.
LoadPackageIndexFromFile
(
packageBundledIndexPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"parsing IDE bundled index: %s"
,
err
)
}
// Now export the bundled index in a temporary core.Packages to retrieve the bundled package version
tmp
:=
cores
.
NewPackages
()
index
.
MergeIntoPackages
(
tmp
)
if
tmpPackage
:=
tmp
.
GetOrCreatePackage
(
targetPackage
.
Name
);
tmpPackage
==
nil
{
pm
.
Log
.
Warnf
(
"Can't determine bundle platform version for %s"
,
targetPackage
.
Name
)
}
else
if
tmpPlatform
:=
tmpPackage
.
GetOrCreatePlatform
(
architecure
);
tmpPlatform
==
nil
{
pm
.
Log
.
Warnf
(
"Can't determine bundle platform version for %s:%s"
,
targetPackage
.
Name
,
architecure
)
}
else
if
tmpPlatformRelease
:=
tmpPlatform
.
GetLatestRelease
();
tmpPlatformRelease
==
nil
{
pm
.
Log
.
Warnf
(
"Can't determine bundle platform version for %s:%s, no valid release found"
,
targetPackage
.
Name
,
architecure
)
}
else
{
version
=
tmpPlatformRelease
.
Version
}
}
platform
:=
targetPackage
.
GetOrCreatePlatform
(
architecure
)
release
,
err
:=
platform
.
GetOrCreateRelease
(
version
)
if
err
!=
nil
{
...
...
arduino/cores/packagemanager/package_manager.go
View file @
0888f0f5
...
...
@@ -198,14 +198,19 @@ func (pm *PackageManager) ResolveFQBN(fqbn *cores.FQBN) (
// LoadPackageIndex loads a package index by looking up the local cached file from the specified URL
func
(
pm
*
PackageManager
)
LoadPackageIndex
(
URL
*
url
.
URL
)
error
{
indexPath
:=
pm
.
IndexDir
.
Join
(
path
.
Base
(
URL
.
Path
))
_
,
err
:=
pm
.
LoadPackageIndexFromFile
(
pm
.
IndexDir
.
Join
(
path
.
Base
(
URL
.
Path
)))
return
err
}
// LoadPackageIndexFromFile load a package index from the specified file
func
(
pm
*
PackageManager
)
LoadPackageIndexFromFile
(
indexPath
*
paths
.
Path
)
(
*
packageindex
.
Index
,
error
)
{
index
,
err
:=
packageindex
.
LoadIndex
(
indexPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"loading json index file %s: %s"
,
indexPath
,
err
)
return
nil
,
fmt
.
Errorf
(
"loading json index file %s: %s"
,
indexPath
,
err
)
}
index
.
MergeIntoPackages
(
pm
.
packages
)
return
nil
return
index
,
nil
}
// Package looks for the Package with the given name, returning a structure
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment