diff --git a/go.mod b/go.mod index aaef35eada6..6c36cd3e6e7 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/fatih/color v1.7.0 github.com/fluxio/iohelpers v0.0.0-20160419043813-3a4dd67a94d2 // indirect github.com/fluxio/multierror v0.0.0-20160419044231-9c68d39025e5 // indirect - github.com/fsnotify/fsnotify v1.4.7 github.com/gofrs/uuid v3.2.0+incompatible github.com/golang/protobuf v1.3.3 github.com/h2non/filetype v1.0.8 // indirect diff --git a/go.sum b/go.sum index 099067dc63c..b13d6acdbed 100644 --- a/go.sum +++ b/go.sum @@ -38,12 +38,9 @@ github.com/codeclysm/extract v2.2.0+incompatible h1:q3wyckoA30bhUSiwdQezMqVhwd8+ github.com/codeclysm/extract v2.2.0+incompatible/go.mod h1:2nhFMPHiU9At61hz+12bfrlpXSUrOnK+wR+KlGO4Uks= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/goselect v0.1.1 h1:tiSSgKE1eJtxs1h/VgGQWuXUP0YS4CDIFMp6vaI1ls0= @@ -170,8 +167,6 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo= github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/schollz/closestmatch v2.1.0+incompatible h1:Uel2GXEpJqOWBrlyI+oY9LTiyyjYS17cCYRqP13/SHk= @@ -197,15 +192,12 @@ github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E= github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= @@ -219,7 +211,6 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -239,7 +230,6 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -265,7 +255,6 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/legacy/builder/client/client.go b/legacy/builder/client/client.go deleted file mode 100644 index c7ff4f3e478..00000000000 --- a/legacy/builder/client/client.go +++ /dev/null @@ -1,84 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 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 implements a simple gRPC client that demonstrates how to use gRPC-Go libraries -// to perform unary, client streaming, server streaming and full duplex RPCs. -// -// It interacts with the route guide service whose definition can be found in routeguide/route_guide.proto. -package main - -import ( - "io" - "log" - - pb "github.com/arduino/arduino-cli/legacy/builder/grpc/proto" - "golang.org/x/net/context" - "google.golang.org/grpc" -) - -// printFeature gets the feature for the given point. -func autocomplete(client pb.BuilderClient, in *pb.BuildParams) { - resp, err := client.Autocomplete(context.Background(), in) - if err != nil { - log.Fatalf("%v.GetFeatures(_) = _, %v: ", client, err) - } - log.Println(resp) -} - -// printFeatures lists all the features within the given bounding Rectangle. -func build(client pb.BuilderClient, in *pb.BuildParams) { - stream, err := client.Build(context.Background(), in) - if err != nil { - log.Fatalf("%v.ListFeatures(_) = _, %v", client, err) - } - for { - line, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - log.Fatalf("%v.ListFeatures(_) = _, %v", client, err) - } - log.Println(line) - } -} - -func main() { - conn, err := grpc.Dial("localhost:12345", grpc.WithInsecure()) - if err != nil { - log.Fatalf("fail to dial: %v", err) - } - defer conn.Close() - - client := pb.NewBuilderClient(conn) - - exampleParames := pb.BuildParams{ - BuiltInLibrariesFolders: "/ssd/Arduino-master/build/linux/work/libraries", - CustomBuildProperties: "build.warn_data_percentage=75", - FQBN: "arduino:avr:mega:cpu=atmega2560", - HardwareFolders: "/ssd/Arduino-master/build/linux/work/hardware,/home/martino/.arduino15/packages,/home/martino/eslov-sk/hardware", - OtherLibrariesFolders: "/home/martino/eslov-sk/libraries", - ArduinoAPIVersion: "10805", - SketchLocation: "/home/martino/eslov-sk/libraries/WiFi101/examples/ScanNetworks/ScanNetworks.ino", - ToolsFolders: "/ssd/Arduino-master/build/linux/work/tools-builder,/ssd/Arduino-master/build/linux/work/hardware/tools/avr,/home/martino/.arduino15/packages", - Verbose: true, - WarningsLevel: "all", - BuildCachePath: "/tmp/arduino_cache_761418/", - CodeCompleteAt: "/home/martino/eslov-sk/libraries/WiFi101/examples/ScanNetworks/ScanNetworks.ino:56:9", - } - - //build(client, &exampleParames) - autocomplete(client, &exampleParames) -} diff --git a/legacy/builder/grpc/proto/builder.pb.go b/legacy/builder/grpc/proto/builder.pb.go deleted file mode 100644 index 4690c81cf7d..00000000000 --- a/legacy/builder/grpc/proto/builder.pb.go +++ /dev/null @@ -1,396 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: builder.proto - -/* -Package proto is a generated protocol buffer package. - -It is generated from these files: - builder.proto - -It has these top-level messages: - BuildParams - VerboseParams - Response -*/ -package proto - -import proto1 "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -import ( - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto1.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 _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package - -type BuildParams struct { - HardwareFolders string `protobuf:"bytes,1,opt,name=hardwareFolders" json:"hardwareFolders,omitempty"` - ToolsFolders string `protobuf:"bytes,2,opt,name=toolsFolders" json:"toolsFolders,omitempty"` - BuiltInLibrariesFolders string `protobuf:"bytes,3,opt,name=builtInLibrariesFolders" json:"builtInLibrariesFolders,omitempty"` - OtherLibrariesFolders string `protobuf:"bytes,4,opt,name=otherLibrariesFolders" json:"otherLibrariesFolders,omitempty"` - SketchLocation string `protobuf:"bytes,5,opt,name=sketchLocation" json:"sketchLocation,omitempty"` - FQBN string `protobuf:"bytes,6,opt,name=fQBN" json:"fQBN,omitempty"` - ArduinoAPIVersion string `protobuf:"bytes,7,opt,name=arduinoAPIVersion" json:"arduinoAPIVersion,omitempty"` - CustomBuildProperties string `protobuf:"bytes,8,opt,name=customBuildProperties" json:"customBuildProperties,omitempty"` - BuildCachePath string `protobuf:"bytes,9,opt,name=buildCachePath" json:"buildCachePath,omitempty"` - BuildPath string `protobuf:"bytes,10,opt,name=buildPath" json:"buildPath,omitempty"` - WarningsLevel string `protobuf:"bytes,11,opt,name=warningsLevel" json:"warningsLevel,omitempty"` - CodeCompleteAt string `protobuf:"bytes,12,opt,name=codeCompleteAt" json:"codeCompleteAt,omitempty"` - Verbose bool `protobuf:"varint,13,opt,name=verbose" json:"verbose,omitempty"` -} - -func (m *BuildParams) Reset() { *m = BuildParams{} } -func (m *BuildParams) String() string { return proto1.CompactTextString(m) } -func (*BuildParams) ProtoMessage() {} -func (*BuildParams) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *BuildParams) GetHardwareFolders() string { - if m != nil { - return m.HardwareFolders - } - return "" -} - -func (m *BuildParams) GetToolsFolders() string { - if m != nil { - return m.ToolsFolders - } - return "" -} - -func (m *BuildParams) GetBuiltInLibrariesFolders() string { - if m != nil { - return m.BuiltInLibrariesFolders - } - return "" -} - -func (m *BuildParams) GetOtherLibrariesFolders() string { - if m != nil { - return m.OtherLibrariesFolders - } - return "" -} - -func (m *BuildParams) GetSketchLocation() string { - if m != nil { - return m.SketchLocation - } - return "" -} - -func (m *BuildParams) GetFQBN() string { - if m != nil { - return m.FQBN - } - return "" -} - -func (m *BuildParams) GetArduinoAPIVersion() string { - if m != nil { - return m.ArduinoAPIVersion - } - return "" -} - -func (m *BuildParams) GetCustomBuildProperties() string { - if m != nil { - return m.CustomBuildProperties - } - return "" -} - -func (m *BuildParams) GetBuildCachePath() string { - if m != nil { - return m.BuildCachePath - } - return "" -} - -func (m *BuildParams) GetBuildPath() string { - if m != nil { - return m.BuildPath - } - return "" -} - -func (m *BuildParams) GetWarningsLevel() string { - if m != nil { - return m.WarningsLevel - } - return "" -} - -func (m *BuildParams) GetCodeCompleteAt() string { - if m != nil { - return m.CodeCompleteAt - } - return "" -} - -func (m *BuildParams) GetVerbose() bool { - if m != nil { - return m.Verbose - } - return false -} - -type VerboseParams struct { - Verbose bool `protobuf:"varint,1,opt,name=verbose" json:"verbose,omitempty"` -} - -func (m *VerboseParams) Reset() { *m = VerboseParams{} } -func (m *VerboseParams) String() string { return proto1.CompactTextString(m) } -func (*VerboseParams) ProtoMessage() {} -func (*VerboseParams) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -func (m *VerboseParams) GetVerbose() bool { - if m != nil { - return m.Verbose - } - return false -} - -type Response struct { - Line string `protobuf:"bytes,1,opt,name=line" json:"line,omitempty"` -} - -func (m *Response) Reset() { *m = Response{} } -func (m *Response) String() string { return proto1.CompactTextString(m) } -func (*Response) ProtoMessage() {} -func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } - -func (m *Response) GetLine() string { - if m != nil { - return m.Line - } - return "" -} - -func init() { - proto1.RegisterType((*BuildParams)(nil), "proto.BuildParams") - proto1.RegisterType((*VerboseParams)(nil), "proto.VerboseParams") - proto1.RegisterType((*Response)(nil), "proto.Response") -} - -// 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 - -// Client API for Builder service - -type BuilderClient interface { - // A server-to-client streaming RPC. - // - // Obtains the Features available within the given Rectangle. Results are - // streamed rather than returned at once (e.g. in a response message with a - // repeated field), as the rectangle may cover a large area and contain a - // huge number of features. - Build(ctx context.Context, in *BuildParams, opts ...grpc.CallOption) (Builder_BuildClient, error) - Autocomplete(ctx context.Context, in *BuildParams, opts ...grpc.CallOption) (*Response, error) - DropCache(ctx context.Context, in *VerboseParams, opts ...grpc.CallOption) (*Response, error) -} - -type builderClient struct { - cc *grpc.ClientConn -} - -func NewBuilderClient(cc *grpc.ClientConn) BuilderClient { - return &builderClient{cc} -} - -func (c *builderClient) Build(ctx context.Context, in *BuildParams, opts ...grpc.CallOption) (Builder_BuildClient, error) { - stream, err := grpc.NewClientStream(ctx, &_Builder_serviceDesc.Streams[0], c.cc, "/proto.Builder/Build", opts...) - if err != nil { - return nil, err - } - x := &builderBuildClient{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 Builder_BuildClient interface { - Recv() (*Response, error) - grpc.ClientStream -} - -type builderBuildClient struct { - grpc.ClientStream -} - -func (x *builderBuildClient) Recv() (*Response, error) { - m := new(Response) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *builderClient) Autocomplete(ctx context.Context, in *BuildParams, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := grpc.Invoke(ctx, "/proto.Builder/Autocomplete", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *builderClient) DropCache(ctx context.Context, in *VerboseParams, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := grpc.Invoke(ctx, "/proto.Builder/DropCache", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Builder service - -type BuilderServer interface { - // A server-to-client streaming RPC. - // - // Obtains the Features available within the given Rectangle. Results are - // streamed rather than returned at once (e.g. in a response message with a - // repeated field), as the rectangle may cover a large area and contain a - // huge number of features. - Build(*BuildParams, Builder_BuildServer) error - Autocomplete(context.Context, *BuildParams) (*Response, error) - DropCache(context.Context, *VerboseParams) (*Response, error) -} - -func RegisterBuilderServer(s *grpc.Server, srv BuilderServer) { - s.RegisterService(&_Builder_serviceDesc, srv) -} - -func _Builder_Build_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(BuildParams) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(BuilderServer).Build(m, &builderBuildServer{stream}) -} - -type Builder_BuildServer interface { - Send(*Response) error - grpc.ServerStream -} - -type builderBuildServer struct { - grpc.ServerStream -} - -func (x *builderBuildServer) Send(m *Response) error { - return x.ServerStream.SendMsg(m) -} - -func _Builder_Autocomplete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(BuildParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(BuilderServer).Autocomplete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.Builder/Autocomplete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(BuilderServer).Autocomplete(ctx, req.(*BuildParams)) - } - return interceptor(ctx, in, info, handler) -} - -func _Builder_DropCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(VerboseParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(BuilderServer).DropCache(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.Builder/DropCache", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(BuilderServer).DropCache(ctx, req.(*VerboseParams)) - } - return interceptor(ctx, in, info, handler) -} - -var _Builder_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.Builder", - HandlerType: (*BuilderServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Autocomplete", - Handler: _Builder_Autocomplete_Handler, - }, - { - MethodName: "DropCache", - Handler: _Builder_DropCache_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Build", - Handler: _Builder_Build_Handler, - ServerStreams: true, - }, - }, - Metadata: "builder.proto", -} - -func init() { proto1.RegisterFile("builder.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x6f, 0x6b, 0x13, 0x41, - 0x10, 0xc6, 0x3d, 0x4d, 0x9a, 0x64, 0x9a, 0x58, 0x1c, 0x14, 0x17, 0x11, 0x29, 0xa1, 0x48, 0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8, 0x3c, 0x7d, 0x34, 0xf9, 0x38, 0xa5, 0x2f, 0x3c, - 0x5e, 0x64, 0xe5, 0x51, 0xe8, 0x7b, 0xff, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xb2, 0x39, 0x66, 0x51, - 0x56, 0x03, 0x00, 0x00, -} diff --git a/legacy/builder/grpc/proto/builder.proto b/legacy/builder/grpc/proto/builder.proto deleted file mode 100644 index 7419c730671..00000000000 --- a/legacy/builder/grpc/proto/builder.proto +++ /dev/null @@ -1,65 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// Copyright 2015 Matthijs Kooijman -// -// 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. - -// compile me with: protoc -I proto/ proto/builder.proto --go_out=plugins=grpc:proto - -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "cc.arduino.builder"; -option java_outer_classname = "BuilderProto"; - -package proto; - -// Interface exported by the server. -service Builder { - - // A server-to-client streaming RPC. - // - // Obtains the Features available within the given Rectangle. Results are - // streamed rather than returned at once (e.g. in a response message with a - // repeated field), as the rectangle may cover a large area and contain a - // huge number of features. - rpc Build(BuildParams) returns (stream Response) {} - - rpc Autocomplete(BuildParams) returns (Response) {} - - rpc DropCache(VerboseParams) returns (Response) {} -} - -message BuildParams { - string hardwareFolders = 1; - string toolsFolders = 2; - string builtInLibrariesFolders = 3; - string otherLibrariesFolders = 4; - string sketchLocation = 5; - string fQBN = 6; - string arduinoAPIVersion = 7; - string customBuildProperties = 8; - string buildCachePath = 9; - string buildPath = 10; - string warningsLevel = 11; - string codeCompleteAt = 12; - bool verbose = 13; -} - -message VerboseParams { - bool verbose = 1; -} - -message Response { - string line = 1; -} diff --git a/legacy/builder/grpc/rpc.go b/legacy/builder/grpc/rpc.go deleted file mode 100644 index d135d03900a..00000000000 --- a/legacy/builder/grpc/rpc.go +++ /dev/null @@ -1,235 +0,0 @@ -package jsonrpc - -import ( - "fmt" - "io" - "log" - "net" - "os" - "strings" - - "github.com/arduino/arduino-cli/arduino/cores" - "github.com/arduino/go-paths-helper" - - "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/legacy/builder/utils" - "github.com/fsnotify/fsnotify" - "golang.org/x/net/context" - "google.golang.org/grpc" - - pb "github.com/arduino/arduino-cli/legacy/builder/grpc/proto" -) - -type StreamLogger struct { - stream pb.Builder_BuildServer -} - -func (s StreamLogger) Fprintln(w io.Writer, level string, format string, a ...interface{}) { - s.stream.Send(&pb.Response{Line: fmt.Sprintf(format, a...)}) -} - -func (s StreamLogger) UnformattedFprintln(w io.Writer, str string) { - s.stream.Send(&pb.Response{Line: str}) -} - -func (s StreamLogger) UnformattedWrite(w io.Writer, data []byte) { - s.stream.Send(&pb.Response{Line: string(data)}) -} - -func (s StreamLogger) Println(level string, format string, a ...interface{}) { - s.stream.Send(&pb.Response{Line: fmt.Sprintf(format, a...)}) -} - -func (s StreamLogger) Flush() string { - return "" -} - -func (s StreamLogger) Name() string { - return "streamlogger" -} - -type builderServer struct { - resp []*pb.Response - ctx *types.Context - watcher *fsnotify.Watcher -} - -func (s *builderServer) watch() { - folders := []paths.PathList{s.ctx.HardwareDirs, s.ctx.BuiltInToolsDirs, s.ctx.BuiltInLibrariesDirs, s.ctx.OtherLibrariesDirs} - - for _, category := range folders { - for _, folder := range category { - if !s.ctx.WatchedLocations.Contains(folder) { - var subfolders []string - utils.FindAllSubdirectories(folder.String(), &subfolders) - subfolders = append(subfolders, folder.String()) - for _, element := range subfolders { - s.watcher.Add(element) - s.ctx.WatchedLocations.AddIfMissing(paths.New(element)) - } - } - } - } -} - -func (s *builderServer) DropCache(ctx context.Context, args *pb.VerboseParams) (*pb.Response, error) { - s.ctx.CanUseCachedTools = false - response := pb.Response{Line: "Tools cache dropped"} - return &response, nil -} - -// GetFeature returns the feature at the given point. -func (s *builderServer) Autocomplete(ctx context.Context, args *pb.BuildParams) (*pb.Response, error) { - - s.ctx.HardwareDirs = paths.NewPathList(strings.Split(args.HardwareFolders, ",")...) - s.ctx.BuiltInToolsDirs = paths.NewPathList(strings.Split(args.ToolsFolders, ",")...) - s.ctx.BuiltInLibrariesDirs = paths.NewPathList(strings.Split(args.BuiltInLibrariesFolders, ",")...) - s.ctx.OtherLibrariesDirs = paths.NewPathList(strings.Split(args.OtherLibrariesFolders, ",")...) - s.ctx.SketchLocation = paths.New(args.SketchLocation) - s.ctx.CustomBuildProperties = strings.Split(args.CustomBuildProperties, ",") - s.ctx.ArduinoAPIVersion = args.ArduinoAPIVersion - if fqbn, err := cores.ParseFQBN(args.FQBN); err != nil { - return nil, fmt.Errorf("parsing fqbn: %s", err) - } else { - s.ctx.FQBN = fqbn - } - s.ctx.Verbose = false //p.Verbose - s.ctx.BuildCachePath = paths.New(args.BuildCachePath) - s.ctx.BuildPath = paths.New(args.BuildPath) - s.ctx.WarningsLevel = args.WarningsLevel - s.ctx.PrototypesSection = "" - s.ctx.CodeCompleteAt = args.CodeCompleteAt - s.ctx.CodeCompletions = "" - - s.ctx.IncludeFolders = s.ctx.IncludeFolders[0:0] - s.ctx.LibrariesObjectFiles = s.ctx.LibrariesObjectFiles[0:0] - s.ctx.CoreObjectsFiles = s.ctx.CoreObjectsFiles[0:0] - s.ctx.SketchObjectFiles = s.ctx.SketchObjectFiles[0:0] - - s.ctx.ImportedLibraries = s.ctx.ImportedLibraries[0:0] - - //s.watch() - - oldlogger := s.ctx.GetLogger() - logger := i18n.NoopLogger{} - s.ctx.SetLogger(logger) - - err := builder.RunPreprocess(s.ctx) - - response := pb.Response{Line: s.ctx.CodeCompletions} - s.ctx.SetLogger(oldlogger) - - return &response, err -} - -// GetFeature returns the feature at the given point. -func (s *builderServer) Build(args *pb.BuildParams, stream pb.Builder_BuildServer) error { - - s.ctx.HardwareDirs = paths.NewPathList(strings.Split(args.HardwareFolders, ",")...) - s.ctx.BuiltInToolsDirs = paths.NewPathList(strings.Split(args.ToolsFolders, ",")...) - s.ctx.BuiltInLibrariesDirs = paths.NewPathList(strings.Split(args.BuiltInLibrariesFolders, ",")...) - s.ctx.OtherLibrariesDirs = paths.NewPathList(strings.Split(args.OtherLibrariesFolders, ",")...) - s.ctx.SketchLocation = paths.New(args.SketchLocation) - s.ctx.CustomBuildProperties = strings.Split(args.CustomBuildProperties, ",") - s.ctx.ArduinoAPIVersion = args.ArduinoAPIVersion - if fqbn, err := cores.ParseFQBN(args.FQBN); err != nil { - return fmt.Errorf("parsing fqbn: %s", err) - } else { - s.ctx.FQBN = fqbn - } - s.ctx.Verbose = args.Verbose - s.ctx.BuildCachePath = paths.New(args.BuildCachePath) - s.ctx.BuildPath = paths.New(args.BuildPath) - s.ctx.WarningsLevel = args.WarningsLevel - s.ctx.PrototypesSection = "" - s.ctx.CodeCompleteAt = "" - - s.ctx.IncludeFolders = s.ctx.IncludeFolders[0:0] - s.ctx.LibrariesObjectFiles = s.ctx.LibrariesObjectFiles[0:0] - s.ctx.CoreObjectsFiles = s.ctx.CoreObjectsFiles[0:0] - s.ctx.SketchObjectFiles = s.ctx.SketchObjectFiles[0:0] - - s.ctx.ImportedLibraries = s.ctx.ImportedLibraries[0:0] - - // setup logger to send via protobuf - oldlogger := s.ctx.GetLogger() - logger := StreamLogger{stream} - s.ctx.SetLogger(logger) - - //s.watch() - - err := builder.RunBuilder(s.ctx) - s.ctx.SetLogger(oldlogger) - if err != nil { - return err - } - - // No feature was found, return an unnamed feature - return nil -} - -/* -func (h *WatchHandler) ServeJSONRPC(c context.Context, params *json.RawMessage) (interface{}, *jsonrpc.Error) { - - var p WatchParams - if err := jsonrpc.Unmarshal(params, &p); err != nil { - return nil, err - } - - err := h.watcher.Add(p.Path) - if err != nil { - return nil, jsonrpc.ErrInvalidParams() - } - return BuildResult{ - Message: "OK " + p.Path, - }, nil -} -*/ - -func startWatching(ctx *types.Context) *fsnotify.Watcher { - watcher, err := fsnotify.NewWatcher() - if err != nil { - log.Fatal(err) - } - - go func() { - for { - select { - case event := <-watcher.Events: - ctx.CanUseCachedTools = false - log.Println("event:", event) - case err := <-watcher.Errors: - log.Println("error:", err) - } - } - }() - return watcher -} - -func newServerWithWatcher(ctx *types.Context, watcher *fsnotify.Watcher) *builderServer { - s := new(builderServer) - s.ctx = ctx - s.watcher = watcher - return s -} - -func newServer(ctx *types.Context) *builderServer { - s := new(builderServer) - s.ctx = ctx - return s -} - -func RegisterAndServeJsonRPC(ctx *types.Context) { - lis, err := net.Listen("tcp", "localhost:12345") - if err != nil { - //can't spawn two grpc servers on the same port - os.Exit(0) - } - //watcher := startWatching(ctx) - - grpcServer := grpc.NewServer() - pb.RegisterBuilderServer(grpcServer, newServer(ctx)) - grpcServer.Serve(lis) -}