Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0a5d65c

Browse files
committedAug 21, 2024
Added upload properties to gRPC Upload, UploadWithProgrammer, and BurnBootloader
1 parent 4640c09 commit 0a5d65c

File tree

5 files changed

+199
-145
lines changed

5 files changed

+199
-145
lines changed
 

‎commands/service_upload.go

+21-11
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,17 +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(),
259-
DryRun: req.GetDryRun(),
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(),
260262
}, streamAdapter)
261263
}
262264

@@ -267,6 +269,7 @@ func runProgramAction(ctx context.Context, pme *packagemanager.Explorer,
267269
verbose, verify, burnBootloader bool,
268270
outStream, errStream io.Writer,
269271
dryRun bool, userFields map[string]string,
272+
requestUploadProperties []string,
270273
) (*rpc.Port, error) {
271274
port := rpc.DiscoveryPortFromRPCPort(userPort)
272275
if port == nil || (port.Address == "" && port.Protocol == "") {
@@ -378,6 +381,13 @@ func runProgramAction(ctx context.Context, pme *packagemanager.Explorer,
378381
uploadProperties.Merge(programmer.Properties)
379382
}
380383

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+
381391
// Certain tools require the user to provide custom fields at run time,
382392
// if they've been provided set them
383393
// For more info:

‎commands/service_upload_burnbootloader.go

+1
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

+1
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 {

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

+170-134
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ message UploadRequest {
6060
// For more info:
6161
// https://arduino.github.io/arduino-cli/latest/platform-specification/#user-provided-fields
6262
map<string, string> user_fields = 11;
63+
// List of custom upload properties.
64+
repeated string upload_properties = 12;
6365
}
6466

6567
message UploadResponse {
@@ -116,6 +118,8 @@ message UploadUsingProgrammerRequest {
116118
// For more info:
117119
// https://arduino.github.io/arduino-cli/latest/platform-specification/#user-provided-fields
118120
map<string, string> user_fields = 11;
121+
// List of custom upload properties.
122+
repeated string upload_properties = 12;
119123
}
120124

121125
message UploadUsingProgrammerResponse {
@@ -150,6 +154,8 @@ message BurnBootloaderRequest {
150154
// For more info:
151155
// https://arduino.github.io/arduino-cli/latest/platform-specification/#user-provided-fields
152156
map<string, string> user_fields = 11;
157+
// List of custom upload properties.
158+
repeated string upload_properties = 12;
153159
}
154160

155161
message BurnBootloaderResponse {

0 commit comments

Comments
 (0)
Please sign in to comment.