Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fecb334

Browse files
committed
[breaking] gRPC: improved CompileRequest.export_binaries field definition
1 parent 32d8833 commit fecb334

File tree

5 files changed

+150
-159
lines changed

5 files changed

+150
-159
lines changed

‎commands/compile/compile.go‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,9 @@ var tr = i18n.Tr
4343

4444
// Compile FIXMEDOC
4545
func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream io.Writer, progressCB rpc.TaskProgressCB) (r *rpc.BuilderResult, e error) {
46-
47-
// There is a binding between the export binaries setting and the CLI flag to explicitly set it,
48-
// since we want this binding to work also for the gRPC interface we must read it here in this
49-
// package instead of the cli/compile one, otherwise we'd lose the binding.
5046
exportBinaries := configuration.Settings.GetBool("sketch.always_export_binaries")
51-
// If we'd just read the binding in any case, even if the request sets the export binaries setting,
52-
// the settings value would always overwrite the request one and it wouldn't have any effect
53-
// setting it for individual requests. To solve this we use a wrapper.BoolValue to handle
54-
// the optionality of this property, otherwise we would have no way of knowing if the property
55-
// was set in the request or it's just the default boolean value.
56-
if reqExportBinaries := req.GetExportBinaries(); reqExportBinaries != nil {
57-
exportBinaries = reqExportBinaries.GetValue()
47+
if e := req.ExportBinaries; e != nil {
48+
exportBinaries = *e
5849
}
5950

6051
pme, release, err := instances.GetPackageManagerExplorer(req.GetInstance())

‎docs/UPGRADING.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ Here you can find a list of migration guides to handle breaking changes between
44

55
## 0.36.0
66

7+
### The gRPC `cc.arduino.cli.commands.v1.CompileRequest.export_binaries` changed type.
8+
9+
Previously the field `export_binaries` was a `google.protobuf.BoolValue`. We used this type because it expresses this
10+
field's optional nature (that is, it could be `true`, `false`, and `null` if not set).
11+
12+
Now the field is an `optional bool`, since the latest protobuf protocol changes now allows optional fields.
13+
714
### The gRPC `cc.arduino.cli.commands.v1.UpdateIndexResponse` and `UpdateLibrariesIndexResponse` have changed.
815

916
The responses coming from the update index commands:

‎internal/cli/compile/compile.go‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var (
6161
uploadAfterCompile bool // Upload the binary after the compilation.
6262
portArgs arguments.Port // Upload port, e.g.: COM10 or /dev/ttyACM0.
6363
verify bool // Upload, verify uploaded binary after the upload.
64+
exportBinaries bool //
6465
exportDir string // The compiled binary is written to this file
6566
optimizeForDebug bool // Optimize compile output for debug, not for release
6667
programmer arguments.Programmer // Use the specified programmer to upload
@@ -127,10 +128,7 @@ func NewCommand() *cobra.Command {
127128
programmer.AddToCommand(compileCommand)
128129
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."))
129130
compileCommand.Flags().BoolVar(&clean, "clean", false, tr("Optional, cleanup the build folder and do not use any cached build."))
130-
// We must use the following syntax for this flag since it's also bound to settings.
131-
// This must be done because the value is set when the binding is accessed from viper. Accessing from cobra would only
132-
// read the value if the flag is set explicitly by the user.
133-
compileCommand.Flags().BoolP("export-binaries", "e", false, tr("If set built binaries will be exported to the sketch folder."))
131+
compileCommand.Flags().BoolVarP(&exportBinaries, "export-binaries", "e", false, tr("If set built binaries will be exported to the sketch folder."))
134132
compileCommand.Flags().StringVar(&sourceOverrides, "source-override", "", tr("Optional. Path to a .json file that contains a set of replacements of the sketch source code."))
135133
compileCommand.Flag("source-override").Hidden = true
136134
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")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /