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
8874d91b
Commit
8874d91b
authored
May 23, 2019
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved tool Install/Download helpers from commands/core to commands
parent
6ec261e6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
41 deletions
+65
-41
commands/board/list.go
commands/board/list.go
+3
-5
commands/bundled_tools.go
commands/bundled_tools.go
+58
-0
commands/compile/compile.go
commands/compile/compile.go
+2
-3
commands/core/download.go
commands/core/download.go
+1
-9
commands/core/install.go
commands/core/install.go
+1
-24
No files found.
commands/board/list.go
View file @
8874d91b
...
...
@@ -26,7 +26,6 @@ import (
"github.com/arduino/arduino-cli/arduino/discovery"
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/rpc"
)
...
...
@@ -42,8 +41,8 @@ func BoardList(ctx context.Context, req *rpc.BoardListReq) (*rpc.BoardListResp,
serialDiscoveryTool
,
_
:=
getBuiltinSerialDiscoveryTool
(
pm
)
if
!
serialDiscoveryTool
.
IsInstalled
()
{
formatter
.
Print
(
"Downloading and installing missing tool: "
+
serialDiscoveryTool
.
String
())
co
re
.
DownloadToolRelease
(
pm
,
serialDiscoveryTool
,
cli
.
OutputProgressBar
())
co
re
.
InstallToolRelease
(
pm
,
serialDiscoveryTool
,
cli
.
OutputTaskProgress
())
co
mmands
.
DownloadToolRelease
(
pm
,
serialDiscoveryTool
,
cli
.
OutputProgressBar
())
co
mmands
.
InstallToolRelease
(
pm
,
serialDiscoveryTool
,
cli
.
OutputTaskProgress
())
if
err
:=
pm
.
LoadHardware
(
cli
.
Config
);
err
!=
nil
{
formatter
.
PrintError
(
err
,
"Could not load hardware packages."
)
...
...
@@ -63,8 +62,7 @@ func BoardList(ctx context.Context, req *rpc.BoardListReq) (*rpc.BoardListResp,
}
// Find all installed discoveries
discoveries
:=
discovery
.
ExtractDiscoveriesFromPlatforms
(
pm
)
discoveries
[
"serial"
]
=
serialDiscovery
discoveries
:=
append
(
discovery
.
ExtractDiscoveriesFromPlatforms
(
pm
),
serialDiscovery
)
resp
:=
&
rpc
.
BoardListResp
{
Ports
:
[]
*
rpc
.
DetectedPort
{}}
for
_
,
disc
:=
range
discoveries
{
...
...
commands/bundled_tools.go
0 → 100644
View file @
8874d91b
//
// This file is part of arduino-cli.
//
// Copyright 2018 ARDUINO SA (http://www.arduino.cc/)
//
// This software is released under the GNU General Public License version 3,
// which covers the main part of arduino-cli.
// The terms of this license can be found at:
// https://www.gnu.org/licenses/gpl-3.0.en.html
//
// You can be released from the requirements of the above licenses by purchasing
// a commercial license. Buying such a license is mandatory if you want to modify or
// otherwise use the software for commercial activities involving the Arduino
// software without disclosing the source code of your own applications. To purchase
// a commercial license, send an email to license@arduino.cc.
//
package
commands
import
(
"fmt"
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/rpc"
)
// DownloadToolRelease downloads a ToolRelease
func
DownloadToolRelease
(
pm
*
packagemanager
.
PackageManager
,
toolRelease
*
cores
.
ToolRelease
,
downloadCB
DownloadProgressCB
)
error
{
resp
,
err
:=
pm
.
DownloadToolRelease
(
toolRelease
)
if
err
!=
nil
{
return
err
}
return
Download
(
resp
,
toolRelease
.
String
(),
downloadCB
)
}
// InstallToolRelease installs a ToolRelease
func
InstallToolRelease
(
pm
*
packagemanager
.
PackageManager
,
toolRelease
*
cores
.
ToolRelease
,
taskCB
TaskProgressCB
)
error
{
log
:=
pm
.
Log
.
WithField
(
"Tool"
,
toolRelease
)
if
toolRelease
.
IsInstalled
()
{
log
.
Warn
(
"Tool already installed"
)
taskCB
(
&
rpc
.
TaskProgress
{
Name
:
"Tool "
+
toolRelease
.
String
()
+
" already installed"
,
Completed
:
true
})
return
nil
}
log
.
Info
(
"Installing tool"
)
taskCB
(
&
rpc
.
TaskProgress
{
Name
:
"Installing "
+
toolRelease
.
String
()})
err
:=
pm
.
InstallTool
(
toolRelease
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Warn
(
"Cannot install tool"
)
return
fmt
.
Errorf
(
"installing tool %s: %s"
,
toolRelease
,
err
)
}
log
.
Info
(
"Tool installed"
)
taskCB
(
&
rpc
.
TaskProgress
{
Message
:
toolRelease
.
String
()
+
" installed"
,
Completed
:
true
})
return
nil
}
commands/compile/compile.go
View file @
8874d91b
...
...
@@ -17,7 +17,6 @@ import (
"github.com/arduino/arduino-cli/arduino/sketches"
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/rpc"
paths
"github.com/arduino/go-paths-helper"
properties
"github.com/arduino/go-properties-orderedmap"
...
...
@@ -60,9 +59,9 @@ func Compile(ctx context.Context, req *rpc.CompileReq,
ctags
,
_
:=
getBuiltinCtagsTool
(
pm
)
if
!
ctags
.
IsInstalled
()
{
taskCB
(
&
rpc
.
TaskProgress
{
Name
:
"Downloading missing tool "
+
ctags
.
String
()})
co
re
.
DownloadToolRelease
(
pm
,
ctags
,
downloadCB
)
co
mmands
.
DownloadToolRelease
(
pm
,
ctags
,
downloadCB
)
taskCB
(
&
rpc
.
TaskProgress
{
Completed
:
true
})
co
re
.
InstallToolRelease
(
pm
,
ctags
,
taskCB
)
co
mmands
.
InstallToolRelease
(
pm
,
ctags
,
taskCB
)
if
err
:=
pm
.
LoadHardware
(
cli
.
Config
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"loading hardware packages: %s"
,
err
)
...
...
commands/core/download.go
View file @
8874d91b
...
...
@@ -78,14 +78,6 @@ func downloadTool(pm *packagemanager.PackageManager, tool *cores.ToolRelease, do
return
fmt
.
Errorf
(
"tool %s not available for the current OS"
,
tool
)
}
return
DownloadToolRelease
(
pm
,
tool
,
downloadCB
)
return
commands
.
DownloadToolRelease
(
pm
,
tool
,
downloadCB
)
}
// DownloadToolRelease downloads a ToolRelease
func
DownloadToolRelease
(
pm
*
packagemanager
.
PackageManager
,
toolRelease
*
cores
.
ToolRelease
,
downloadCB
commands
.
DownloadProgressCB
)
error
{
resp
,
err
:=
pm
.
DownloadToolRelease
(
toolRelease
)
if
err
!=
nil
{
return
err
}
return
commands
.
Download
(
resp
,
toolRelease
.
String
(),
downloadCB
)
}
commands/core/install.go
View file @
8874d91b
...
...
@@ -94,7 +94,7 @@ func installPlatform(pm *packagemanager.PackageManager,
// Install tools first
for
_
,
tool
:=
range
toolsToInstall
{
err
:=
InstallToolRelease
(
pm
,
tool
,
taskCB
)
err
:=
commands
.
InstallToolRelease
(
pm
,
tool
,
taskCB
)
if
err
!=
nil
{
// TODO: handle error
}
...
...
@@ -141,26 +141,3 @@ func installPlatform(pm *packagemanager.PackageManager,
taskCB
(
&
rpc
.
TaskProgress
{
Message
:
platformRelease
.
String
()
+
" installed"
,
Completed
:
true
})
return
nil
}
// InstallToolRelease installs a ToolRelease
func
InstallToolRelease
(
pm
*
packagemanager
.
PackageManager
,
toolRelease
*
cores
.
ToolRelease
,
taskCB
commands
.
TaskProgressCB
)
error
{
log
:=
pm
.
Log
.
WithField
(
"Tool"
,
toolRelease
)
if
toolRelease
.
IsInstalled
()
{
log
.
Warn
(
"Tool already installed"
)
taskCB
(
&
rpc
.
TaskProgress
{
Name
:
"Tool "
+
toolRelease
.
String
()
+
" already installed"
,
Completed
:
true
})
return
nil
}
log
.
Info
(
"Installing tool"
)
taskCB
(
&
rpc
.
TaskProgress
{
Name
:
"Installing "
+
toolRelease
.
String
()})
err
:=
pm
.
InstallTool
(
toolRelease
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Warn
(
"Cannot install tool"
)
return
fmt
.
Errorf
(
"installing tool %s: %s"
,
toolRelease
,
err
)
}
log
.
Info
(
"Tool installed"
)
taskCB
(
&
rpc
.
TaskProgress
{
Message
:
toolRelease
.
String
()
+
" installed"
,
Completed
:
true
})
return
nil
}
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