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
b6a5eb49
Commit
b6a5eb49
authored
May 24, 2019
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Download ctags builtin tool during Init
parent
f027d134
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
47 deletions
+50
-47
cli/compile/compile.go
cli/compile/compile.go
+1
-1
commands/bundled_tools_ctags.go
commands/bundled_tools_ctags.go
+3
-2
commands/bundled_tools_serial_discovery.go
commands/bundled_tools_serial_discovery.go
+1
-0
commands/compile/compile.go
commands/compile/compile.go
+1
-22
commands/instances.go
commands/instances.go
+44
-18
daemon/daemon.go
daemon/daemon.go
+0
-2
rpc/compile.proto
rpc/compile.proto
+0
-2
No files found.
cli/compile/compile.go
View file @
b6a5eb49
...
...
@@ -111,7 +111,7 @@ func run(cmd *cobra.Command, args []string) {
Quiet
:
flags
.
quiet
,
VidPid
:
flags
.
vidPid
,
ExportFile
:
flags
.
exportFile
,
},
os
.
Stdout
,
os
.
Stderr
,
cli
.
OutputTaskProgress
(),
cli
.
OutputProgressBar
()
)
},
os
.
Stdout
,
os
.
Stderr
)
if
err
==
nil
{
outputCompileResp
(
compRes
)
}
else
{
...
...
commands/
compile/
ctags.go
→
commands/
bundled_tools_
ctags.go
View file @
b6a5eb49
...
...
@@ -15,13 +15,13 @@
* a commercial license, send an email to license@arduino.cc.
*/
package
com
pile
package
com
mands
import
(
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/arduino/resources"
"go.bug.st/relaxed-semver"
semver
"go.bug.st/relaxed-semver"
)
func
loadBuiltinCtagsMetadata
(
pm
*
packagemanager
.
PackageManager
)
{
...
...
@@ -85,5 +85,6 @@ func loadBuiltinCtagsMetadata(pm *packagemanager.PackageManager) {
var
ctagsVersion
=
semver
.
ParseRelaxed
(
"5.8-arduino11"
)
func
getBuiltinCtagsTool
(
pm
*
packagemanager
.
PackageManager
)
(
*
cores
.
ToolRelease
,
error
)
{
loadBuiltinCtagsMetadata
(
pm
)
return
pm
.
Package
(
"builtin"
)
.
Tool
(
"ctags"
)
.
Release
(
ctagsVersion
)
.
Get
()
}
commands/bundled_tools_serial_discovery.go
View file @
b6a5eb49
...
...
@@ -88,6 +88,7 @@ func loadBuiltinSerialDiscoveryMetadata(pm *packagemanager.PackageManager) {
}
func
getBuiltinSerialDiscoveryTool
(
pm
*
packagemanager
.
PackageManager
)
(
*
cores
.
ToolRelease
,
error
)
{
loadBuiltinSerialDiscoveryMetadata
(
pm
)
return
pm
.
Package
(
"builtin"
)
.
Tool
(
"serial-discovery"
)
.
Release
(
serialDiscoveryVersion
)
.
Get
()
}
...
...
commands/compile/compile.go
View file @
b6a5eb49
...
...
@@ -40,10 +40,7 @@ import (
"github.com/sirupsen/logrus"
)
func
Compile
(
ctx
context
.
Context
,
req
*
rpc
.
CompileReq
,
outStream
io
.
Writer
,
errStream
io
.
Writer
,
taskCB
commands
.
TaskProgressCB
,
downloadCB
commands
.
DownloadProgressCB
)
(
*
rpc
.
CompileResp
,
error
)
{
func
Compile
(
ctx
context
.
Context
,
req
*
rpc
.
CompileReq
,
outStream
io
.
Writer
,
errStream
io
.
Writer
)
(
*
rpc
.
CompileResp
,
error
)
{
pm
:=
commands
.
GetPackageManager
(
req
)
if
pm
==
nil
{
return
nil
,
errors
.
New
(
"invalid instance"
)
...
...
@@ -71,24 +68,6 @@ func Compile(ctx context.Context, req *rpc.CompileReq,
return
nil
,
fmt
.
Errorf
(
"incorrect FQBN: %s"
,
err
)
}
// Check for ctags tool
loadBuiltinCtagsMetadata
(
pm
)
ctags
,
_
:=
getBuiltinCtagsTool
(
pm
)
if
!
ctags
.
IsInstalled
()
{
taskCB
(
&
rpc
.
TaskProgress
{
Name
:
"Downloading missing tool "
+
ctags
.
String
()})
commands
.
DownloadToolRelease
(
pm
,
ctags
,
downloadCB
)
taskCB
(
&
rpc
.
TaskProgress
{
Completed
:
true
})
commands
.
InstallToolRelease
(
pm
,
ctags
,
taskCB
)
if
err
:=
pm
.
LoadHardware
(
cli
.
Config
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"loading hardware packages: %s"
,
err
)
}
ctags
,
_
=
getBuiltinCtagsTool
(
pm
)
if
!
ctags
.
IsInstalled
()
{
return
nil
,
fmt
.
Errorf
(
"missing ctags tool"
)
}
}
targetPlatform
:=
pm
.
FindPlatform
(
&
packagemanager
.
PlatformReference
{
Package
:
fqbn
.
Package
,
PlatformArchitecture
:
fqbn
.
PlatformArch
,
...
...
commands/instances.go
View file @
b6a5eb49
...
...
@@ -25,6 +25,7 @@ import (
"path"
"time"
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/cores/packageindex"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/arduino/discovery"
...
...
@@ -81,26 +82,45 @@ func GetDiscoveries(req InstanceContainer) []*discovery.Discovery {
return
i
.
discoveries
}
func
(
instance
*
CoreInstance
)
startDiscoveries
(
downloadCB
DownloadProgressCB
,
taskCB
TaskProgressCB
)
error
{
func
(
instance
*
CoreInstance
)
installToolIfMissing
(
tool
*
cores
.
ToolRelease
,
downloadCB
DownloadProgressCB
,
taskCB
TaskProgressCB
)
(
bool
,
error
)
{
if
tool
.
IsInstalled
()
{
return
false
,
nil
}
taskCB
(
&
rpc
.
TaskProgress
{
Name
:
"Downloading missing tool "
+
tool
.
String
()})
if
err
:=
DownloadToolRelease
(
instance
.
pm
,
tool
,
downloadCB
);
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"downloading %s tool: %s"
,
tool
,
err
)
}
taskCB
(
&
rpc
.
TaskProgress
{
Completed
:
true
})
if
err
:=
InstallToolRelease
(
instance
.
pm
,
tool
,
taskCB
);
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"installing %s tool: %s"
,
tool
,
err
)
}
return
true
,
nil
}
func
(
instance
*
CoreInstance
)
checkForBuiltinTools
(
downloadCB
DownloadProgressCB
,
taskCB
TaskProgressCB
)
error
{
// Check for ctags tool
ctags
,
_
:=
getBuiltinCtagsTool
(
instance
.
pm
)
ctagsInstalled
,
err
:=
instance
.
installToolIfMissing
(
ctags
,
downloadCB
,
taskCB
)
if
err
!=
nil
{
return
err
}
// Check for bultin serial-discovery tool
loadBuiltinSerialDiscoveryMetadata
(
instance
.
pm
)
if
downloadCB
!=
nil
{
serialDiscoveryTool
,
_
:=
getBuiltinSerialDiscoveryTool
(
instance
.
pm
)
if
!
serialDiscoveryTool
.
IsInstalled
()
{
//formatter.Print("Downloading and installing missing tool: " + serialDiscoveryTool.String())
if
err
:=
DownloadToolRelease
(
instance
.
pm
,
serialDiscoveryTool
,
downloadCB
);
err
!=
nil
{
return
fmt
.
Errorf
((
"could not download serial-discovery tool"
))
}
if
err
:=
InstallToolRelease
(
instance
.
pm
,
serialDiscoveryTool
,
taskCB
);
err
!=
nil
{
return
fmt
.
Errorf
((
"could not install serial-discovery tool"
))
}
if
err
:=
instance
.
pm
.
LoadHardware
(
instance
.
config
);
err
!=
nil
{
return
fmt
.
Errorf
(
"could not load hardware packages: %s"
,
err
)
}
serialDiscoveryTool
,
_
:=
getBuiltinSerialDiscoveryTool
(
instance
.
pm
)
serialDiscoveryInstalled
,
err
:=
instance
.
installToolIfMissing
(
serialDiscoveryTool
,
downloadCB
,
taskCB
)
if
err
!=
nil
{
return
err
}
if
ctagsInstalled
||
serialDiscoveryInstalled
{
if
err
:=
instance
.
pm
.
LoadHardware
(
instance
.
config
);
err
!=
nil
{
return
fmt
.
Errorf
(
"could not load hardware packages: %s"
,
err
)
}
}
return
nil
}
func
(
instance
*
CoreInstance
)
startDiscoveries
()
error
{
serialDiscovery
,
err
:=
newBuiltinSerialDiscovery
(
instance
.
pm
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"starting serial discovery: %s"
,
err
)
...
...
@@ -162,10 +182,16 @@ func Init(ctx context.Context, req *rpc.InitReq, downloadCB DownloadProgressCB,
instancesCount
++
instances
[
handle
]
=
instance
if
err
:=
instance
.
startDiscoveries
(
downloadCB
,
taskCB
);
err
!=
nil
{
if
err
:=
instance
.
checkForBuiltinTools
(
downloadCB
,
taskCB
);
err
!=
nil
{
fmt
.
Println
(
err
)
return
nil
,
err
}
if
err
:=
instance
.
startDiscoveries
();
err
!=
nil
{
// TODO: handle discovery errors
fmt
.
Println
(
err
)
}
return
&
rpc
.
InitResp
{
Instance
:
&
rpc
.
Instance
{
Id
:
handle
},
PlatformsIndexErrors
:
reqPltIndex
,
...
...
@@ -271,7 +297,7 @@ func Rescan(ctx context.Context, req *rpc.RescanReq) (*rpc.RescanResp, error) {
coreInstance
.
pm
=
pm
coreInstance
.
lm
=
lm
coreInstance
.
startDiscoveries
(
nil
,
nil
)
coreInstance
.
startDiscoveries
()
return
&
rpc
.
RescanResp
{
PlatformsIndexErrors
:
reqPltIndex
,
...
...
daemon/daemon.go
View file @
b6a5eb49
...
...
@@ -120,8 +120,6 @@ func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileReq, stream rpc.ArduinoC
stream
.
Context
(),
req
,
feedStream
(
func
(
data
[]
byte
)
{
stream
.
Send
(
&
rpc
.
CompileResp
{
OutStream
:
data
})
}),
feedStream
(
func
(
data
[]
byte
)
{
stream
.
Send
(
&
rpc
.
CompileResp
{
ErrStream
:
data
})
}),
func
(
p
*
rpc
.
TaskProgress
)
{
stream
.
Send
(
&
rpc
.
CompileResp
{
TaskProgress
:
p
})
},
func
(
p
*
rpc
.
DownloadProgress
)
{
stream
.
Send
(
&
rpc
.
CompileResp
{
DownloadProgress
:
p
})
},
)
if
err
!=
nil
{
return
err
...
...
rpc/compile.proto
View file @
b6a5eb49
...
...
@@ -42,6 +42,4 @@ message CompileReq {
message
CompileResp
{
bytes
out_stream
=
1
;
bytes
err_stream
=
2
;
DownloadProgress
download_progress
=
3
;
TaskProgress
task_progress
=
4
;
}
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