From cb70a39aecfa8830da1146a3e88d663657d4dca5 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 27 May 2022 16:16:05 +0200 Subject: [PATCH 01/10] [breaking] report platforms installation dir in compile result --- arduino/cores/cores.go | 9 ++- rpc/cc/arduino/cli/commands/v1/common.pb.go | 83 ++++++++++--------- rpc/cc/arduino/cli/commands/v1/common.proto | 4 +- rpc/cc/arduino/cli/commands/v1/compile.pb.go | 85 ++++++++++---------- rpc/cc/arduino/cli/commands/v1/compile.proto | 4 +- 5 files changed, 100 insertions(+), 85 deletions(-) diff --git a/arduino/cores/cores.go b/arduino/cores/cores.go index 60a6d5d54d6..f522db916d7 100644 --- a/arduino/cores/cores.go +++ b/arduino/cores/cores.go @@ -359,10 +359,11 @@ func (release *PlatformRelease) String() string { } // ToRPCPlatformReference creates a gRPC PlatformReference message out of this PlatformRelease -func (release *PlatformRelease) ToRPCPlatformReference() *rpc.PlatformReference { - return &rpc.PlatformReference{ - Id: release.Platform.String(), - Version: release.Version.String(), +func (release *PlatformRelease) ToRPCPlatformReference() *rpc.InstalledPlatformReference { + return &rpc.InstalledPlatformReference{ + Id: release.Platform.String(), + Version: release.Version.String(), + InstallDir: release.InstallDir.String(), } } diff --git a/rpc/cc/arduino/cli/commands/v1/common.pb.go b/rpc/cc/arduino/cli/commands/v1/common.pb.go index 08f268c7b67..38c0e4102d5 100644 --- a/rpc/cc/arduino/cli/commands/v1/common.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/common.pb.go @@ -439,7 +439,7 @@ func (x *Platform) GetDeprecated() bool { return false } -type PlatformReference struct { +type InstalledPlatformReference struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -448,10 +448,12 @@ type PlatformReference struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Version of the platform. Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + // Installation directory of the platform + InstallDir string `protobuf:"bytes,3,opt,name=install_dir,json=installDir,proto3" json:"install_dir,omitempty"` } -func (x *PlatformReference) Reset() { - *x = PlatformReference{} +func (x *InstalledPlatformReference) Reset() { + *x = InstalledPlatformReference{} if protoimpl.UnsafeEnabled { mi := &file_cc_arduino_cli_commands_v1_common_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -459,13 +461,13 @@ func (x *PlatformReference) Reset() { } } -func (x *PlatformReference) String() string { +func (x *InstalledPlatformReference) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PlatformReference) ProtoMessage() {} +func (*InstalledPlatformReference) ProtoMessage() {} -func (x *PlatformReference) ProtoReflect() protoreflect.Message { +func (x *InstalledPlatformReference) ProtoReflect() protoreflect.Message { mi := &file_cc_arduino_cli_commands_v1_common_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -477,25 +479,32 @@ func (x *PlatformReference) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PlatformReference.ProtoReflect.Descriptor instead. -func (*PlatformReference) Descriptor() ([]byte, []int) { +// Deprecated: Use InstalledPlatformReference.ProtoReflect.Descriptor instead. +func (*InstalledPlatformReference) Descriptor() ([]byte, []int) { return file_cc_arduino_cli_commands_v1_common_proto_rawDescGZIP(), []int{5} } -func (x *PlatformReference) GetId() string { +func (x *InstalledPlatformReference) GetId() string { if x != nil { return x.Id } return "" } -func (x *PlatformReference) GetVersion() string { +func (x *InstalledPlatformReference) GetVersion() string { if x != nil { return x.Version } return "" } +func (x *InstalledPlatformReference) GetInstallDir() string { + if x != nil { + return x.InstallDir + } + return "" +} + type Board struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -661,23 +670,25 @@ var file_cc_arduino_cli_commands_v1_common_proto_rawDesc = []byte{ 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x6d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x6c, 0x79, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x22, 0x3d, - 0x0a, 0x11, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, - 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2f, 0x0a, - 0x05, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, - 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x22, 0x31, - 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, - 0x6e, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, - 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, - 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, - 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x22, 0x67, + 0x0a, 0x1a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, + 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, + 0x6c, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x22, 0x2f, 0x0a, 0x05, 0x42, 0x6f, 0x61, 0x72, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x22, 0x31, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x42, 0x48, 0x5a, 0x46, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, + 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, + 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -694,14 +705,14 @@ func file_cc_arduino_cli_commands_v1_common_proto_rawDescGZIP() []byte { var file_cc_arduino_cli_commands_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_cc_arduino_cli_commands_v1_common_proto_goTypes = []interface{}{ - (*Instance)(nil), // 0: cc.arduino.cli.commands.v1.Instance - (*DownloadProgress)(nil), // 1: cc.arduino.cli.commands.v1.DownloadProgress - (*TaskProgress)(nil), // 2: cc.arduino.cli.commands.v1.TaskProgress - (*Programmer)(nil), // 3: cc.arduino.cli.commands.v1.Programmer - (*Platform)(nil), // 4: cc.arduino.cli.commands.v1.Platform - (*PlatformReference)(nil), // 5: cc.arduino.cli.commands.v1.PlatformReference - (*Board)(nil), // 6: cc.arduino.cli.commands.v1.Board - (*Profile)(nil), // 7: cc.arduino.cli.commands.v1.Profile + (*Instance)(nil), // 0: cc.arduino.cli.commands.v1.Instance + (*DownloadProgress)(nil), // 1: cc.arduino.cli.commands.v1.DownloadProgress + (*TaskProgress)(nil), // 2: cc.arduino.cli.commands.v1.TaskProgress + (*Programmer)(nil), // 3: cc.arduino.cli.commands.v1.Programmer + (*Platform)(nil), // 4: cc.arduino.cli.commands.v1.Platform + (*InstalledPlatformReference)(nil), // 5: cc.arduino.cli.commands.v1.InstalledPlatformReference + (*Board)(nil), // 6: cc.arduino.cli.commands.v1.Board + (*Profile)(nil), // 7: cc.arduino.cli.commands.v1.Profile } var file_cc_arduino_cli_commands_v1_common_proto_depIdxs = []int32{ 6, // 0: cc.arduino.cli.commands.v1.Platform.boards:type_name -> cc.arduino.cli.commands.v1.Board @@ -779,7 +790,7 @@ func file_cc_arduino_cli_commands_v1_common_proto_init() { } } file_cc_arduino_cli_commands_v1_common_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PlatformReference); i { + switch v := v.(*InstalledPlatformReference); i { case 0: return &v.state case 1: diff --git a/rpc/cc/arduino/cli/commands/v1/common.proto b/rpc/cc/arduino/cli/commands/v1/common.proto index 75c90cd5e3c..27742989656 100644 --- a/rpc/cc/arduino/cli/commands/v1/common.proto +++ b/rpc/cc/arduino/cli/commands/v1/common.proto @@ -82,11 +82,13 @@ message Platform { bool deprecated = 10; } -message PlatformReference { +message InstalledPlatformReference { // Platform ID (e.g., `arduino:avr`). string id = 1; // Version of the platform. string version = 2; + // Installation directory of the platform + string install_dir = 3; } message Board { diff --git a/rpc/cc/arduino/cli/commands/v1/compile.pb.go b/rpc/cc/arduino/cli/commands/v1/compile.pb.go index fc0087936f9..6f958b8c2a9 100644 --- a/rpc/cc/arduino/cli/commands/v1/compile.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/compile.pb.go @@ -322,9 +322,9 @@ type CompileResponse struct { // The size of the executable split by sections ExecutableSectionsSize []*ExecutableSectionSize `protobuf:"bytes,5,rep,name=executable_sections_size,json=executableSectionsSize,proto3" json:"executable_sections_size,omitempty"` // The platform where the board is defined - BoardPlatform *PlatformReference `protobuf:"bytes,6,opt,name=board_platform,json=boardPlatform,proto3" json:"board_platform,omitempty"` + BoardPlatform *InstalledPlatformReference `protobuf:"bytes,6,opt,name=board_platform,json=boardPlatform,proto3" json:"board_platform,omitempty"` // The platform used for the build (if referenced from the board platform) - BuildPlatform *PlatformReference `protobuf:"bytes,7,opt,name=build_platform,json=buildPlatform,proto3" json:"build_platform,omitempty"` + BuildPlatform *InstalledPlatformReference `protobuf:"bytes,7,opt,name=build_platform,json=buildPlatform,proto3" json:"build_platform,omitempty"` // Completions reports of the compilation process (stream) Progress *TaskProgress `protobuf:"bytes,8,opt,name=progress,proto3" json:"progress,omitempty"` } @@ -396,14 +396,14 @@ func (x *CompileResponse) GetExecutableSectionsSize() []*ExecutableSectionSize { return nil } -func (x *CompileResponse) GetBoardPlatform() *PlatformReference { +func (x *CompileResponse) GetBoardPlatform() *InstalledPlatformReference { if x != nil { return x.BoardPlatform } return nil } -func (x *CompileResponse) GetBuildPlatform() *PlatformReference { +func (x *CompileResponse) GetBuildPlatform() *InstalledPlatformReference { if x != nil { return x.BuildPlatform } @@ -557,7 +557,7 @@ var file_cc_arduino_cli_commands_v1_compile_proto_rawDesc = []byte{ 0x63, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x99, 0x04, 0x0a, 0x0f, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xab, 0x04, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6f, 0x75, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6f, 0x75, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1d, @@ -576,33 +576,34 @@ var file_cc_arduino_cli_commands_v1_compile_proto_rawDesc = []byte{ 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x69, 0x7a, 0x65, 0x52, 0x16, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x54, 0x0a, 0x0e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x70, - 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, + 0x73, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x5d, 0x0a, 0x0e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, 0x70, + 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, - 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x62, 0x6f, - 0x61, 0x72, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x54, 0x0a, 0x0e, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, - 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, - 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, - 0x63, 0x65, 0x52, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x12, 0x44, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, - 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, - 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0x5a, 0x0a, 0x15, 0x45, 0x78, 0x65, 0x63, 0x75, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x69, 0x7a, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x61, 0x78, 0x5f, - 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6d, 0x61, 0x78, 0x53, - 0x69, 0x7a, 0x65, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, - 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, - 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x50, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x5d, 0x0a, 0x0e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x70, 0x6c, + 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x63, + 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, + 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, + 0x6f, 0x72, 0x6d, 0x12, 0x44, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, + 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0x5a, 0x0a, 0x15, 0x45, 0x78, 0x65, + 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x69, + 0x7a, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x61, + 0x78, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6d, 0x61, + 0x78, 0x53, 0x69, 0x7a, 0x65, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, + 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, + 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -619,15 +620,15 @@ func file_cc_arduino_cli_commands_v1_compile_proto_rawDescGZIP() []byte { var file_cc_arduino_cli_commands_v1_compile_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_cc_arduino_cli_commands_v1_compile_proto_goTypes = []interface{}{ - (*CompileRequest)(nil), // 0: cc.arduino.cli.commands.v1.CompileRequest - (*CompileResponse)(nil), // 1: cc.arduino.cli.commands.v1.CompileResponse - (*ExecutableSectionSize)(nil), // 2: cc.arduino.cli.commands.v1.ExecutableSectionSize - nil, // 3: cc.arduino.cli.commands.v1.CompileRequest.SourceOverrideEntry - (*Instance)(nil), // 4: cc.arduino.cli.commands.v1.Instance - (*wrapperspb.BoolValue)(nil), // 5: google.protobuf.BoolValue - (*Library)(nil), // 6: cc.arduino.cli.commands.v1.Library - (*PlatformReference)(nil), // 7: cc.arduino.cli.commands.v1.PlatformReference - (*TaskProgress)(nil), // 8: cc.arduino.cli.commands.v1.TaskProgress + (*CompileRequest)(nil), // 0: cc.arduino.cli.commands.v1.CompileRequest + (*CompileResponse)(nil), // 1: cc.arduino.cli.commands.v1.CompileResponse + (*ExecutableSectionSize)(nil), // 2: cc.arduino.cli.commands.v1.ExecutableSectionSize + nil, // 3: cc.arduino.cli.commands.v1.CompileRequest.SourceOverrideEntry + (*Instance)(nil), // 4: cc.arduino.cli.commands.v1.Instance + (*wrapperspb.BoolValue)(nil), // 5: google.protobuf.BoolValue + (*Library)(nil), // 6: cc.arduino.cli.commands.v1.Library + (*InstalledPlatformReference)(nil), // 7: cc.arduino.cli.commands.v1.InstalledPlatformReference + (*TaskProgress)(nil), // 8: cc.arduino.cli.commands.v1.TaskProgress } var file_cc_arduino_cli_commands_v1_compile_proto_depIdxs = []int32{ 4, // 0: cc.arduino.cli.commands.v1.CompileRequest.instance:type_name -> cc.arduino.cli.commands.v1.Instance @@ -635,8 +636,8 @@ var file_cc_arduino_cli_commands_v1_compile_proto_depIdxs = []int32{ 5, // 2: cc.arduino.cli.commands.v1.CompileRequest.export_binaries:type_name -> google.protobuf.BoolValue 6, // 3: cc.arduino.cli.commands.v1.CompileResponse.used_libraries:type_name -> cc.arduino.cli.commands.v1.Library 2, // 4: cc.arduino.cli.commands.v1.CompileResponse.executable_sections_size:type_name -> cc.arduino.cli.commands.v1.ExecutableSectionSize - 7, // 5: cc.arduino.cli.commands.v1.CompileResponse.board_platform:type_name -> cc.arduino.cli.commands.v1.PlatformReference - 7, // 6: cc.arduino.cli.commands.v1.CompileResponse.build_platform:type_name -> cc.arduino.cli.commands.v1.PlatformReference + 7, // 5: cc.arduino.cli.commands.v1.CompileResponse.board_platform:type_name -> cc.arduino.cli.commands.v1.InstalledPlatformReference + 7, // 6: cc.arduino.cli.commands.v1.CompileResponse.build_platform:type_name -> cc.arduino.cli.commands.v1.InstalledPlatformReference 8, // 7: cc.arduino.cli.commands.v1.CompileResponse.progress:type_name -> cc.arduino.cli.commands.v1.TaskProgress 8, // [8:8] is the sub-list for method output_type 8, // [8:8] is the sub-list for method input_type diff --git a/rpc/cc/arduino/cli/commands/v1/compile.proto b/rpc/cc/arduino/cli/commands/v1/compile.proto index 3e8f71ae395..61eabaeeb17 100644 --- a/rpc/cc/arduino/cli/commands/v1/compile.proto +++ b/rpc/cc/arduino/cli/commands/v1/compile.proto @@ -101,9 +101,9 @@ message CompileResponse { // The size of the executable split by sections repeated ExecutableSectionSize executable_sections_size = 5; // The platform where the board is defined - PlatformReference board_platform = 6; + InstalledPlatformReference board_platform = 6; // The platform used for the build (if referenced from the board platform) - PlatformReference build_platform = 7; + InstalledPlatformReference build_platform = 7; // Completions reports of the compilation process (stream) TaskProgress progress = 8; } From 0b0d1c92c3426d1a843f728ef132265dd3a31e8b Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 27 May 2022 16:11:20 +0200 Subject: [PATCH 02/10] Added platforms and libraries used in the build report --- cli/compile/compile.go | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/cli/compile/compile.go b/cli/compile/compile.go index 93100bc8a3d..649f53b78bc 100644 --- a/cli/compile/compile.go +++ b/cli/compile/compile.go @@ -33,6 +33,8 @@ import ( "github.com/arduino/arduino-cli/commands" "github.com/arduino/arduino-cli/configuration" "github.com/arduino/arduino-cli/i18n" + "github.com/arduino/arduino-cli/table" + "github.com/fatih/color" "github.com/sirupsen/logrus" "github.com/arduino/arduino-cli/cli/errorcodes" @@ -316,6 +318,45 @@ func (r *compileResult) Data() interface{} { } func (r *compileResult) String() string { - // The output is already printed via os.Stdout/os.Stdin - return "" + titleColor := color.New(color.FgHiGreen) + nameColor := color.New(color.FgHiYellow) + pathColor := color.New(color.FgHiBlack) + build := r.BuilderResult + + res := "\n" + libraries := table.New() + if len(build.GetUsedLibraries()) > 0 { + libraries.SetHeader( + table.NewCell(tr("Used library"), titleColor), + table.NewCell(tr("Version"), titleColor), + table.NewCell(tr("Path"), pathColor)) + for _, l := range build.GetUsedLibraries() { + libraries.AddRow( + table.NewCell(l.GetName(), nameColor), + l.GetVersion(), + table.NewCell(l.GetInstallDir(), pathColor)) + } + } + res += libraries.Render() + "\n" + + platforms := table.New() + platforms.SetHeader( + table.NewCell(tr("Used platform"), titleColor), + table.NewCell(tr("Version"), titleColor), + table.NewCell(tr("Path"), pathColor)) + boardPlatform := build.GetBoardPlatform() + platforms.AddRow( + table.NewCell(boardPlatform.GetId(), nameColor), + boardPlatform.GetVersion(), + table.NewCell(boardPlatform.GetInstallDir(), pathColor)) + if buildPlatform := build.GetBuildPlatform(); buildPlatform != nil && + buildPlatform.Id != boardPlatform.Id && + buildPlatform.Version != boardPlatform.Version { + platforms.AddRow( + table.NewCell(buildPlatform.GetId(), nameColor), + buildPlatform.GetVersion(), + table.NewCell(buildPlatform.GetInstallDir(), pathColor)) + } + res += platforms.Render() + return res } From 61563a4039f1ede942cc93929d39a38e19611fff Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 27 May 2022 16:23:55 +0200 Subject: [PATCH 03/10] Report used libraries even in case of unsuccessful build --- commands/compile/compile.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/commands/compile/compile.go b/commands/compile/compile.go index 03a2093da9f..234fed5b977 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -219,6 +219,19 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream return r, compileErr } + defer func() { + importedLibs := []*rpc.Library{} + for _, lib := range builderCtx.ImportedLibraries { + rpcLib, err := lib.ToRPCLibrary() + if err != nil { + msg := tr("Error getting information for library %s", lib.Name) + ": " + err.Error() + "\n" + errStream.Write([]byte(msg)) + } + importedLibs = append(importedLibs, rpcLib) + } + r.UsedLibraries = importedLibs + }() + // if it's a regular build, go on... if err := builder.RunBuilder(builderCtx); err != nil { return r, &arduino.CompileFailedError{Message: err.Error()} @@ -268,16 +281,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream } } - importedLibs := []*rpc.Library{} - for _, lib := range builderCtx.ImportedLibraries { - rpcLib, err := lib.ToRPCLibrary() - if err != nil { - return r, &arduino.PermissionDeniedError{Message: tr("Error getting information for library %s", lib.Name), Cause: err} - } - importedLibs = append(importedLibs, rpcLib) - } - r.UsedLibraries = importedLibs - r.ExecutableSectionsSize = builderCtx.ExecutableSectionsSize.ToRPCExecutableSectionSizeArray() logrus.Tracef("Compile %s for %s successful", sk.Name, fqbnIn) From 6644d04e6e66bdc98f6cbab37fc7914d0eb13ccb Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 31 May 2022 11:22:07 +0200 Subject: [PATCH 04/10] Added 3rd party platform url in InstalledPlatofrm grpc response --- arduino/cores/cores.go | 5 +++ rpc/cc/arduino/cli/commands/v1/common.pb.go | 49 +++++++++++++-------- rpc/cc/arduino/cli/commands/v1/common.proto | 2 + 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/arduino/cores/cores.go b/arduino/cores/cores.go index f522db916d7..672d1402bb0 100644 --- a/arduino/cores/cores.go +++ b/arduino/cores/cores.go @@ -360,10 +360,15 @@ func (release *PlatformRelease) String() string { // ToRPCPlatformReference creates a gRPC PlatformReference message out of this PlatformRelease func (release *PlatformRelease) ToRPCPlatformReference() *rpc.InstalledPlatformReference { + url := release.Platform.Package.URL + if strings.HasPrefix(url, "https://downloads.arduino.cc/packages/package_index.") { + url = "" + } return &rpc.InstalledPlatformReference{ Id: release.Platform.String(), Version: release.Version.String(), InstallDir: release.InstallDir.String(), + PackageUrl: url, } } diff --git a/rpc/cc/arduino/cli/commands/v1/common.pb.go b/rpc/cc/arduino/cli/commands/v1/common.pb.go index 38c0e4102d5..65c93f179f9 100644 --- a/rpc/cc/arduino/cli/commands/v1/common.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/common.pb.go @@ -450,6 +450,8 @@ type InstalledPlatformReference struct { Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // Installation directory of the platform InstallDir string `protobuf:"bytes,3,opt,name=install_dir,json=installDir,proto3" json:"install_dir,omitempty"` + // 3rd party platform URL + PackageUrl string `protobuf:"bytes,4,opt,name=package_url,json=packageUrl,proto3" json:"package_url,omitempty"` } func (x *InstalledPlatformReference) Reset() { @@ -505,6 +507,13 @@ func (x *InstalledPlatformReference) GetInstallDir() string { return "" } +func (x *InstalledPlatformReference) GetPackageUrl() string { + if x != nil { + return x.PackageUrl + } + return "" +} + type Board struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -670,25 +679,27 @@ var file_cc_arduino_cli_commands_v1_common_proto_rawDesc = []byte{ 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x6d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x6c, 0x79, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x22, 0x67, - 0x0a, 0x1a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, - 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, - 0x6c, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x22, 0x2f, 0x0a, 0x05, 0x42, 0x6f, 0x61, 0x72, 0x64, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x22, 0x31, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x66, - 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x42, 0x48, 0x5a, 0x46, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, - 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, - 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x22, 0x88, + 0x01, 0x0a, 0x1a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x44, 0x69, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x55, 0x72, 0x6c, 0x22, 0x2f, 0x0a, 0x05, 0x42, 0x6f, 0x61, + 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x22, 0x31, 0x0a, 0x07, 0x50, 0x72, + 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x42, 0x48, 0x5a, + 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, + 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, + 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, + 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/rpc/cc/arduino/cli/commands/v1/common.proto b/rpc/cc/arduino/cli/commands/v1/common.proto index 27742989656..a94085b9e5b 100644 --- a/rpc/cc/arduino/cli/commands/v1/common.proto +++ b/rpc/cc/arduino/cli/commands/v1/common.proto @@ -89,6 +89,8 @@ message InstalledPlatformReference { string version = 2; // Installation directory of the platform string install_dir = 3; + // 3rd party platform URL + string package_url = 4; } message Board { From cf9bc040c8ee6368c4dddfcd8637ddfb9c0e8a94 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 31 May 2022 11:24:19 +0200 Subject: [PATCH 05/10] Added temporary functionality to support profile creation It will be probably deprecated and removed once a better UX is implemented. --- cli/compile/compile.go | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/cli/compile/compile.go b/cli/compile/compile.go index 649f53b78bc..6edfc9a3336 100644 --- a/cli/compile/compile.go +++ b/cli/compile/compile.go @@ -70,6 +70,7 @@ var ( clean bool // Cleanup the build folder and do not use any cached build compilationDatabaseOnly bool // Only create compilation database without actually compiling sourceOverrides string // Path to a .json file that contains a set of replacements of the sketch source code. + dumpProfile bool // Create and print a profile configuration from the build // library and libraries sound similar but they're actually different. // library expects a path to the root folder of one single library. // libraries expects a path to a directory containing multiple libraries, similarly to the /libraries path. @@ -95,6 +96,7 @@ func NewCommand() *cobra.Command { fqbnArg.AddToCommand(compileCommand) profileArg.AddToCommand(compileCommand) + compileCommand.Flags().BoolVar(&dumpProfile, "dump-profile", false, tr("Create and print a profile configuration from the build.")) compileCommand.Flags().BoolVar(&showProperties, "show-properties", false, tr("Show all build properties used instead of compiling.")) compileCommand.Flags().BoolVar(&preprocess, "preprocess", false, tr("Print preprocessed code to stdout instead of compiling.")) compileCommand.Flags().StringVar(&buildCachePath, "build-cache-path", "", tr("Builds of 'core.a' are saved into this path to be cached and reused.")) @@ -270,6 +272,50 @@ func runCompileCommand(cmd *cobra.Command, args []string) { } } + if dumpProfile { + libs := "" + hasVendoredLibs := false + for _, lib := range compileRes.GetUsedLibraries() { + if lib.Location != rpc.LibraryLocation_LIBRARY_LOCATION_USER && lib.Location != rpc.LibraryLocation_LIBRARY_LOCATION_UNMANAGED { + continue + } + if lib.GetVersion() == "" { + hasVendoredLibs = true + continue + } + libs += fmt.Sprintln(" - " + lib.GetName() + " (" + lib.GetVersion() + ")") + } + if hasVendoredLibs { + fmt.Println() + fmt.Println(tr("WARNING: The sketch is compiled using one or more custom libraries.")) + fmt.Println(tr("Currently, Build Profiles only support libraries available through Arduino Library Manager.")) + } + + fmt.Println() + fmt.Println("profile:") + fmt.Println(" my_profile_name:") + fmt.Println(" fqbn: " + compileRequest.GetFqbn()) + fmt.Println(" platforms:") + boardPlatform := compileRes.GetBoardPlatform() + fmt.Println(" - platform: " + boardPlatform.GetId() + " (" + boardPlatform.GetVersion() + ")") + if url := boardPlatform.GetPackageUrl(); url != "" { + fmt.Println(" platform_index_url: " + url) + } + + if buildPlatform := compileRes.GetBuildPlatform(); buildPlatform != nil && + buildPlatform.Id != boardPlatform.Id && + buildPlatform.Version != boardPlatform.Version { + fmt.Println(" - platform: " + buildPlatform.GetId() + " (" + buildPlatform.GetVersion() + ")") + if url := buildPlatform.GetPackageUrl(); url != "" { + fmt.Println(" platform_index_url: " + url) + } + } + if len(libs) > 0 { + fmt.Println(" libraries:") + fmt.Print(libs) + } + } + feedback.PrintResult(&compileResult{ CompileOut: compileStdOut.String(), CompileErr: compileStdErr.String(), From f7d5354d081f8569db949e0dac65930db6a4f0b3 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 31 May 2022 15:48:41 +0200 Subject: [PATCH 06/10] Updated documentation --- docs/UPGRADING.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 36ec080dd36..75df0decc39 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -13,6 +13,17 @@ but since it has been the default behaviour from a very long time we decided to If a compilation fail for a missing bundled library, you can fix it just by installing the missing library from the library manager as usual. +### gRPC: Changes in message `cc.arduino.cli.commands.v1.PlatformReference` + +The gRPC message structure `cc.arduino.cli.commands.v1.PlatformReference` has been renamed to +`cc.arduino.cli.commands.v1.InstalledPlatformReference`, and some new fields have been added: + +- `install_dir` is the installation directory of the platform +- `package_url` is the 3rd party platform URL of the platform + +It is currently used only in `cc.arduino.cli.commands.v1.CompileResponse`, so the field type has been changed as well. +Old gRPC clients must only update gRPC bindings. They can safely ignore the new fields if not needed. + ### golang API: PackageManager.DownloadPlatformRelease no longer need `label` parameter ```go From 25e6df5ed673869a8e3239498b0488c3277ca10e Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 31 May 2022 17:22:38 +0200 Subject: [PATCH 07/10] Use the last part of the FQBN for suggested profile name --- cli/compile/compile.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/compile/compile.go b/cli/compile/compile.go index 6edfc9a3336..33fab9b510a 100644 --- a/cli/compile/compile.go +++ b/cli/compile/compile.go @@ -291,9 +291,13 @@ func runCompileCommand(cmd *cobra.Command, args []string) { fmt.Println(tr("Currently, Build Profiles only support libraries available through Arduino Library Manager.")) } + newProfileName := "my_profile_name" + if split := strings.Split(compileRequest.GetFqbn(), ":"); len(split) > 2 { + newProfileName = split[2] + } fmt.Println() fmt.Println("profile:") - fmt.Println(" my_profile_name:") + fmt.Println(" " + newProfileName + ":") fmt.Println(" fqbn: " + compileRequest.GetFqbn()) fmt.Println(" platforms:") boardPlatform := compileRes.GetBoardPlatform() From d5e359f8c5cf7878fd580add58e49232d88c4722 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 1 Jun 2022 16:08:47 +0200 Subject: [PATCH 08/10] Move DefaultIndexURL under arduino/globals as it should be --- arduino/cores/packagemanager/profiles.go | 2 +- arduino/globals/globals.go | 3 +++ cli/core/search.go | 2 +- cli/globals/globals.go | 2 -- commands/instances.go | 5 +++-- docs/UPGRADING.md | 4 ++++ 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/arduino/cores/packagemanager/profiles.go b/arduino/cores/packagemanager/profiles.go index fb295476fe2..30bf9a69cc5 100644 --- a/arduino/cores/packagemanager/profiles.go +++ b/arduino/cores/packagemanager/profiles.go @@ -21,9 +21,9 @@ import ( "github.com/arduino/arduino-cli/arduino" "github.com/arduino/arduino-cli/arduino/cores" + "github.com/arduino/arduino-cli/arduino/globals" "github.com/arduino/arduino-cli/arduino/resources" "github.com/arduino/arduino-cli/arduino/sketch" - "github.com/arduino/arduino-cli/cli/globals" "github.com/arduino/arduino-cli/configuration" rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" "github.com/arduino/go-paths-helper" diff --git a/arduino/globals/globals.go b/arduino/globals/globals.go index c320b177878..97e0b75e958 100644 --- a/arduino/globals/globals.go +++ b/arduino/globals/globals.go @@ -56,4 +56,7 @@ var ( ".hpp": empty, ".hh": empty, } + + // DefaultIndexURL is the default index url + DefaultIndexURL = "https://downloads.arduino.cc/packages/package_index.tar.bz2" ) diff --git a/cli/core/search.go b/cli/core/search.go index afaf32f4409..7493763c5fc 100644 --- a/cli/core/search.go +++ b/cli/core/search.go @@ -23,10 +23,10 @@ import ( "strings" "time" + "github.com/arduino/arduino-cli/arduino/globals" "github.com/arduino/arduino-cli/arduino/utils" "github.com/arduino/arduino-cli/cli/errorcodes" "github.com/arduino/arduino-cli/cli/feedback" - "github.com/arduino/arduino-cli/cli/globals" "github.com/arduino/arduino-cli/cli/instance" "github.com/arduino/arduino-cli/cli/output" "github.com/arduino/arduino-cli/commands" diff --git a/cli/globals/globals.go b/cli/globals/globals.go index d0369683059..f48339ddd72 100644 --- a/cli/globals/globals.go +++ b/cli/globals/globals.go @@ -25,6 +25,4 @@ import ( var ( // VersionInfo contains all info injected during build VersionInfo = version.NewInfo(filepath.Base(os.Args[0])) - // DefaultIndexURL is the default index url - DefaultIndexURL = "https://downloads.arduino.cc/packages/package_index.tar.bz2" ) diff --git a/commands/instances.go b/commands/instances.go index 952fde1ad47..79700833e3f 100644 --- a/commands/instances.go +++ b/commands/instances.go @@ -27,6 +27,7 @@ import ( "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/globals" "github.com/arduino/arduino-cli/arduino/httpclient" "github.com/arduino/arduino-cli/arduino/libraries" "github.com/arduino/arduino-cli/arduino/libraries/librariesindex" @@ -34,7 +35,7 @@ import ( "github.com/arduino/arduino-cli/arduino/resources" "github.com/arduino/arduino-cli/arduino/sketch" "github.com/arduino/arduino-cli/arduino/utils" - "github.com/arduino/arduino-cli/cli/globals" + cliglobals "github.com/arduino/arduino-cli/cli/globals" "github.com/arduino/arduino-cli/configuration" "github.com/arduino/arduino-cli/i18n" rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" @@ -128,7 +129,7 @@ func Create(req *rpc.CreateRequest, extraUserAgent ...string) (*rpc.CreateRespon } // Create package manager - userAgent := "arduino-cli/" + globals.VersionInfo.VersionString + userAgent := "arduino-cli/" + cliglobals.VersionInfo.VersionString for _, ua := range extraUserAgent { userAgent += " " + ua } diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 75df0decc39..402ce4e2493 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -24,6 +24,10 @@ The gRPC message structure `cc.arduino.cli.commands.v1.PlatformReference` has be It is currently used only in `cc.arduino.cli.commands.v1.CompileResponse`, so the field type has been changed as well. Old gRPC clients must only update gRPC bindings. They can safely ignore the new fields if not needed. +### golang API: `github.com/arduino/arduino-cli/cli/globals.DefaultIndexURL` has been moved under `github.com/arduino/arduino-cli/arduino/globals` + +Legacy code should just update the import. + ### golang API: PackageManager.DownloadPlatformRelease no longer need `label` parameter ```go From 0ec4a34e117982dccd09913c12c309237e2a8e12 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 1 Jun 2022 16:22:17 +0200 Subject: [PATCH 09/10] Use global index url --- arduino/cores/cores.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arduino/cores/cores.go b/arduino/cores/cores.go index 672d1402bb0..3201112d50b 100644 --- a/arduino/cores/cores.go +++ b/arduino/cores/cores.go @@ -21,9 +21,11 @@ import ( "encoding/json" "fmt" "net/url" + "path/filepath" "sort" "strings" + "github.com/arduino/arduino-cli/arduino/globals" "github.com/arduino/arduino-cli/arduino/resources" "github.com/arduino/arduino-cli/arduino/utils" "github.com/arduino/arduino-cli/i18n" @@ -360,8 +362,13 @@ func (release *PlatformRelease) String() string { // ToRPCPlatformReference creates a gRPC PlatformReference message out of this PlatformRelease func (release *PlatformRelease) ToRPCPlatformReference() *rpc.InstalledPlatformReference { + defaultURLPrefix := globals.DefaultIndexURL + // TODO: create a IndexURL object to factorize this + defaultURLPrefix = strings.TrimSuffix(defaultURLPrefix, filepath.Ext(defaultURLPrefix)) + defaultURLPrefix = strings.TrimSuffix(defaultURLPrefix, filepath.Ext(defaultURLPrefix)) // removes .tar.bz2 + url := release.Platform.Package.URL - if strings.HasPrefix(url, "https://downloads.arduino.cc/packages/package_index.") { + if strings.HasPrefix(url, defaultURLPrefix) { url = "" } return &rpc.InstalledPlatformReference{ From df09be2388dc580c3531f1f2b188bca02fc5fb17 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 1 Jun 2022 16:25:41 +0200 Subject: [PATCH 10/10] Output an error if dump-profile is used with json output --- cli/compile/compile.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/compile/compile.go b/cli/compile/compile.go index 33fab9b510a..a23de369381 100644 --- a/cli/compile/compile.go +++ b/cli/compile/compile.go @@ -146,6 +146,10 @@ func NewCommand() *cobra.Command { func runCompileCommand(cmd *cobra.Command, args []string) { logrus.Info("Executing `arduino-cli compile`") + if dumpProfile && feedback.GetFormat() != feedback.Text { + feedback.Errorf(tr("You cannot use the %[1]s flag together with %[2]s.", "--dump-profile", "--format json")) + os.Exit(errorcodes.ErrBadArgument) + } if profileArg.Get() != "" { if len(libraries) > 0 { feedback.Errorf(tr("You cannot use the %s flag while compiling with a profile.", "--libraries"))