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

Appearance settings

Commit 642ce2e

Browse filesBrowse files
authored
Added possibility to set custom properties on upload/burn-bootloader/debug commands. (#2693)
* Fixed dry-run in upload with programmer * Fixed doc comment * Added upload properties to gRPC Upload, UploadWithProgrammer, and BurnBootloader * Removed unused var * Added --upload-properties flag to CLI `upload` and `burn-bootloader` commands. * Added custom debug properties to Debug/IsDebugSupported commands (gRPC and CLI)
1 parent 0cae891 commit 642ce2e
Copy full SHA for 642ce2e

File tree

Expand file treeCollapse file tree

14 files changed

+404
-295
lines changed
Filter options
Expand file treeCollapse file tree

14 files changed

+404
-295
lines changed

‎commands/service_debug_config.go

Copy file name to clipboardExpand all lines: commands/service_debug_config.go
+16-7Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020
"encoding/json"
2121
"errors"
22+
"fmt"
2223
"reflect"
2324
"slices"
2425
"strconv"
@@ -55,13 +56,14 @@ func (s *arduinoCoreServerImpl) IsDebugSupported(ctx context.Context, req *rpc.I
5556
}
5657
defer release()
5758
configRequest := &rpc.GetDebugConfigRequest{
58-
Instance: req.GetInstance(),
59-
Fqbn: req.GetFqbn(),
60-
SketchPath: "",
61-
Port: req.GetPort(),
62-
Interpreter: req.GetInterpreter(),
63-
ImportDir: "",
64-
Programmer: req.GetProgrammer(),
59+
Instance: req.GetInstance(),
60+
Fqbn: req.GetFqbn(),
61+
SketchPath: "",
62+
Port: req.GetPort(),
63+
Interpreter: req.GetInterpreter(),
64+
ImportDir: "",
65+
Programmer: req.GetProgrammer(),
66+
DebugProperties: req.GetDebugProperties(),
6567
}
6668
expectedOutput, err := getDebugProperties(configRequest, pme, true)
6769
var x *cmderrors.FailedDebugError
@@ -202,6 +204,13 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl
202204
}
203205
}
204206

207+
// Add user provided custom debug properties
208+
if p, err := properties.LoadFromSlice(req.GetDebugProperties()); err == nil {
209+
debugProperties.Merge(p)
210+
} else {
211+
return nil, fmt.Errorf("invalid build properties: %w", err)
212+
}
213+
205214
if !debugProperties.ContainsKey("executable") || debugProperties.Get("executable") == "" {
206215
return nil, &cmderrors.FailedDebugError{Message: i18n.Tr("Debugging not supported for board %s", req.GetFqbn())}
207216
}

‎commands/service_upload.go

Copy file name to clipboardExpand all lines: commands/service_upload.go
+21-10Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ func (s *arduinoCoreServerImpl) Upload(req *rpc.UploadRequest, stream rpc.Arduin
205205
errStream,
206206
req.GetDryRun(),
207207
req.GetUserFields(),
208+
req.GetUploadProperties(),
208209
)
209210
if err != nil {
210211
return err
@@ -246,16 +247,18 @@ func (s *arduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgra
246247
return &cmderrors.MissingProgrammerError{}
247248
}
248249
return s.Upload(&rpc.UploadRequest{
249-
Instance: req.GetInstance(),
250-
SketchPath: req.GetSketchPath(),
251-
ImportFile: req.GetImportFile(),
252-
ImportDir: req.GetImportDir(),
253-
Fqbn: req.GetFqbn(),
254-
Port: req.GetPort(),
255-
Programmer: req.GetProgrammer(),
256-
Verbose: req.GetVerbose(),
257-
Verify: req.GetVerify(),
258-
UserFields: req.GetUserFields(),
250+
Instance: req.GetInstance(),
251+
SketchPath: req.GetSketchPath(),
252+
ImportFile: req.GetImportFile(),
253+
ImportDir: req.GetImportDir(),
254+
Fqbn: req.GetFqbn(),
255+
Port: req.GetPort(),
256+
Programmer: req.GetProgrammer(),
257+
Verbose: req.GetVerbose(),
258+
Verify: req.GetVerify(),
259+
UserFields: req.GetUserFields(),
260+
DryRun: req.GetDryRun(),
261+
UploadProperties: req.GetUploadProperties(),
259262
}, streamAdapter)
260263
}
261264

@@ -266,6 +269,7 @@ func runProgramAction(ctx context.Context, pme *packagemanager.Explorer,
266269
verbose, verify, burnBootloader bool,
267270
outStream, errStream io.Writer,
268271
dryRun bool, userFields map[string]string,
272+
requestUploadProperties []string,
269273
) (*rpc.Port, error) {
270274
port := rpc.DiscoveryPortFromRPCPort(userPort)
271275
if port == nil || (port.Address == "" && port.Protocol == "") {
@@ -377,6 +381,13 @@ func runProgramAction(ctx context.Context, pme *packagemanager.Explorer,
377381
uploadProperties.Merge(programmer.Properties)
378382
}
379383

384+
// Add user provided custom upload properties
385+
if p, err := properties.LoadFromSlice(requestUploadProperties); err == nil {
386+
uploadProperties.Merge(p)
387+
} else {
388+
return nil, fmt.Errorf("invalid build properties: %w", err)
389+
}
390+
380391
// Certain tools require the user to provide custom fields at run time,
381392
// if they've been provided set them
382393
// For more info:

‎commands/service_upload_burnbootloader.go

Copy file name to clipboardExpand all lines: commands/service_upload_burnbootloader.go
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func (s *arduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, s
8888
errStream,
8989
req.GetDryRun(),
9090
map[string]string{}, // User fields
91+
req.GetUploadProperties(),
9192
); err != nil {
9293
return err
9394
}

‎commands/service_upload_test.go

Copy file name to clipboardExpand all lines: commands/service_upload_test.go
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ func TestUploadPropertiesComposition(t *testing.T) {
202202
errStream,
203203
false,
204204
map[string]string{},
205+
nil,
205206
)
206207
verboseVerifyOutput := "verbose verify"
207208
if !verboseVerify {

‎internal/cli/burnbootloader/burnbootloader.go

Copy file name to clipboardExpand all lines: internal/cli/burnbootloader/burnbootloader.go
+17-14Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ import (
3232
)
3333

3434
var (
35-
fqbn arguments.Fqbn
36-
port arguments.Port
37-
verbose bool
38-
verify bool
39-
programmer arguments.Programmer
40-
dryRun bool
41-
tr = i18n.Tr
35+
fqbn arguments.Fqbn
36+
port arguments.Port
37+
verbose bool
38+
verify bool
39+
programmer arguments.Programmer
40+
dryRun bool
41+
uploadProperties []string
4242
)
4343

4444
// NewCommand created a new `burn-bootloader` command
@@ -57,6 +57,8 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
5757
fqbn.AddToCommand(burnBootloaderCommand, srv)
5858
port.AddToCommand(burnBootloaderCommand, srv)
5959
programmer.AddToCommand(burnBootloaderCommand, srv)
60+
burnBootloaderCommand.Flags().StringArrayVar(&uploadProperties, "upload-property", []string{},
61+
i18n.Tr("Override an upload property with a custom value. Can be used multiple times for multiple properties."))
6062
burnBootloaderCommand.Flags().BoolVarP(&verify, "verify", "t", false, i18n.Tr("Verify uploaded binary after the upload."))
6163
burnBootloaderCommand.Flags().BoolVarP(&verbose, "verbose", "v", false, i18n.Tr("Turns on verbose mode."))
6264
burnBootloaderCommand.Flags().BoolVar(&dryRun, "dry-run", false, i18n.Tr("Do not perform the actual upload, just log out actions"))
@@ -79,13 +81,14 @@ func runBootloaderCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer)
7981
stdOut, stdErr, res := feedback.OutputStreams()
8082
stream := commands.BurnBootloaderToServerStreams(ctx, stdOut, stdErr)
8183
if err := srv.BurnBootloader(&rpc.BurnBootloaderRequest{
82-
Instance: instance,
83-
Fqbn: fqbn.String(),
84-
Port: discoveryPort,
85-
Verbose: verbose,
86-
Verify: verify,
87-
Programmer: programmer.String(ctx, instance, srv, fqbn.String()),
88-
DryRun: dryRun,
84+
Instance: instance,
85+
Fqbn: fqbn.String(),
86+
Port: discoveryPort,
87+
Verbose: verbose,
88+
Verify: verify,
89+
Programmer: programmer.String(ctx, instance, srv, fqbn.String()),
90+
UploadProperties: uploadProperties,
91+
DryRun: dryRun,
8992
}, stream); err != nil {
9093
errcode := feedback.ErrGeneric
9194
if errors.Is(err, &cmderrors.ProgrammerRequiredForUploadError{}) {

‎internal/cli/debug/debug.go

Copy file name to clipboardExpand all lines: internal/cli/debug/debug.go
+21-16Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ import (
3838
// NewCommand created a new `upload` command
3939
func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
4040
var (
41-
fqbnArg arguments.Fqbn
42-
portArgs arguments.Port
43-
profileArg arguments.Profile
44-
interpreter string
45-
importDir string
46-
printInfo bool
47-
programmer arguments.Programmer
41+
fqbnArg arguments.Fqbn
42+
portArgs arguments.Port
43+
profileArg arguments.Profile
44+
interpreter string
45+
importDir string
46+
printInfo bool
47+
programmer arguments.Programmer
48+
debugProperties []string
4849
)
4950

5051
debugCommand := &cobra.Command{
@@ -54,7 +55,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
5455
Example: " " + os.Args[0] + " debug -b arduino:samd:mkr1000 -P atmel_ice /home/user/Arduino/MySketch",
5556
Args: cobra.MaximumNArgs(1),
5657
Run: func(cmd *cobra.Command, args []string) {
57-
runDebugCommand(cmd.Context(), srv, args, &portArgs, &fqbnArg, interpreter, importDir, &programmer, printInfo, &profileArg)
58+
runDebugCommand(cmd.Context(), srv, args, &portArgs, &fqbnArg, interpreter, importDir, &programmer, printInfo, &profileArg, debugProperties)
5859
},
5960
}
6061

@@ -66,12 +67,15 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
6667
debugCommand.Flags().StringVar(&interpreter, "interpreter", "console", i18n.Tr("Debug interpreter e.g.: %s", "console, mi, mi1, mi2, mi3"))
6768
debugCommand.Flags().StringVarP(&importDir, "input-dir", "", "", i18n.Tr("Directory containing binaries for debug."))
6869
debugCommand.Flags().BoolVarP(&printInfo, "info", "I", false, i18n.Tr("Show metadata about the debug session instead of starting the debugger."))
70+
debugCommand.Flags().StringArrayVar(&debugProperties, "debug-property", []string{},
71+
i18n.Tr("Override an debug property with a custom value. Can be used multiple times for multiple properties."))
6972

7073
return debugCommand
7174
}
7275

7376
func runDebugCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args []string, portArgs *arguments.Port, fqbnArg *arguments.Fqbn,
74-
interpreter string, importDir string, programmer *arguments.Programmer, printInfo bool, profileArg *arguments.Profile) {
77+
interpreter string, importDir string, programmer *arguments.Programmer, printInfo bool, profileArg *arguments.Profile,
78+
debugProperties []string) {
7579
logrus.Info("Executing `arduino-cli debug`")
7680

7781
path := ""
@@ -111,13 +115,14 @@ func runDebugCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args
111115
}
112116

113117
debugConfigRequested := &rpc.GetDebugConfigRequest{
114-
Instance: inst,
115-
Fqbn: fqbn,
116-
SketchPath: sketchPath.String(),
117-
Port: port,
118-
Interpreter: interpreter,
119-
ImportDir: importDir,
120-
Programmer: prog,
118+
Instance: inst,
119+
Fqbn: fqbn,
120+
SketchPath: sketchPath.String(),
121+
Port: port,
122+
Interpreter: interpreter,
123+
ImportDir: importDir,
124+
Programmer: prog,
125+
DebugProperties: debugProperties,
121126
}
122127

123128
if printInfo {

‎internal/cli/debug/debug_check.go

Copy file name to clipboardExpand all lines: internal/cli/debug/debug_check.go
+17-11Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,32 @@ import (
3131

3232
func newDebugCheckCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
3333
var (
34-
fqbnArg arguments.Fqbn
35-
portArgs arguments.Port
36-
interpreter string
37-
programmer arguments.Programmer
34+
fqbnArg arguments.Fqbn
35+
portArgs arguments.Port
36+
interpreter string
37+
programmer arguments.Programmer
38+
debugProperties []string
3839
)
3940
debugCheckCommand := &cobra.Command{
4041
Use: "check",
4142
Short: i18n.Tr("Check if the given board/programmer combination supports debugging."),
4243
Example: " " + os.Args[0] + " debug check -b arduino:samd:mkr1000 -P atmel_ice",
4344
Run: func(cmd *cobra.Command, args []string) {
44-
runDebugCheckCommand(cmd.Context(), srv, &portArgs, &fqbnArg, interpreter, &programmer)
45+
runDebugCheckCommand(cmd.Context(), srv, &portArgs, &fqbnArg, interpreter, &programmer, debugProperties)
4546
},
4647
}
4748
fqbnArg.AddToCommand(debugCheckCommand, srv)
4849
portArgs.AddToCommand(debugCheckCommand, srv)
4950
programmer.AddToCommand(debugCheckCommand, srv)
5051
debugCheckCommand.Flags().StringVar(&interpreter, "interpreter", "console", i18n.Tr("Debug interpreter e.g.: %s", "console, mi, mi1, mi2, mi3"))
52+
debugCheckCommand.Flags().StringArrayVar(&debugProperties, "debug-property", []string{},
53+
i18n.Tr("Override an debug property with a custom value. Can be used multiple times for multiple properties."))
5154
return debugCheckCommand
5255
}
5356

54-
func runDebugCheckCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, portArgs *arguments.Port, fqbnArg *arguments.Fqbn, interpreter string, programmerArg *arguments.Programmer) {
57+
func runDebugCheckCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, portArgs *arguments.Port,
58+
fqbnArg *arguments.Fqbn, interpreter string, programmerArg *arguments.Programmer, debugProperties []string,
59+
) {
5560
instance := instance.CreateAndInit(ctx, srv)
5661
logrus.Info("Executing `arduino-cli debug`")
5762

@@ -61,11 +66,12 @@ func runDebugCheckCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer,
6166
}
6267
fqbn := fqbnArg.String()
6368
resp, err := srv.IsDebugSupported(ctx, &rpc.IsDebugSupportedRequest{
64-
Instance: instance,
65-
Fqbn: fqbn,
66-
Port: port,
67-
Interpreter: interpreter,
68-
Programmer: programmerArg.String(ctx, instance, srv, fqbn),
69+
Instance: instance,
70+
Fqbn: fqbn,
71+
Port: port,
72+
Interpreter: interpreter,
73+
Programmer: programmerArg.String(ctx, instance, srv, fqbn),
74+
DebugProperties: debugProperties,
6975
})
7076
if err != nil {
7177
feedback.FatalError(err, feedback.ErrGeneric)

‎internal/cli/upload/upload.go

Copy file name to clipboardExpand all lines: internal/cli/upload/upload.go
+24-21Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ import (
3636
)
3737

3838
var (
39-
fqbnArg arguments.Fqbn
40-
portArgs arguments.Port
41-
profileArg arguments.Profile
42-
verbose bool
43-
verify bool
44-
importDir string
45-
importFile string
46-
programmer arguments.Programmer
47-
dryRun bool
48-
tr = i18n.Tr
39+
fqbnArg arguments.Fqbn
40+
portArgs arguments.Port
41+
profileArg arguments.Profile
42+
verbose bool
43+
verify bool
44+
importDir string
45+
importFile string
46+
programmer arguments.Programmer
47+
dryRun bool
48+
uploadProperties []string
4949
)
5050

5151
// NewCommand created a new `upload` command
@@ -72,6 +72,8 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
7272
profileArg.AddToCommand(uploadCommand, srv)
7373
uploadCommand.Flags().StringVarP(&importDir, "input-dir", "", "", i18n.Tr("Directory containing binaries to upload."))
7474
uploadCommand.Flags().StringVarP(&importFile, "input-file", "i", "", i18n.Tr("Binary file to upload."))
75+
uploadCommand.Flags().StringArrayVar(&uploadProperties, "upload-property", []string{},
76+
i18n.Tr("Override an upload property with a custom value. Can be used multiple times for multiple properties."))
7577
uploadCommand.Flags().BoolVarP(&verify, "verify", "t", false, i18n.Tr("Verify uploaded binary after the upload."))
7678
uploadCommand.Flags().BoolVarP(&verbose, "verbose", "v", false, i18n.Tr("Optional, turns on verbose mode."))
7779
programmer.AddToCommand(uploadCommand, srv)
@@ -185,17 +187,18 @@ func runUploadCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, arg
185187

186188
stdOut, stdErr, stdIOResult := feedback.OutputStreams()
187189
req := &rpc.UploadRequest{
188-
Instance: inst,
189-
Fqbn: fqbn,
190-
SketchPath: path,
191-
Port: port,
192-
Verbose: verbose,
193-
Verify: verify,
194-
ImportFile: importFile,
195-
ImportDir: importDir,
196-
Programmer: prog,
197-
DryRun: dryRun,
198-
UserFields: fields,
190+
Instance: inst,
191+
Fqbn: fqbn,
192+
SketchPath: path,
193+
Port: port,
194+
Verbose: verbose,
195+
Verify: verify,
196+
ImportFile: importFile,
197+
ImportDir: importDir,
198+
Programmer: prog,
199+
DryRun: dryRun,
200+
UserFields: fields,
201+
UploadProperties: uploadProperties,
199202
}
200203
stream, streamResp := commands.UploadToServerStreams(ctx, stdOut, stdErr)
201204
if err := srv.Upload(req, stream); err != nil {

‎rpc/cc/arduino/cli/commands/v1/compile.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/compile.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/compile.proto

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/compile.proto
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ message CompileRequest {
4242
// a directory will be created in the operating system's default temporary
4343
// path.
4444
string build_path = 7;
45-
// List of custom build properties separated by commas.
45+
// List of custom build properties.
4646
repeated string build_properties = 8;
4747
// Used to tell gcc which warning level to use. The level names are: "none",
4848
// "default", "more" and "all".

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.