Skip to content

Commit

Permalink
chore(cli): update CLI to 0.35.0-rc.2
Browse files Browse the repository at this point in the history
 - 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]>
  • Loading branch information
Akos Kitta committed Nov 13, 2023
1 parent 4b7721c commit d9c682d
Show file tree
Hide file tree
Showing 21 changed files with 2,037 additions and 2,548 deletions.
2 changes: 1 addition & 1 deletion arduino-ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
],
"arduino": {
"arduino-cli": {
"version": "0.34.0"
"version": "0.35.0-rc.2"
},
"arduino-fwuploader": {
"version": "2.4.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export namespace Sketch {
export namespace Extensions {
export const DEFAULT = '.ino';
export const MAIN = [DEFAULT, '.pde'];
export const SOURCE = ['.c', '.cpp', '.S'];
export const SOURCE = ['.c', '.cpp', '.S', '.cxx', '.cc'];
export const CODE_FILES = [
...MAIN,
...SOURCE,
Expand Down
42 changes: 10 additions & 32 deletions arduino-ide-extension/src/node/board-discovery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ClientDuplexStream } from '@grpc/grpc-js';
import type { ClientReadableStream } from '@grpc/grpc-js';
import {
Disposable,
DisposableCollection,
Expand Down Expand Up @@ -30,9 +30,9 @@ import type { Port as RpcPort } from './cli-protocol/cc/arduino/cli/commands/v1/
import { CoreClientAware } from './core-client-provider';
import { ServiceError } from './service-error';

type Duplex = ClientDuplexStream<BoardListWatchRequest, BoardListWatchResponse>;
type Stream = ClientReadableStream<BoardListWatchResponse>;
interface StreamWrapper extends Disposable {
readonly stream: Duplex;
readonly stream: Stream;
readonly uuid: string; // For logging only
}

Expand Down Expand Up @@ -121,34 +121,15 @@ export class BoardDiscovery
return Disposable.create(() => clearTimeout(timer));
}

private async requestStartWatch(
req: BoardListWatchRequest,
duplex: Duplex
): Promise<void> {
return new Promise<void>((resolve, reject) => {
if (
!duplex.write(req, (err: Error | undefined) => {
if (err) {
reject(err);
return;
}
})
) {
duplex.once('drain', resolve);
} else {
process.nextTick(resolve);
}
});
}

private async createWrapper(
client: ArduinoCoreServiceClient
client: ArduinoCoreServiceClient,
req: BoardListWatchRequest
): Promise<StreamWrapper> {
if (this.wrapper) {
throw new Error(`Duplex was already set.`);
}
const stream = client
.boardListWatch()
.boardListWatch(req)
.on('end', () => {
this.logger.info('received end');
this.onStreamDidEndEmitter.fire();
Expand Down Expand Up @@ -202,14 +183,11 @@ export class BoardDiscovery
this.watching = new Deferred();
this.logger.info('start new deferred');
const { client, instance } = await this.coreClient;
const wrapper = await this.createWrapper(client);
wrapper.stream.on('data', (resp) => this.onBoardListWatchResponse(resp));
this.logger.info('start request start watch');
await this.requestStartWatch(
new BoardListWatchRequest().setInstance(instance),
wrapper.stream
const wrapper = await this.createWrapper(
client,
new BoardListWatchRequest().setInstance(instance)
);
this.logger.info('start requested start watch');
wrapper.stream.on('data', (resp) => this.onBoardListWatchResponse(resp));
this.watching.resolve();
this.logger.info('start resolved watching');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,6 @@ export class BoardListWatchRequest extends jspb.Message {
clearInstance(): void;
getInstance(): cc_arduino_cli_commands_v1_common_pb.Instance | undefined;
setInstance(value?: cc_arduino_cli_commands_v1_common_pb.Instance): BoardListWatchRequest;
getInterrupt(): boolean;
setInterrupt(value: boolean): BoardListWatchRequest;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): BoardListWatchRequest.AsObject;
Expand All @@ -504,7 +502,6 @@ export class BoardListWatchRequest extends jspb.Message {
export namespace BoardListWatchRequest {
export type AsObject = {
instance?: cc_arduino_cli_commands_v1_common_pb.Instance.AsObject,
interrupt: boolean,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4181,8 +4181,7 @@ proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.prototype.toObject = func
*/
proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.toObject = function(includeInstance, msg) {
var f, obj = {
instance: (f = msg.getInstance()) && cc_arduino_cli_commands_v1_common_pb.Instance.toObject(includeInstance, f),
interrupt: jspb.Message.getBooleanFieldWithDefault(msg, 2, false)
instance: (f = msg.getInstance()) && cc_arduino_cli_commands_v1_common_pb.Instance.toObject(includeInstance, f)
};

if (includeInstance) {
Expand Down Expand Up @@ -4224,10 +4223,6 @@ proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.deserializeBinaryFromRead
reader.readMessage(value,cc_arduino_cli_commands_v1_common_pb.Instance.deserializeBinaryFromReader);
msg.setInstance(value);
break;
case 2:
var value = /** @type {boolean} */ (reader.readBool());
msg.setInterrupt(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -4265,13 +4260,6 @@ proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.serializeBinaryToWriter =
cc_arduino_cli_commands_v1_common_pb.Instance.serializeBinaryToWriter
);
}
f = message.getInterrupt();
if (f) {
writer.writeBool(
2,
f
);
}
};


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


/**
* optional bool interrupt = 2;
* @return {boolean}
*/
proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.prototype.getInterrupt = function() {
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false));
};


/**
* @param {boolean} value
* @return {!proto.cc.arduino.cli.commands.v1.BoardListWatchRequest} returns this
*/
proto.cc.arduino.cli.commands.v1.BoardListWatchRequest.prototype.setInterrupt = function(value) {
return jspb.Message.setProto3BooleanField(this, 2, value);
};





Expand Down
Loading

0 comments on commit d9c682d

Please sign in to comment.