Unverified Commit 71c55d74 authored by Cristian Maglie's avatar Cristian Maglie Committed by GitHub

[breaking] gRPC: improved CompileRequest.export_binaries field definition (#2570)

* [breaking] gRPC: improved CompileRequest.export_binaries field definition

* Disable protogetter check
parent 32d8833d
......@@ -29,7 +29,8 @@ linters:
- tenv
- typecheck
- unconvert
- protogetter
# We must disable this one because there is no support 'optional' protobuf fields yet: https://github.com/arduino/arduino-cli/pull/2570
#- protogetter
linters-settings:
forbidigo:
......
......@@ -43,18 +43,9 @@ var tr = i18n.Tr
// Compile FIXMEDOC
func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream io.Writer, progressCB rpc.TaskProgressCB) (r *rpc.BuilderResult, e error) {
// There is a binding between the export binaries setting and the CLI flag to explicitly set it,
// since we want this binding to work also for the gRPC interface we must read it here in this
// package instead of the cli/compile one, otherwise we'd lose the binding.
exportBinaries := configuration.Settings.GetBool("sketch.always_export_binaries")
// If we'd just read the binding in any case, even if the request sets the export binaries setting,
// the settings value would always overwrite the request one and it wouldn't have any effect
// setting it for individual requests. To solve this we use a wrapper.BoolValue to handle
// the optionality of this property, otherwise we would have no way of knowing if the property
// was set in the request or it's just the default boolean value.
if reqExportBinaries := req.GetExportBinaries(); reqExportBinaries != nil {
exportBinaries = reqExportBinaries.GetValue()
if e := req.ExportBinaries; e != nil {
exportBinaries = *e
}
pme, release, err := instances.GetPackageManagerExplorer(req.GetInstance())
......
......@@ -4,6 +4,13 @@ Here you can find a list of migration guides to handle breaking changes between
## 0.36.0
### The gRPC `cc.arduino.cli.commands.v1.CompileRequest.export_binaries` changed type.
Previously the field `export_binaries` was a `google.protobuf.BoolValue`. We used this type because it expresses this
field's optional nature (that is, it could be `true`, `false`, and `null` if not set).
Now the field is an `optional bool`, since the latest protobuf protocol changes now allows optional fields.
### The gRPC `cc.arduino.cli.commands.v1.UpdateIndexResponse` and `UpdateLibrariesIndexResponse` have changed.
The responses coming from the update index commands:
......
......@@ -61,6 +61,7 @@ var (
uploadAfterCompile bool // Upload the binary after the compilation.
portArgs arguments.Port // Upload port, e.g.: COM10 or /dev/ttyACM0.
verify bool // Upload, verify uploaded binary after the upload.
exportBinaries bool //
exportDir string // The compiled binary is written to this file
optimizeForDebug bool // Optimize compile output for debug, not for release
programmer arguments.Programmer // Use the specified programmer to upload
......@@ -127,10 +128,7 @@ func NewCommand() *cobra.Command {
programmer.AddToCommand(compileCommand)
compileCommand.Flags().BoolVar(&compilationDatabaseOnly, "only-compilation-database", false, tr("Just produce the compilation database, without actually compiling. All build commands are skipped except pre* hooks."))
compileCommand.Flags().BoolVar(&clean, "clean", false, tr("Optional, cleanup the build folder and do not use any cached build."))
// We must use the following syntax for this flag since it's also bound to settings.
// This must be done because the value is set when the binding is accessed from viper. Accessing from cobra would only
// read the value if the flag is set explicitly by the user.
compileCommand.Flags().BoolP("export-binaries", "e", false, tr("If set built binaries will be exported to the sketch folder."))
compileCommand.Flags().BoolVarP(&exportBinaries, "export-binaries", "e", false, tr("If set built binaries will be exported to the sketch folder."))
compileCommand.Flags().StringVar(&sourceOverrides, "source-override", "", tr("Optional. Path to a .json file that contains a set of replacements of the sketch source code."))
compileCommand.Flag("source-override").Hidden = true
compileCommand.Flags().BoolVar(&skipLibrariesDiscovery, "skip-libraries-discovery", false, "Skip libraries discovery. This flag is provided only for use in language server and other, very specific, use cases. Do not use for normal compiles")
......
......@@ -19,7 +19,6 @@ package cc.arduino.cli.commands.v1;
option go_package = "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1;commands";
import "google/protobuf/wrappers.proto";
import "cc/arduino/cli/commands/v1/common.proto";
import "cc/arduino/cli/commands/v1/lib.proto";
......@@ -75,7 +74,7 @@ message CompileRequest {
map<string, string> source_override = 22;
// When set to `true` the compiled binary will be copied to the export
// directory.
google.protobuf.BoolValue export_binaries = 23;
optional bool export_binaries = 23;
// A list of paths to single libraries root directory.
repeated string library = 24;
// The path where to search for the custom signing key name and the encrypt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment