From b723cc28a00865453a743c38535ae6f9d5b17b06 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Mon, 10 Jun 2019 18:21:01 +0200 Subject: [PATCH] show new layout --- Taskfile.yml | 7 + cli/compile/compile.go | 25 +- commands/compile/compile.go | 20 +- commands/daemon/client/client.go | 544 +++++++++++++++++++++++ commands/daemon/daemon.go | 67 +++ commands/daemon/utils.go | 18 + daemon/daemon.go | 13 - proto-gen/commands/rpc_v1/commands.pb.go | 148 ++++++ proto-gen/commands/rpc_v1/compile.pb.go | 200 +++++++++ proto-gen/commands/rpc_v1/types.pb.go | 266 +++++++++++ rpc/commands.pb.go | 14 - 11 files changed, 1289 insertions(+), 33 deletions(-) create mode 100644 commands/daemon/client/client.go create mode 100644 commands/daemon/daemon.go create mode 100644 commands/daemon/utils.go create mode 100644 proto-gen/commands/rpc_v1/commands.pb.go create mode 100644 proto-gen/commands/rpc_v1/compile.pb.go create mode 100644 proto-gen/commands/rpc_v1/types.pb.go diff --git a/Taskfile.yml b/Taskfile.yml index 9cf78a338ba..19ffd5df27d 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,6 +1,13 @@ version: '2' tasks: + protoc: + desc: Compile protobuf definitions + cmds: + - protoc --proto_path=. --go_out=plugins=grpc,paths=source_relative:./proto-gen ./commands/rpc_v1/commands.proto + - protoc --proto_path=. --go_out=plugins=grpc,paths=source_relative:./proto-gen ./commands/rpc_v1/types.proto + - protoc --proto_path=. --go_out=plugins=grpc,paths=source_relative:./proto-gen ./commands/rpc_v1/compile.proto + build: desc: Build the project cmds: diff --git a/cli/compile/compile.go b/cli/compile/compile.go index 0ac8ccaca88..a36b31a1bba 100644 --- a/cli/compile/compile.go +++ b/cli/compile/compile.go @@ -19,12 +19,13 @@ package compile import ( "context" + "errors" "os" "github.com/arduino/arduino-cli/cli" "github.com/arduino/arduino-cli/commands/compile" "github.com/arduino/arduino-cli/common/formatter" - "github.com/arduino/arduino-cli/rpc" + "github.com/arduino/arduino-cli/proto-gen/commands/rpc_v1" "github.com/arduino/go-paths-helper" "github.com/spf13/cobra" ) @@ -89,15 +90,28 @@ var flags struct { exportFile string // The compiled binary is written to this file } +// FIXME: temporary fix +func createInstance() *rpc_v1.Instance { + resp := cli.InitInstance() + if resp.GetPlatformsIndexErrors() != nil { + for _, err := range resp.GetPlatformsIndexErrors() { + formatter.PrintError(errors.New(err), "Error loading index") + } + formatter.PrintErrorMessage("Launch 'core update-index' to fix or download indexes.") + os.Exit(cli.ErrGeneric) + } + return &rpc_v1.Instance{Id: resp.GetInstance().Id} +} + func run(cmd *cobra.Command, args []string) { - instance := cli.CreateInstance() + instance := createInstance() var path *paths.Path if len(args) > 0 { path = paths.New(args[0]) } sketchPath := cli.InitSketchPath(path) - compRes, err := compile.Compile(context.Background(), &rpc.CompileReq{ + _, err := compile.Compile(context.Background(), &rpc_v1.CompileReq{ Instance: instance, Fqbn: flags.fqbn, SketchPath: sketchPath.String(), @@ -113,13 +127,14 @@ func run(cmd *cobra.Command, args []string) { ExportFile: flags.exportFile, }, os.Stdout, os.Stderr) if err == nil { - outputCompileResp(compRes) + // FIXME: re-enable + //outputCompileResp(compRes) } else { formatter.PrintError(err, "Error during build") os.Exit(cli.ErrGeneric) } } -func outputCompileResp(details *rpc.CompileResp) { +func outputCompileResp(details *rpc_v1.ExecResp) { } diff --git a/commands/compile/compile.go b/commands/compile/compile.go index b68e4889fa1..707b83c4889 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -34,13 +34,31 @@ import ( "github.com/arduino/arduino-cli/legacy/builder" "github.com/arduino/arduino-cli/legacy/builder/i18n" "github.com/arduino/arduino-cli/legacy/builder/types" + "github.com/arduino/arduino-cli/proto-gen/commands/rpc_v1" "github.com/arduino/arduino-cli/rpc" paths "github.com/arduino/go-paths-helper" properties "github.com/arduino/go-properties-orderedmap" "github.com/sirupsen/logrus" ) -func Compile(ctx context.Context, req *rpc.CompileReq, outStream io.Writer, errStream io.Writer) (*rpc.CompileResp, error) { +func Compile(ctx context.Context, compile_req *rpc_v1.CompileReq, outStream io.Writer, errStream io.Writer) (*rpc.CompileResp, error) { + // FIXME: temprary fix to show alternative protobuf layout + req := &rpc.CompileReq{ + Instance: &rpc.Instance{Id: compile_req.Instance.Id}, + Fqbn: compile_req.Fqbn, + SketchPath: compile_req.SketchPath, + ShowProperties: compile_req.ShowProperties, + Preprocess: compile_req.Preprocess, + BuildCachePath: compile_req.BuildCachePath, + BuildPath: compile_req.BuildPath, + BuildProperties: compile_req.BuildProperties, + Warnings: compile_req.Warnings, + Verbose: compile_req.Verbose, + Quiet: compile_req.Quiet, + VidPid: compile_req.VidPid, + } + // FIXME: end of fix + pm := commands.GetPackageManager(req) if pm == nil { return nil, errors.New("invalid instance") diff --git a/commands/daemon/client/client.go b/commands/daemon/client/client.go new file mode 100644 index 00000000000..baf4e3ffbb0 --- /dev/null +++ b/commands/daemon/client/client.go @@ -0,0 +1,544 @@ +// +// 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 main + +import ( + "context" + "fmt" + "io" + "os" + + "github.com/arduino/arduino-cli/common/formatter" + "github.com/arduino/arduino-cli/rpc" + "google.golang.org/grpc" +) + +func main() { + if len(os.Args) != 3 { + fmt.Println("Please specify Arduino DATA_DIR as first argument") + os.Exit(1) + } + datadir := os.Args[1] + + fmt.Println("=== Connecting to GRPC server") + conn, err := grpc.Dial("127.0.0.1:50051", grpc.WithInsecure()) + if err != nil { + fmt.Printf("Error connecting to server: %s\n", err) + os.Exit(1) + } + client := rpc.NewArduinoCoreClient(conn) + fmt.Println() + + // VERSION + fmt.Println("=== calling Version") + versionResp, err := client.Version(context.Background(), &rpc.VersionReq{}) + if err != nil { + fmt.Printf("Error getting version: %s\n", err) + os.Exit(1) + } + fmt.Printf("---> %+v\n\v", versionResp) + + // INIT + fmt.Println("=== calling Init") + initRespStream, err := client.Init(context.Background(), &rpc.InitReq{ + Configuration: &rpc.Configuration{ + DataDir: datadir, + }, + }) + if err != nil { + fmt.Printf("Error creating server instance: %s\n", err) + os.Exit(1) + } + var instance *rpc.Instance + for { + initResp, err := initRespStream.Recv() + if err == io.EOF { + fmt.Println() + break + } + if err != nil { + fmt.Printf("Init error: %s\n", err) + os.Exit(1) + } + if initResp.GetInstance() != nil { + instance = initResp.GetInstance() + fmt.Printf("---> %+v\n", initResp) + } + if initResp.GetDownloadProgress() != nil { + fmt.Printf(">> DOWNLOAD: %s\n", initResp.GetDownloadProgress()) + } + if initResp.GetTaskProgress() != nil { + fmt.Printf(">> TASK: %s\n", initResp.GetTaskProgress()) + } + } + + // UPDATE-INDEX + fmt.Println("=== calling UpdateIndex") + uiRespStream, err := client.UpdateIndex(context.Background(), &rpc.UpdateIndexReq{ + Instance: instance, + }) + if err != nil { + fmt.Printf("Error updating index: %s\n", err) + os.Exit(1) + } + for { + uiResp, err := uiRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", uiResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Update error: %s\n", err) + os.Exit(1) + } + if uiResp.GetDownloadProgress() != nil { + fmt.Printf(">> DOWNLOAD: %s\n", uiResp.GetDownloadProgress()) + } + } + + // PLATFORM SEARCH + fmt.Println("=== calling PlatformSearch(samd)") + searchResp, err := client.PlatformSearch(context.Background(), &rpc.PlatformSearchReq{ + Instance: instance, + SearchArgs: "uno", + }) + if err != nil { + fmt.Printf("Search error: %s\n", err) + os.Exit(1) + } + serchedOutput := searchResp.GetSearchOutput() + for _, outsearch := range serchedOutput { + fmt.Printf(">> SEARCH: %+v\n", outsearch) + } + fmt.Printf("---> %+v\n", searchResp) + fmt.Println() + + // PLATFORM INSTALL + install := func() { + fmt.Println("=== calling PlatformInstall(arduino:samd@1.6.19)") + installRespStream, err := client.PlatformInstall(context.Background(), &rpc.PlatformInstallReq{ + Instance: instance, + PlatformPackage: "arduino", + Architecture: "samd", + Version: "1.6.19", + }) + if err != nil { + fmt.Printf("Error installing platform: %s\n", err) + os.Exit(1) + } + for { + installResp, err := installRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", installResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Install error: %s\n", err) + os.Exit(1) + } + if installResp.GetProgress() != nil { + fmt.Printf(">> DOWNLOAD: %s\n", installResp.GetProgress()) + } + if installResp.GetTaskProgress() != nil { + fmt.Printf(">> TASK: %s\n", installResp.GetTaskProgress()) + } + } + } + + install() + install() + + // PLATFORM LIST + fmt.Println("=== calling PlatformList()") + listResp, err := client.PlatformList(context.Background(), &rpc.PlatformListReq{ + Instance: instance, + }) + if err != nil { + fmt.Printf("List error: %s\n", err) + os.Exit(1) + } + Installedplatforms := listResp.GetInstalledPlatform() + for _, listpfm := range Installedplatforms { + fmt.Printf("---> LIST: %+v\n", listpfm) + } + fmt.Println() + + // PLATFORM UPGRADE + fmt.Println("=== calling PlatformUpgrade(arduino:samd)") + upgradeRespStream, err := client.PlatformUpgrade(context.Background(), &rpc.PlatformUpgradeReq{ + Instance: instance, + PlatformPackage: "arduino", + Architecture: "samd", + }) + if err != nil { + fmt.Printf("Error upgrading platform: %s\n", err) + os.Exit(1) + } + for { + upgradeResp, err := upgradeRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", upgradeResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Upgrade error: %s\n", err) + os.Exit(1) + } + if upgradeResp.GetProgress() != nil { + fmt.Printf(">> DOWNLOAD: %s\n", upgradeResp.GetProgress()) + } + if upgradeResp.GetTaskProgress() != nil { + fmt.Printf(">> TASK: %s\n", upgradeResp.GetTaskProgress()) + } + } + + // BOARDS DETAILS + fmt.Println("=== calling BoardDetails(arduino:samd:mkr1000)") + details, err := client.BoardDetails(context.Background(), &rpc.BoardDetailsReq{ + Instance: instance, + Fqbn: "arduino:samd:mkr1000", + }) + if err != nil { + fmt.Printf("Error getting board data: %s\n", err) + } + fmt.Printf("---> %+v\n", details) + fmt.Println() + + // BOARDS ATTACH + fmt.Println("=== calling BoardAttach(serial:///dev/ttyACM0)") + boardattachresp, err := client.BoardAttach(context.Background(), &rpc.BoardAttachReq{ + Instance: instance, + BoardUri: "/dev/ttyACM0", + SketchPath: os.Args[2], + }) + if err != nil { + fmt.Printf("Attach error: %s\n", err) + os.Exit(1) + } + for { + attachResp, err := boardattachresp.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", attachResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Attach error: %s\n", err) + os.Exit(1) + } + if attachResp.GetTaskProgress() != nil { + fmt.Printf(">> TASK: %s\n", attachResp.GetTaskProgress()) + } + } + + // COMPILE + fmt.Println("=== calling Compile(arduino:samd:mkr1000, VERBOSE, " + os.Args[2] + ")") + compRespStream, err := client.Compile(context.Background(), &rpc.CompileReq{ + Instance: instance, + Fqbn: "arduino:samd:mkr1000", + SketchPath: os.Args[2], + Verbose: true, + }) + if err != nil { + fmt.Printf("Compile error: %s\n", err) + os.Exit(1) + } + for { + compResp, err := compRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", compResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Compile error: %s\n", err) + os.Exit(1) + } + if resp := compResp.GetOutStream(); resp != nil { + fmt.Printf(">> STDOUT: %s", resp) + } + if resperr := compResp.GetErrStream(); resperr != nil { + fmt.Printf(">> STDERR: %s", resperr) + } + } + + // UPLOAD + fmt.Println("=== calling Upload(arduino:samd:mkr1000, /dev/ttyACM0, VERBOSE, " + os.Args[2] + ")") + uplRespStream, err := client.Upload(context.Background(), &rpc.UploadReq{ + Instance: instance, + Fqbn: "arduino:samd:mkr1000", + SketchPath: os.Args[2], + Port: "/dev/ttyACM0", + Verbose: true, + }) + if err != nil { + fmt.Printf("Upload error: %s\n", err) + os.Exit(1) + } + for { + uplResp, err := uplRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", uplResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Upload error: %s\n", err) + // os.Exit(1) + break + } + if resp := uplResp.GetOutStream(); resp != nil { + fmt.Printf(">> STDOUT: %s", resp) + } + if resperr := uplResp.GetErrStream(); resperr != nil { + fmt.Printf(">> STDERR: %s", resperr) + } + } + + // BOARD LIST ALL + fmt.Println("=== calling BoardListAll(mkr)") + boardListAllResp, err := client.BoardListAll(context.Background(), &rpc.BoardListAllReq{ + Instance: instance, + SearchArgs: []string{"mkr"}, + }) + if err != nil { + fmt.Printf("Board list-all error: %s\n", err) + os.Exit(1) + } + fmt.Printf("---> %+v\n", boardListAllResp) + fmt.Println() + + // BOARD LIST + fmt.Println("=== calling BoardList()") + boardListResp, err := client.BoardList(context.Background(), &rpc.BoardListReq{Instance: instance}) + if err != nil { + fmt.Printf("Board list error: %s\n", err) + os.Exit(1) + } + fmt.Printf("---> %+v\n", boardListResp) + fmt.Println() + + // PLATFORM UNINSTALL + fmt.Println("=== calling PlatformUninstall(arduino:samd)") + uninstallRespStream, err := client.PlatformUninstall(context.Background(), &rpc.PlatformUninstallReq{ + Instance: instance, + PlatformPackage: "arduino", + Architecture: "samd", + }) + if err != nil { + fmt.Printf("Uninstall error: %s\n", err) + os.Exit(1) + } + for { + uninstallResp, err := uninstallRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", uninstallResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Uninstall error: %s\n", err) + os.Exit(1) + } + if uninstallResp.GetTaskProgress() != nil { + fmt.Printf(">> TASK: %s\n", uninstallResp.GetTaskProgress()) + } + } + + // LIB UPDATE INDEX + fmt.Println("=== calling UpdateLibrariesIndex()") + libIdxUpdateStream, err := client.UpdateLibrariesIndex(context.Background(), &rpc.UpdateLibrariesIndexReq{Instance: instance}) + if err != nil { + fmt.Printf("Error updating libraries index: %s\n", err) + os.Exit(1) + } + for { + resp, err := libIdxUpdateStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", resp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Error updating libraries index: %s\n", err) + os.Exit(1) + } + if resp.GetDownloadProgress() != nil { + fmt.Printf(">> DOWNLOAD: %s\n", resp.GetDownloadProgress()) + } + } + + // LIB DOWNLOAD + fmt.Println("=== calling LibraryDownload(WiFi101@0.15.2)") + downloadRespStream, err := client.LibraryDownload(context.Background(), &rpc.LibraryDownloadReq{ + Instance: instance, + Name: "WiFi101", + Version: "0.15.2", + }) + if err != nil { + fmt.Printf("Error downloading library: %s\n", err) + os.Exit(1) + } + for { + downloadResp, err := downloadRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", downloadResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Download error: %s\n", err) + os.Exit(1) + } + if downloadResp.GetProgress() != nil { + fmt.Printf(">> DOWNLOAD: %s\n", downloadResp.GetProgress()) + } + } + + libInstall := func(version string) { + // LIB INSTALL + fmt.Println("=== calling LibraryInstall(WiFi101@" + version + ")") + installRespStream, err := client.LibraryInstall(context.Background(), &rpc.LibraryInstallReq{ + Instance: instance, + Name: "WiFi101", + Version: version, + }) + if err != nil { + fmt.Printf("Error installing library: %s\n", err) + os.Exit(1) + } + for { + installResp, err := installRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", installResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Install error: %s\n", err) + os.Exit(1) + } + if installResp.GetProgress() != nil { + fmt.Printf(">> DOWNLOAD: %s\n", installResp.GetProgress()) + } + if installResp.GetTaskProgress() != nil { + fmt.Printf(">> TASK: %s\n", installResp.GetTaskProgress()) + } + } + } + + libInstall("0.15.1") // Install + libInstall("0.15.2") // Replace + + // LIB UPGRADE + fmt.Println("=== calling LibraryUpgradeAll()") + libUpgradeAllRespStream, err := client.LibraryUpgradeAll(context.Background(), &rpc.LibraryUpgradeAllReq{ + Instance: instance, + }) + if err != nil { + fmt.Printf("Error upgrading all: %s\n", err) + os.Exit(1) + } + for { + resp, err := libUpgradeAllRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", resp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Upgrading error: %s\n", err) + os.Exit(1) + } + if resp.GetProgress() != nil { + fmt.Printf(">> DOWNLOAD: %s\n", resp.GetProgress()) + } + if resp.GetTaskProgress() != nil { + fmt.Printf(">> TASK: %s\n", resp.GetTaskProgress()) + } + } + + // LIB SEARCH + fmt.Println("=== calling LibrarySearch(audio)") + libSearchResp, err := client.LibrarySearch(context.Background(), &rpc.LibrarySearchReq{ + Instance: instance, + Query: "audio", + }) + if err != nil { + formatter.PrintError(err, "Error searching for library") + os.Exit(1) + } + fmt.Printf("---> %+v\n", libSearchResp) + fmt.Println() + + // LIB LIST + fmt.Println("=== calling LibraryList") + libLstResp, err := client.LibraryList(context.Background(), &rpc.LibraryListReq{ + Instance: instance, + All: false, + Updatable: false, + }) + if err != nil { + formatter.PrintError(err, "Error List Library") + os.Exit(1) + } + fmt.Printf("---> %+v\n", libLstResp) + fmt.Println() + + // LIB UNINSTALL + fmt.Println("=== calling LibraryUninstall(WiFi101)") + libUninstallRespStream, err := client.LibraryUninstall(context.Background(), &rpc.LibraryUninstallReq{ + Instance: instance, + Name: "WiFi101", + }) + if err != nil { + fmt.Printf("Error uninstalling: %s\n", err) + os.Exit(1) + } + for { + uninstallResp, err := libUninstallRespStream.Recv() + if err == io.EOF { + fmt.Printf("---> %+v\n", uninstallResp) + fmt.Println() + break + } + if err != nil { + fmt.Printf("Uninstall error: %s\n", err) + os.Exit(1) + } + if uninstallResp.GetTaskProgress() != nil { + fmt.Printf(">> TASK: %s\n", uninstallResp.GetTaskProgress()) + } + } + + // DESTROY + fmt.Println("=== calling Destroy()") + destroyResp, err := client.Destroy(context.Background(), &rpc.DestroyReq{ + Instance: instance, + }) + if err != nil { + fmt.Printf("Error closing server instance: %s\n", err) + } else { + fmt.Println("Successfully closed server instance") + } + fmt.Printf("---> %+v\n", destroyResp) + fmt.Println() +} diff --git a/commands/daemon/daemon.go b/commands/daemon/daemon.go new file mode 100644 index 00000000000..39f88d3e0e9 --- /dev/null +++ b/commands/daemon/daemon.go @@ -0,0 +1,67 @@ +// +// 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 daemon + +import ( + "fmt" + "log" + "net" + + "github.com/arduino/arduino-cli/commands/compile" + "github.com/arduino/arduino-cli/proto-gen/commands/rpc_v1" + "github.com/spf13/cobra" + "google.golang.org/grpc" +) + +const ( + port = ":50051" +) + +func runDaemonCommand(cmd *cobra.Command, args []string) { + lis, err := net.Listen("tcp", port) + if err != nil { + log.Fatalf("failed to listen: %v", err) + } + s := grpc.NewServer() + rpc_v1.RegisterArduinoCommandsServer(s, &ArduinoCommandsService{}) + if err := s.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) + } + fmt.Println("Done serving") +} + +// ArduinoCommandsService is the gRPC service implementation +type ArduinoCommandsService struct{} + +// Version returns a message containing CLI version +// func (s *ArduinoCommandsService) Version(ctx context.Context, req *rpc.VersionReq) (*rpc.VersionResp, error) { +// return &rpc.VersionResp{Version: cli.Version}, nil +// } + +// Compile sends a request for a compilation run +func (s *ArduinoCommandsService) Compile(req *rpc_v1.CompileReq, stream rpc_v1.ArduinoCommands_CompileServer) error { + resp, err := compile.Compile( + stream.Context(), req, + feedStream(func(data []byte) { stream.Send(&rpc_v1.ExecResp{OutStream: data}) }), + feedStream(func(data []byte) { stream.Send(&rpc_v1.ExecResp{ErrStream: data}) }), + ) + if err != nil { + return err + } + return stream.Send(&rpc_v1.ExecResp{ErrStream: resp.ErrStream, OutStream: resp.OutStream}) +} diff --git a/commands/daemon/utils.go b/commands/daemon/utils.go new file mode 100644 index 00000000000..188a5d3e831 --- /dev/null +++ b/commands/daemon/utils.go @@ -0,0 +1,18 @@ +package daemon + +import "io" + +func feedStream(streamer func(data []byte)) io.Writer { + r, w := io.Pipe() + go func() { + data := make([]byte, 1024) + for { + if n, err := r.Read(data); err == nil { + streamer(data[:n]) + } else { + return + } + } + }() + return w +} diff --git a/daemon/daemon.go b/daemon/daemon.go index 52a7bfdfa9a..dec7c86ae65 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -29,7 +29,6 @@ import ( "github.com/arduino/arduino-cli/cli" "github.com/arduino/arduino-cli/commands" "github.com/arduino/arduino-cli/commands/board" - "github.com/arduino/arduino-cli/commands/compile" "github.com/arduino/arduino-cli/commands/core" "github.com/arduino/arduino-cli/commands/lib" "github.com/arduino/arduino-cli/commands/upload" @@ -124,18 +123,6 @@ func (s *ArduinoCoreServerImpl) Version(ctx context.Context, req *rpc.VersionReq return &rpc.VersionResp{Version: cli.Version}, nil } -func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileReq, stream rpc.ArduinoCore_CompileServer) error { - resp, err := compile.Compile( - stream.Context(), req, - feedStream(func(data []byte) { stream.Send(&rpc.CompileResp{OutStream: data}) }), - feedStream(func(data []byte) { stream.Send(&rpc.CompileResp{ErrStream: data}) }), - ) - if err != nil { - return err - } - return stream.Send(resp) -} - func (s *ArduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallReq, stream rpc.ArduinoCore_PlatformInstallServer) error { resp, err := core.PlatformInstall( stream.Context(), req, diff --git a/proto-gen/commands/rpc_v1/commands.pb.go b/proto-gen/commands/rpc_v1/commands.pb.go new file mode 100644 index 00000000000..82ebbd3473c --- /dev/null +++ b/proto-gen/commands/rpc_v1/commands.pb.go @@ -0,0 +1,148 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: commands/rpc_v1/commands.proto + +package rpc_v1 + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("commands/rpc_v1/commands.proto", fileDescriptor_cf7880bd07f0f11b) } + +var fileDescriptor_cf7880bd07f0f11b = []byte{ + // 158 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xce, 0xcf, 0xcd, + 0x4d, 0xcc, 0x4b, 0x29, 0xd6, 0x2f, 0x2a, 0x48, 0x8e, 0x2f, 0x33, 0xd4, 0x87, 0xf1, 0xf5, 0x0a, + 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xd8, 0x20, 0xc2, 0x52, 0xd2, 0xe8, 0xea, 0x4a, 0x2a, 0x0b, 0x52, + 0xa1, 0x8a, 0xa4, 0x64, 0xb1, 0x18, 0x52, 0x90, 0x99, 0x93, 0x0a, 0x91, 0x36, 0x72, 0xe1, 0xe2, + 0x77, 0x2c, 0x4a, 0x29, 0xcd, 0xcc, 0xcb, 0x77, 0x86, 0xaa, 0x13, 0x32, 0xe4, 0x62, 0x77, 0x86, + 0xa8, 0x11, 0x12, 0xd2, 0x83, 0x68, 0xd2, 0x83, 0x0a, 0x04, 0xa5, 0x16, 0x4a, 0x09, 0xc0, 0xc4, + 0x5c, 0x2b, 0x52, 0x93, 0x83, 0x52, 0x8b, 0x0b, 0x0c, 0x18, 0x9d, 0x0c, 0xa3, 0xf4, 0xd3, 0x33, + 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x13, 0x21, 0x06, 0xc2, 0x68, 0xdd, 0xe4, + 0x9c, 0x4c, 0x7d, 0xb0, 0x6d, 0xba, 0xe9, 0xa9, 0x79, 0x50, 0x67, 0x24, 0xb1, 0x81, 0x45, 0x8c, + 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xae, 0x9b, 0x41, 0x68, 0xe5, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// ArduinoCommandsClient is the client API for ArduinoCommands service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ArduinoCommandsClient interface { + Compile(ctx context.Context, in *CompileReq, opts ...grpc.CallOption) (ArduinoCommands_CompileClient, error) +} + +type arduinoCommandsClient struct { + cc *grpc.ClientConn +} + +func NewArduinoCommandsClient(cc *grpc.ClientConn) ArduinoCommandsClient { + return &arduinoCommandsClient{cc} +} + +func (c *arduinoCommandsClient) Compile(ctx context.Context, in *CompileReq, opts ...grpc.CallOption) (ArduinoCommands_CompileClient, error) { + stream, err := c.cc.NewStream(ctx, &_ArduinoCommands_serviceDesc.Streams[0], "/rpc_v1.ArduinoCommands/Compile", opts...) + if err != nil { + return nil, err + } + x := &arduinoCommandsCompileClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type ArduinoCommands_CompileClient interface { + Recv() (*ExecResp, error) + grpc.ClientStream +} + +type arduinoCommandsCompileClient struct { + grpc.ClientStream +} + +func (x *arduinoCommandsCompileClient) Recv() (*ExecResp, error) { + m := new(ExecResp) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// ArduinoCommandsServer is the server API for ArduinoCommands service. +type ArduinoCommandsServer interface { + Compile(*CompileReq, ArduinoCommands_CompileServer) error +} + +// UnimplementedArduinoCommandsServer can be embedded to have forward compatible implementations. +type UnimplementedArduinoCommandsServer struct { +} + +func (*UnimplementedArduinoCommandsServer) Compile(req *CompileReq, srv ArduinoCommands_CompileServer) error { + return status.Errorf(codes.Unimplemented, "method Compile not implemented") +} + +func RegisterArduinoCommandsServer(s *grpc.Server, srv ArduinoCommandsServer) { + s.RegisterService(&_ArduinoCommands_serviceDesc, srv) +} + +func _ArduinoCommands_Compile_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(CompileReq) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ArduinoCommandsServer).Compile(m, &arduinoCommandsCompileServer{stream}) +} + +type ArduinoCommands_CompileServer interface { + Send(*ExecResp) error + grpc.ServerStream +} + +type arduinoCommandsCompileServer struct { + grpc.ServerStream +} + +func (x *arduinoCommandsCompileServer) Send(m *ExecResp) error { + return x.ServerStream.SendMsg(m) +} + +var _ArduinoCommands_serviceDesc = grpc.ServiceDesc{ + ServiceName: "rpc_v1.ArduinoCommands", + HandlerType: (*ArduinoCommandsServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Compile", + Handler: _ArduinoCommands_Compile_Handler, + ServerStreams: true, + }, + }, + Metadata: "commands/rpc_v1/commands.proto", +} diff --git a/proto-gen/commands/rpc_v1/compile.pb.go b/proto-gen/commands/rpc_v1/compile.pb.go new file mode 100644 index 00000000000..46da034052e --- /dev/null +++ b/proto-gen/commands/rpc_v1/compile.pb.go @@ -0,0 +1,200 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: commands/rpc_v1/compile.proto + +package rpc_v1 + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type CompileReq struct { + Instance *Instance `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + // Fully Qualified Board Name, e.g.: arduino:avr:uno. + Fqbn string `protobuf:"bytes,2,opt,name=fqbn,proto3" json:"fqbn,omitempty"` + SketchPath string `protobuf:"bytes,3,opt,name=sketchPath,proto3" json:"sketchPath,omitempty"` + // Show all build preferences used instead of compiling. + ShowProperties bool `protobuf:"varint,4,opt,name=showProperties,proto3" json:"showProperties,omitempty"` + // Print preprocessed code to stdout. + Preprocess bool `protobuf:"varint,5,opt,name=preprocess,proto3" json:"preprocess,omitempty"` + // Builds of 'core.a' are saved into this path to be cached and reused. + BuildCachePath string `protobuf:"bytes,6,opt,name=buildCachePath,proto3" json:"buildCachePath,omitempty"` + // Path where to save compiled files. + BuildPath string `protobuf:"bytes,7,opt,name=buildPath,proto3" json:"buildPath,omitempty"` + // List of custom build properties separated by commas. Or can be used + // multiple times for multiple properties. + BuildProperties []string `protobuf:"bytes,8,rep,name=buildProperties,proto3" json:"buildProperties,omitempty"` + // Used to tell gcc which warning level to use. + Warnings string `protobuf:"bytes,9,opt,name=warnings,proto3" json:"warnings,omitempty"` + // Turns on verbose mode. + Verbose bool `protobuf:"varint,10,opt,name=verbose,proto3" json:"verbose,omitempty"` + // Suppresses almost every output. + Quiet bool `protobuf:"varint,11,opt,name=quiet,proto3" json:"quiet,omitempty"` + // VID/PID specific build properties. + VidPid string `protobuf:"bytes,12,opt,name=vidPid,proto3" json:"vidPid,omitempty"` + // The compiled binary is written to this file. + ExportFile string `protobuf:"bytes,13,opt,name=exportFile,proto3" json:"exportFile,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CompileReq) Reset() { *m = CompileReq{} } +func (m *CompileReq) String() string { return proto.CompactTextString(m) } +func (*CompileReq) ProtoMessage() {} +func (*CompileReq) Descriptor() ([]byte, []int) { + return fileDescriptor_02fb106927d1a068, []int{0} +} + +func (m *CompileReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CompileReq.Unmarshal(m, b) +} +func (m *CompileReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CompileReq.Marshal(b, m, deterministic) +} +func (m *CompileReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompileReq.Merge(m, src) +} +func (m *CompileReq) XXX_Size() int { + return xxx_messageInfo_CompileReq.Size(m) +} +func (m *CompileReq) XXX_DiscardUnknown() { + xxx_messageInfo_CompileReq.DiscardUnknown(m) +} + +var xxx_messageInfo_CompileReq proto.InternalMessageInfo + +func (m *CompileReq) GetInstance() *Instance { + if m != nil { + return m.Instance + } + return nil +} + +func (m *CompileReq) GetFqbn() string { + if m != nil { + return m.Fqbn + } + return "" +} + +func (m *CompileReq) GetSketchPath() string { + if m != nil { + return m.SketchPath + } + return "" +} + +func (m *CompileReq) GetShowProperties() bool { + if m != nil { + return m.ShowProperties + } + return false +} + +func (m *CompileReq) GetPreprocess() bool { + if m != nil { + return m.Preprocess + } + return false +} + +func (m *CompileReq) GetBuildCachePath() string { + if m != nil { + return m.BuildCachePath + } + return "" +} + +func (m *CompileReq) GetBuildPath() string { + if m != nil { + return m.BuildPath + } + return "" +} + +func (m *CompileReq) GetBuildProperties() []string { + if m != nil { + return m.BuildProperties + } + return nil +} + +func (m *CompileReq) GetWarnings() string { + if m != nil { + return m.Warnings + } + return "" +} + +func (m *CompileReq) GetVerbose() bool { + if m != nil { + return m.Verbose + } + return false +} + +func (m *CompileReq) GetQuiet() bool { + if m != nil { + return m.Quiet + } + return false +} + +func (m *CompileReq) GetVidPid() string { + if m != nil { + return m.VidPid + } + return "" +} + +func (m *CompileReq) GetExportFile() string { + if m != nil { + return m.ExportFile + } + return "" +} + +func init() { + proto.RegisterType((*CompileReq)(nil), "rpc_v1.CompileReq") +} + +func init() { proto.RegisterFile("commands/rpc_v1/compile.proto", fileDescriptor_02fb106927d1a068) } + +var fileDescriptor_02fb106927d1a068 = []byte{ + // 337 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xcb, 0x6e, 0xab, 0x30, + 0x10, 0x86, 0xc5, 0x49, 0x42, 0x60, 0x72, 0x6e, 0xb2, 0x8e, 0x8e, 0xac, 0xf4, 0x22, 0xd4, 0x45, + 0xc5, 0xa2, 0x01, 0xa5, 0x7d, 0x83, 0x46, 0xaa, 0xd4, 0x5d, 0xc4, 0xb2, 0x9b, 0x0a, 0xcc, 0x34, + 0x58, 0x05, 0xdb, 0xb1, 0x4d, 0xd2, 0xbe, 0x52, 0x9f, 0xb2, 0x8a, 0xc9, 0x4d, 0xac, 0xe0, 0xff, + 0xfc, 0xcf, 0x3f, 0x63, 0x0f, 0x5c, 0x31, 0xd9, 0x34, 0xb9, 0x28, 0x4d, 0xaa, 0x15, 0x7b, 0xdd, + 0xcc, 0x53, 0x26, 0x1b, 0xc5, 0x6b, 0x4c, 0x94, 0x96, 0x56, 0x12, 0xbf, 0xa3, 0xd3, 0x8b, 0xbe, + 0xcd, 0x7e, 0x2a, 0x34, 0x9d, 0xe9, 0xe6, 0x6b, 0x00, 0xb0, 0xe8, 0xca, 0x32, 0x5c, 0x93, 0x3b, + 0x08, 0xb8, 0x30, 0x36, 0x17, 0x0c, 0xa9, 0x17, 0x79, 0xf1, 0xe4, 0xfe, 0x6f, 0xd2, 0x55, 0x25, + 0xcf, 0x7b, 0x9e, 0x1d, 0x1d, 0x84, 0xc0, 0xf0, 0x6d, 0x5d, 0x08, 0xfa, 0x23, 0xf2, 0xe2, 0x30, + 0x73, 0xff, 0xe4, 0x1a, 0xc0, 0xbc, 0xa3, 0x65, 0xd5, 0x32, 0xb7, 0x15, 0x1d, 0xb8, 0x93, 0x33, + 0x42, 0x6e, 0xe1, 0xb7, 0xa9, 0xe4, 0x76, 0xa9, 0xa5, 0x42, 0x6d, 0x39, 0x1a, 0x3a, 0x8c, 0xbc, + 0x38, 0xc8, 0x7a, 0x74, 0x97, 0xa3, 0x34, 0x2a, 0x2d, 0x19, 0x1a, 0x43, 0x47, 0xce, 0x73, 0x46, + 0x76, 0x39, 0x45, 0xcb, 0xeb, 0x72, 0x91, 0xb3, 0x0a, 0x5d, 0x2f, 0xdf, 0xf5, 0xea, 0x51, 0x72, + 0x09, 0xa1, 0x23, 0xce, 0x32, 0x76, 0x96, 0x13, 0x20, 0x31, 0xfc, 0xe9, 0xc4, 0x69, 0x9c, 0x20, + 0x1a, 0xc4, 0x61, 0xd6, 0xc7, 0x64, 0x0a, 0xc1, 0x36, 0xd7, 0x82, 0x8b, 0x95, 0xa1, 0xa1, 0x8b, + 0x39, 0x6a, 0x42, 0x61, 0xbc, 0x41, 0x5d, 0x48, 0x83, 0x14, 0xdc, 0xa0, 0x07, 0x49, 0xfe, 0xc1, + 0x68, 0xdd, 0x72, 0xb4, 0x74, 0xe2, 0x78, 0x27, 0xc8, 0x7f, 0xf0, 0x37, 0xbc, 0x5c, 0xf2, 0x92, + 0xfe, 0x74, 0x49, 0x7b, 0xb5, 0xbb, 0x33, 0x7e, 0x28, 0xa9, 0xed, 0x13, 0xaf, 0x91, 0xfe, 0xea, + 0xde, 0xee, 0x44, 0x1e, 0xe7, 0x2f, 0xe9, 0x8a, 0xdb, 0xaa, 0x2d, 0x12, 0x26, 0x9b, 0x34, 0xd7, + 0x65, 0xcb, 0x85, 0x3c, 0x7c, 0x67, 0xac, 0xe6, 0xa9, 0x5b, 0xea, 0x6c, 0x85, 0x62, 0xbf, 0xeb, + 0xc2, 0x77, 0xe4, 0xe1, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x5e, 0x3f, 0x26, 0x2c, 0x02, 0x00, + 0x00, +} diff --git a/proto-gen/commands/rpc_v1/types.pb.go b/proto-gen/commands/rpc_v1/types.pb.go new file mode 100644 index 00000000000..11b92bca1ae --- /dev/null +++ b/proto-gen/commands/rpc_v1/types.pb.go @@ -0,0 +1,266 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: commands/rpc_v1/types.proto + +package rpc_v1 + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type Instance struct { + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Instance) Reset() { *m = Instance{} } +func (m *Instance) String() string { return proto.CompactTextString(m) } +func (*Instance) ProtoMessage() {} +func (*Instance) Descriptor() ([]byte, []int) { + return fileDescriptor_1cb19cc6bc90b0b1, []int{0} +} + +func (m *Instance) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Instance.Unmarshal(m, b) +} +func (m *Instance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Instance.Marshal(b, m, deterministic) +} +func (m *Instance) XXX_Merge(src proto.Message) { + xxx_messageInfo_Instance.Merge(m, src) +} +func (m *Instance) XXX_Size() int { + return xxx_messageInfo_Instance.Size(m) +} +func (m *Instance) XXX_DiscardUnknown() { + xxx_messageInfo_Instance.DiscardUnknown(m) +} + +var xxx_messageInfo_Instance proto.InternalMessageInfo + +func (m *Instance) GetId() int32 { + if m != nil { + return m.Id + } + return 0 +} + +type DownloadProgress struct { + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + File string `protobuf:"bytes,2,opt,name=file,proto3" json:"file,omitempty"` + TotalSize int64 `protobuf:"varint,3,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"` + Downloaded int64 `protobuf:"varint,4,opt,name=downloaded,proto3" json:"downloaded,omitempty"` + Completed bool `protobuf:"varint,5,opt,name=completed,proto3" json:"completed,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DownloadProgress) Reset() { *m = DownloadProgress{} } +func (m *DownloadProgress) String() string { return proto.CompactTextString(m) } +func (*DownloadProgress) ProtoMessage() {} +func (*DownloadProgress) Descriptor() ([]byte, []int) { + return fileDescriptor_1cb19cc6bc90b0b1, []int{1} +} + +func (m *DownloadProgress) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DownloadProgress.Unmarshal(m, b) +} +func (m *DownloadProgress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DownloadProgress.Marshal(b, m, deterministic) +} +func (m *DownloadProgress) XXX_Merge(src proto.Message) { + xxx_messageInfo_DownloadProgress.Merge(m, src) +} +func (m *DownloadProgress) XXX_Size() int { + return xxx_messageInfo_DownloadProgress.Size(m) +} +func (m *DownloadProgress) XXX_DiscardUnknown() { + xxx_messageInfo_DownloadProgress.DiscardUnknown(m) +} + +var xxx_messageInfo_DownloadProgress proto.InternalMessageInfo + +func (m *DownloadProgress) GetUrl() string { + if m != nil { + return m.Url + } + return "" +} + +func (m *DownloadProgress) GetFile() string { + if m != nil { + return m.File + } + return "" +} + +func (m *DownloadProgress) GetTotalSize() int64 { + if m != nil { + return m.TotalSize + } + return 0 +} + +func (m *DownloadProgress) GetDownloaded() int64 { + if m != nil { + return m.Downloaded + } + return 0 +} + +func (m *DownloadProgress) GetCompleted() bool { + if m != nil { + return m.Completed + } + return false +} + +type TaskProgress struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + Completed bool `protobuf:"varint,3,opt,name=completed,proto3" json:"completed,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TaskProgress) Reset() { *m = TaskProgress{} } +func (m *TaskProgress) String() string { return proto.CompactTextString(m) } +func (*TaskProgress) ProtoMessage() {} +func (*TaskProgress) Descriptor() ([]byte, []int) { + return fileDescriptor_1cb19cc6bc90b0b1, []int{2} +} + +func (m *TaskProgress) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TaskProgress.Unmarshal(m, b) +} +func (m *TaskProgress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TaskProgress.Marshal(b, m, deterministic) +} +func (m *TaskProgress) XXX_Merge(src proto.Message) { + xxx_messageInfo_TaskProgress.Merge(m, src) +} +func (m *TaskProgress) XXX_Size() int { + return xxx_messageInfo_TaskProgress.Size(m) +} +func (m *TaskProgress) XXX_DiscardUnknown() { + xxx_messageInfo_TaskProgress.DiscardUnknown(m) +} + +var xxx_messageInfo_TaskProgress proto.InternalMessageInfo + +func (m *TaskProgress) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *TaskProgress) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func (m *TaskProgress) GetCompleted() bool { + if m != nil { + return m.Completed + } + return false +} + +// Response returned by functions running external processes +type ExecResp struct { + OutStream []byte `protobuf:"bytes,1,opt,name=out_stream,json=outStream,proto3" json:"out_stream,omitempty"` + ErrStream []byte `protobuf:"bytes,2,opt,name=err_stream,json=errStream,proto3" json:"err_stream,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExecResp) Reset() { *m = ExecResp{} } +func (m *ExecResp) String() string { return proto.CompactTextString(m) } +func (*ExecResp) ProtoMessage() {} +func (*ExecResp) Descriptor() ([]byte, []int) { + return fileDescriptor_1cb19cc6bc90b0b1, []int{3} +} + +func (m *ExecResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExecResp.Unmarshal(m, b) +} +func (m *ExecResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExecResp.Marshal(b, m, deterministic) +} +func (m *ExecResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecResp.Merge(m, src) +} +func (m *ExecResp) XXX_Size() int { + return xxx_messageInfo_ExecResp.Size(m) +} +func (m *ExecResp) XXX_DiscardUnknown() { + xxx_messageInfo_ExecResp.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecResp proto.InternalMessageInfo + +func (m *ExecResp) GetOutStream() []byte { + if m != nil { + return m.OutStream + } + return nil +} + +func (m *ExecResp) GetErrStream() []byte { + if m != nil { + return m.ErrStream + } + return nil +} + +func init() { + proto.RegisterType((*Instance)(nil), "rpc_v1.Instance") + proto.RegisterType((*DownloadProgress)(nil), "rpc_v1.DownloadProgress") + proto.RegisterType((*TaskProgress)(nil), "rpc_v1.TaskProgress") + proto.RegisterType((*ExecResp)(nil), "rpc_v1.ExecResp") +} + +func init() { proto.RegisterFile("commands/rpc_v1/types.proto", fileDescriptor_1cb19cc6bc90b0b1) } + +var fileDescriptor_1cb19cc6bc90b0b1 = []byte{ + // 302 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xcb, 0x6a, 0xeb, 0x30, + 0x10, 0x86, 0xb1, 0x9d, 0xe4, 0xc4, 0x43, 0x38, 0x04, 0xad, 0x4c, 0x6f, 0x84, 0xac, 0xb2, 0x49, + 0x4c, 0xe8, 0x1b, 0x94, 0x16, 0xda, 0x5d, 0x71, 0xba, 0xca, 0x26, 0x28, 0xd2, 0xd4, 0x15, 0x95, + 0x34, 0x46, 0x92, 0x7b, 0xc9, 0x7b, 0xf4, 0x7d, 0x4b, 0x94, 0xb8, 0xb7, 0x95, 0x46, 0xdf, 0x27, + 0x7e, 0x7e, 0x31, 0x70, 0x2a, 0xc8, 0x18, 0x6e, 0xa5, 0x2f, 0x5d, 0x23, 0x36, 0x2f, 0xcb, 0x32, + 0xbc, 0x37, 0xe8, 0x17, 0x8d, 0xa3, 0x40, 0x6c, 0x70, 0x60, 0xd3, 0x13, 0x18, 0xde, 0x59, 0x1f, + 0xb8, 0x15, 0xc8, 0xfe, 0x43, 0xaa, 0x64, 0x91, 0x4c, 0x92, 0x59, 0xbf, 0x4a, 0x95, 0x9c, 0x7e, + 0x24, 0x30, 0xbe, 0xa6, 0x57, 0xab, 0x89, 0xcb, 0x7b, 0x47, 0xb5, 0x43, 0xef, 0xd9, 0x18, 0xb2, + 0xd6, 0xe9, 0xf8, 0x2a, 0xaf, 0xf6, 0x23, 0x63, 0xd0, 0x7b, 0x54, 0x1a, 0x8b, 0x34, 0xa2, 0x38, + 0xb3, 0x73, 0x80, 0x40, 0x81, 0xeb, 0x8d, 0x57, 0x3b, 0x2c, 0xb2, 0x49, 0x32, 0xcb, 0xaa, 0x3c, + 0x92, 0x95, 0xda, 0x21, 0xbb, 0x00, 0x90, 0xc7, 0x60, 0x94, 0x45, 0x2f, 0xea, 0x1f, 0x84, 0x9d, + 0x41, 0x2e, 0xc8, 0x34, 0x1a, 0x03, 0xca, 0xa2, 0x3f, 0x49, 0x66, 0xc3, 0xea, 0x1b, 0x4c, 0xd7, + 0x30, 0x7a, 0xe0, 0xfe, 0xf9, 0xab, 0x12, 0x83, 0x9e, 0xe5, 0x06, 0x8f, 0x9d, 0xe2, 0xcc, 0x0a, + 0xf8, 0x67, 0xd0, 0x7b, 0x5e, 0x77, 0xbd, 0xba, 0xeb, 0xef, 0xec, 0xec, 0x6f, 0xf6, 0x2d, 0x0c, + 0x6f, 0xde, 0x50, 0x54, 0xe8, 0x9b, 0xfd, 0x27, 0xa8, 0x0d, 0x1b, 0x1f, 0x1c, 0x72, 0x13, 0xd3, + 0x47, 0x55, 0x4e, 0x6d, 0x58, 0x45, 0xb0, 0xd7, 0xe8, 0x5c, 0xa7, 0xd3, 0x83, 0x46, 0xe7, 0x0e, + 0xfa, 0x6a, 0xb9, 0x2e, 0x6b, 0x15, 0x9e, 0xda, 0xed, 0x42, 0x90, 0x29, 0xb9, 0x93, 0xad, 0xb2, + 0xd4, 0x9d, 0x73, 0xa1, 0x55, 0x19, 0x37, 0x31, 0xaf, 0xd1, 0x1e, 0x17, 0xb4, 0x1d, 0x44, 0x72, + 0xf9, 0x19, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x25, 0x8e, 0x1e, 0xba, 0x01, 0x00, 0x00, +} diff --git a/rpc/commands.pb.go b/rpc/commands.pb.go index 6ee60fab704..bf299f595bc 100644 --- a/rpc/commands.pb.go +++ b/rpc/commands.pb.go @@ -1206,7 +1206,6 @@ type ArduinoCoreServer interface { BoardAttach(*BoardAttachReq, ArduinoCore_BoardAttachServer) error BoardList(context.Context, *BoardListReq) (*BoardListResp, error) BoardListAll(context.Context, *BoardListAllReq) (*BoardListAllResp, error) - Compile(*CompileReq, ArduinoCore_CompileServer) error PlatformInstall(*PlatformInstallReq, ArduinoCore_PlatformInstallServer) error PlatformDownload(*PlatformDownloadReq, ArduinoCore_PlatformDownloadServer) error PlatformUninstall(*PlatformUninstallReq, ArduinoCore_PlatformUninstallServer) error @@ -1418,14 +1417,6 @@ func _ArduinoCore_BoardListAll_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _ArduinoCore_Compile_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(CompileReq) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(ArduinoCoreServer).Compile(m, &arduinoCoreCompileServer{stream}) -} - type ArduinoCore_CompileServer interface { Send(*CompileResp) error grpc.ServerStream @@ -1766,11 +1757,6 @@ var _ArduinoCore_serviceDesc = grpc.ServiceDesc{ Handler: _ArduinoCore_BoardAttach_Handler, ServerStreams: true, }, - { - StreamName: "Compile", - Handler: _ArduinoCore_Compile_Handler, - ServerStreams: true, - }, { StreamName: "PlatformInstall", Handler: _ArduinoCore_PlatformInstall_Handler,