Skip to content

Commit 719bb5d

Browse files
author
Akos Kitta
committed
chore(cli): update CLI to 0.35.0-rc.1
- Adjust board discovery to new gRPC API. From now on, it's a client read stream, not a duplex. - Allow `.cxx` and `.cc` file extensions. (Closes #2265) Signed-off-by: Akos Kitta <[email protected]>
1 parent b1609a1 commit 719bb5d

21 files changed

+1999
-2548
lines changed

arduino-ide-extension/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
],
170170
"arduino": {
171171
"arduino-cli": {
172-
"version": "0.34.0"
172+
"version": "0.35.0-rc.1"
173173
},
174174
"arduino-fwuploader": {
175175
"version": "2.4.1"

arduino-ide-extension/src/common/protocol/sketches-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export namespace Sketch {
308308
export namespace Extensions {
309309
export const DEFAULT = '.ino';
310310
export const MAIN = [DEFAULT, '.pde'];
311-
export const SOURCE = ['.c', '.cpp', '.S'];
311+
export const SOURCE = ['.c', '.cpp', '.S', '.cxx', '.cc'];
312312
export const CODE_FILES = [
313313
...MAIN,
314314
...SOURCE,

arduino-ide-extension/src/node/board-discovery.ts

+10-32
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ClientDuplexStream } from '@grpc/grpc-js';
1+
import type { ClientReadableStream } from '@grpc/grpc-js';
22
import {
33
Disposable,
44
DisposableCollection,
@@ -30,9 +30,9 @@ import type { Port as RpcPort } from './cli-protocol/cc/arduino/cli/commands/v1/
3030
import { CoreClientAware } from './core-client-provider';
3131
import { ServiceError } from './service-error';
3232

33-
type Duplex = ClientDuplexStream<BoardListWatchRequest, BoardListWatchResponse>;
33+
type Stream = ClientReadableStream<BoardListWatchResponse>;
3434
interface StreamWrapper extends Disposable {
35-
readonly stream: Duplex;
35+
readonly stream: Stream;
3636
readonly uuid: string; // For logging only
3737
}
3838

@@ -121,34 +121,15 @@ export class BoardDiscovery
121121
return Disposable.create(() => clearTimeout(timer));
122122
}
123123

124-
private async requestStartWatch(
125-
req: BoardListWatchRequest,
126-
duplex: Duplex
127-
): Promise<void> {
128-
return new Promise<void>((resolve, reject) => {
129-
if (
130-
!duplex.write(req, (err: Error | undefined) => {
131-
if (err) {
132-
reject(err);
133-
return;
134-
}
135-
})
136-
) {
137-
duplex.once('drain', resolve);
138-
} else {
139-
process.nextTick(resolve);
140-
}
141-
});
142-
}
143-
144124
private async createWrapper(
145-
client: ArduinoCoreServiceClient
125+
client: ArduinoCoreServiceClient,
126+
req: BoardListWatchRequest
146127
): Promise<StreamWrapper> {
147128
if (this.wrapper) {
148129
throw new Error(`Duplex was already set.`);
149130
}
150131
const stream = client
151-
.boardListWatch()
132+
.boardListWatch(req)
152133
.on('end', () => {
153134
this.logger.info('received end');
154135
this.onStreamDidEndEmitter.fire();
@@ -202,14 +183,11 @@ export class BoardDiscovery
202183
this.watching = new Deferred();
203184
this.logger.info('start new deferred');
204185
const { client, instance } = await this.coreClient;
205-
const wrapper = await this.createWrapper(client);
206-
wrapper.stream.on('data', (resp) => this.onBoardListWatchResponse(resp));
207-
this.logger.info('start request start watch');
208-
await this.requestStartWatch(
209-
new BoardListWatchRequest().setInstance(instance),
210-
wrapper.stream
186+
const wrapper = await this.createWrapper(
187+
client,
188+
new BoardListWatchRequest().setInstance(instance)
211189
);
212-
this.logger.info('start requested start watch');
190+
wrapper.stream.on('data', (resp) => this.onBoardListWatchResponse(resp));
213191
this.watching.resolve();
214192
this.logger.info('start resolved watching');
215193
}

arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/board_pb.d.ts

-3
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,6 @@ export class BoardListWatchRequest extends jspb.Message {
488488
clearInstance(): void;
489489
getInstance(): cc_arduino_cli_commands_v1_common_pb.Instance | undefined;
490490
setInstance(value?: cc_arduino_cli_commands_v1_common_pb.Instance): BoardListWatchRequest;
491-
getInterrupt(): boolean;
492-
setInterrupt(value: boolean): BoardListWatchRequest;
493491

494492
serializeBinary(): Uint8Array;
495493
toObject(includeInstance?: boolean): BoardListWatchRequest.AsObject;
@@ -504,7 +502,6 @@ export class BoardListWatchRequest extends jspb.Message {
504502
export namespace BoardListWatchRequest {
505503
export type AsObject = {
506504
instance?: cc_arduino_cli_commands_v1_common_pb.Instance.AsObject,
507-
interrupt: boolean,
508505
}
509506
}
510507

arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/board_pb.js

+1-31
Original file line numberDiff line numberDiff line change
@@ -4181,8 +4181,7 @@ proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.prototype.toObject = func
41814181
*/
41824182
proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.toObject = function(includeInstance, msg) {
41834183
var f, obj = {
4184-
instance: (f = msg.getInstance()) && cc_arduino_cli_commands_v1_common_pb.Instance.toObject(includeInstance, f),
4185-
interrupt: jspb.Message.getBooleanFieldWithDefault(msg, 2, false)
4184+
instance: (f = msg.getInstance()) && cc_arduino_cli_commands_v1_common_pb.Instance.toObject(includeInstance, f)
41864185
};
41874186

41884187
if (includeInstance) {
@@ -4224,10 +4223,6 @@ proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.deserializeBinaryFromRead
42244223
reader.readMessage(value,cc_arduino_cli_commands_v1_common_pb.Instance.deserializeBinaryFromReader);
42254224
msg.setInstance(value);
42264225
break;
4227-
case 2:
4228-
var value = /** @type {boolean} */ (reader.readBool());
4229-
msg.setInterrupt(value);
4230-
break;
42314226
default:
42324227
reader.skipField();
42334228
break;
@@ -4265,13 +4260,6 @@ proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.serializeBinaryToWriter =
42654260
cc_arduino_cli_commands_v1_common_pb.Instance.serializeBinaryToWriter
42664261
);
42674262
}
4268-
f = message.getInterrupt();
4269-
if (f) {
4270-
writer.writeBool(
4271-
2,
4272-
f
4273-
);
4274-
}
42754263
};
42764264

42774265

@@ -4312,24 +4300,6 @@ proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.prototype.hasInstance = f
43124300
};
43134301

43144302

4315-
/**
4316-
* optional bool interrupt = 2;
4317-
* @return {boolean}
4318-
*/
4319-
proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.prototype.getInterrupt = function() {
4320-
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false));
4321-
};
4322-
4323-
4324-
/**
4325-
* @param {boolean} value
4326-
* @return {!proto.cc.arduino.cli.commands.v1.BoardListWatchRequest} returns this
4327-
*/
4328-
proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.prototype.setInterrupt = function(value) {
4329-
return jspb.Message.setProto3BooleanField(this, 2, value);
4330-
};
4331-
4332-
43334303

43344304

43354305

0 commit comments

Comments
 (0)