Skip to content

Commit

Permalink
Install the Arduino_BuiltIn to built-in location
Browse files Browse the repository at this point in the history
Closes arduino#1055.

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
  • Loading branch information
Akos Kitta authored and kittaakos committed Sep 2, 2022
1 parent 0d545be commit 1b7f86b
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 9 deletions.
4 changes: 2 additions & 2 deletions arduino-ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@
"arduino": {
"cli": {
"version": {
"owner": "arduino",
"owner": "cmaglie",
"repo": "arduino-cli",
"commitish": "05d1446"
"commitish": "byebye_bundles"
}
},
"fwuploader": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { LocalStorageService } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';
import { BoardsService, LibraryService } from '../../common/protocol';
import {
BoardsService,
LibraryLocation,
LibraryService,
} from '../../common/protocol';
import { Contribution } from './contribution';

@injectable()
Expand Down Expand Up @@ -57,6 +61,7 @@ export class FirstStartupInstaller extends Contribution {
item: builtInLibrary,
installDependencies: true,
noOverwrite: true, // We don't want to automatically replace custom libraries the user might already have in place
installLocation: LibraryLocation.BUILTIN,
});
} catch (e) {
// There's no error code, I need to parse the error message: https://github.com/arduino/arduino-cli/commit/2ea3608453b17b1157f8a1dc892af2e13e40f4f0#diff-1de7569144d4e260f8dde0e0d00a4e2a218c57966d583da1687a70d518986649R95
Expand Down
3 changes: 2 additions & 1 deletion arduino-ide-extension/src/common/protocol/library-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface LibraryService
version?: Installable.Version;
installDependencies?: boolean;
noOverwrite?: boolean;
installLocation?: LibraryLocation.BUILTIN | LibraryLocation.USER;
}): Promise<void>;
installZip(options: {
zipUri: string;
Expand Down Expand Up @@ -141,7 +142,7 @@ export enum LibraryLocation {
/**
* In the `libraries` subdirectory of the Arduino IDE installation.
*/
IDE_BUILTIN = 0,
BUILTIN = 0,

/**
* In the `libraries` subdirectory of the user directory (sketchbook).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export class LibraryInstallRequest extends jspb.Message {
getNoOverwrite(): boolean;
setNoOverwrite(value: boolean): LibraryInstallRequest;

getInstallLocation(): LibraryInstallLocation;
setInstallLocation(value: LibraryInstallLocation): LibraryInstallRequest;


serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LibraryInstallRequest.AsObject;
Expand All @@ -100,6 +103,7 @@ export namespace LibraryInstallRequest {
version: string,
noDeps: boolean,
noOverwrite: boolean,
installLocation: LibraryInstallLocation,
}
}

Expand Down Expand Up @@ -962,6 +966,11 @@ export namespace GitLibraryInstallResponse {
}
}

export enum LibraryInstallLocation {
LIBRARY_INSTALL_LOCATION_USER = 0,
LIBRARY_INSTALL_LOCATION_BUILTIN = 1,
}

export enum LibrarySearchStatus {
LIBRARY_SEARCH_STATUS_FAILED = 0,
LIBRARY_SEARCH_STATUS_SUCCESS = 1,
Expand All @@ -973,7 +982,7 @@ export enum LibraryLayout {
}

export enum LibraryLocation {
LIBRARY_LOCATION_IDE_BUILTIN = 0,
LIBRARY_LOCATION_BUILTIN = 0,
LIBRARY_LOCATION_USER = 1,
LIBRARY_LOCATION_PLATFORM_BUILTIN = 2,
LIBRARY_LOCATION_REFERENCED_PLATFORM_BUILTIN = 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LibraryDependency', null, gl
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LibraryDependencyStatus', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LibraryDownloadRequest', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LibraryDownloadResponse', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LibraryInstallLocation', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LibraryInstallRequest', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LibraryInstallResponse', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.LibraryLayout', null, global);
Expand Down Expand Up @@ -1012,7 +1013,8 @@ proto.cc.arduino.cli.commands.v1.LibraryInstallRequest.toObject = function(inclu
name: jspb.Message.getFieldWithDefault(msg, 2, ""),
version: jspb.Message.getFieldWithDefault(msg, 3, ""),
noDeps: jspb.Message.getBooleanFieldWithDefault(msg, 4, false),
noOverwrite: jspb.Message.getBooleanFieldWithDefault(msg, 5, false)
noOverwrite: jspb.Message.getBooleanFieldWithDefault(msg, 5, false),
installLocation: jspb.Message.getFieldWithDefault(msg, 6, 0)
};

if (includeInstance) {
Expand Down Expand Up @@ -1070,6 +1072,10 @@ proto.cc.arduino.cli.commands.v1.LibraryInstallRequest.deserializeBinaryFromRead
var value = /** @type {boolean} */ (reader.readBool());
msg.setNoOverwrite(value);
break;
case 6:
var value = /** @type {!proto.cc.arduino.cli.commands.v1.LibraryInstallLocation} */ (reader.readEnum());
msg.setInstallLocation(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -1135,6 +1141,13 @@ proto.cc.arduino.cli.commands.v1.LibraryInstallRequest.serializeBinaryToWriter =
f
);
}
f = message.getInstallLocation();
if (f !== 0.0) {
writer.writeEnum(
6,
f
);
}
};


Expand Down Expand Up @@ -1247,6 +1260,24 @@ proto.cc.arduino.cli.commands.v1.LibraryInstallRequest.prototype.setNoOverwrite
};


/**
* optional LibraryInstallLocation install_location = 6;
* @return {!proto.cc.arduino.cli.commands.v1.LibraryInstallLocation}
*/
proto.cc.arduino.cli.commands.v1.LibraryInstallRequest.prototype.getInstallLocation = function() {
return /** @type {!proto.cc.arduino.cli.commands.v1.LibraryInstallLocation} */ (jspb.Message.getFieldWithDefault(this, 6, 0));
};


/**
* @param {!proto.cc.arduino.cli.commands.v1.LibraryInstallLocation} value
* @return {!proto.cc.arduino.cli.commands.v1.LibraryInstallRequest} returns this
*/
proto.cc.arduino.cli.commands.v1.LibraryInstallRequest.prototype.setInstallLocation = function(value) {
return jspb.Message.setProto3EnumField(this, 6, value);
};





Expand Down Expand Up @@ -7057,6 +7088,14 @@ proto.cc.arduino.cli.commands.v1.GitLibraryInstallResponse.prototype.hasTaskProg
};


/**
* @enum {number}
*/
proto.cc.arduino.cli.commands.v1.LibraryInstallLocation = {
LIBRARY_INSTALL_LOCATION_USER: 0,
LIBRARY_INSTALL_LOCATION_BUILTIN: 1
};

/**
* @enum {number}
*/
Expand All @@ -7077,7 +7116,7 @@ proto.cc.arduino.cli.commands.v1.LibraryLayout = {
* @enum {number}
*/
proto.cc.arduino.cli.commands.v1.LibraryLocation = {
LIBRARY_LOCATION_IDE_BUILTIN: 0,
LIBRARY_LOCATION_BUILTIN: 0,
LIBRARY_LOCATION_USER: 1,
LIBRARY_LOCATION_PLATFORM_BUILTIN: 2,
LIBRARY_LOCATION_REFERENCED_PLATFORM_BUILTIN: 3,
Expand Down
15 changes: 13 additions & 2 deletions arduino-ide-extension/src/node/library-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ZipLibraryInstallRequest,
LibrarySearchRequest,
LibrarySearchResponse,
LibraryInstallLocation,
} from './cli-protocol/cc/arduino/cli/commands/v1/lib_pb';
import { Installable } from '../common/protocol/installable';
import { ILogger, notEmpty } from '@theia/core';
Expand Down Expand Up @@ -231,8 +232,8 @@ export class LibraryServiceImpl

private mapLocation(location: GrpcLibraryLocation): LibraryLocation {
switch (location) {
case GrpcLibraryLocation.LIBRARY_LOCATION_IDE_BUILTIN:
return LibraryLocation.IDE_BUILTIN;
case GrpcLibraryLocation.LIBRARY_LOCATION_BUILTIN:
return LibraryLocation.BUILTIN;
case GrpcLibraryLocation.LIBRARY_LOCATION_USER:
return LibraryLocation.USER;
case GrpcLibraryLocation.LIBRARY_LOCATION_PLATFORM_BUILTIN:
Expand Down Expand Up @@ -290,6 +291,7 @@ export class LibraryServiceImpl
version?: Installable.Version;
installDependencies?: boolean;
noOverwrite?: boolean;
installLocation?: LibraryLocation.BUILTIN | LibraryLocation.USER;
}): Promise<void> {
const item = options.item;
const version = !!options.version
Expand All @@ -304,6 +306,15 @@ export class LibraryServiceImpl
req.setVersion(version);
req.setNoDeps(!options.installDependencies);
req.setNoOverwrite(Boolean(options.noOverwrite));
if (options.installLocation === LibraryLocation.BUILTIN) {
req.setInstallLocation(
LibraryInstallLocation.LIBRARY_INSTALL_LOCATION_BUILTIN
);
} else if (options.installLocation === LibraryLocation.USER) {
req.setInstallLocation(
LibraryInstallLocation.LIBRARY_INSTALL_LOCATION_USER
);
}

console.info('>>> Starting library package installation...', item);

Expand Down

0 comments on commit 1b7f86b

Please sign in to comment.