Skip to content

Various fixes from arduino/arduino-pro-ide/issues #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Arduino IDE

[![Arduino IDE](https://github.com/bcmi-labs/arduino-editor/workflows/Arduino%20Pro%20IDE/badge.svg)](https://github.com/bcmi-labs/arduino-editor/actions?query=workflow%3A%22Arduino+Pro+IDE%22)
[![Arduino IDE](https://github.com/arduino/arduino-ide/workflows/Arduino%20IDE/badge.svg)](https://github.com/arduino/arduino-ide/actions?query=workflow%3A%22Arduino+IDE%22)

### Download

Expand Down
2 changes: 1 addition & 1 deletion arduino-ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
],
"arduino": {
"cli": {
"version": "0.15.2"
"version": "20210212"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
protected async openSketchFiles(uri: URI): Promise<void> {
try {
const sketch = await this.sketchService.loadSketch(uri.toString());
const { mainFileUri, otherSketchFileUris, additionalFileUris } = sketch;
for (const uri of [mainFileUri, ...otherSketchFileUris, ...additionalFileUris]) {
const { mainFileUri, rootFolderFileUris } = sketch;
for (const uri of [mainFileUri, ...rootFolderFileUris]) {
await this.ensureOpened(uri);
}
await this.ensureOpened(mainFileUri, true);
Expand Down
8 changes: 4 additions & 4 deletions arduino-ide-extension/src/browser/arduino-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export const ArduinoConfigSchema: PreferenceSchema = {
},
'arduino.compile.verbose': {
'type': 'boolean',
'description': 'True for verbose compile output.',
'default': true
'description': 'True for verbose compile output. False by default',
'default': false
},
'arduino.upload.verbose': {
'type': 'boolean',
'description': 'True for verbose upload output.',
'default': true
'description': 'True for verbose upload output. False by default.',
'default': false
},
'arduino.upload.verify': {
'type': 'boolean',
Expand Down
13 changes: 6 additions & 7 deletions arduino-ide-extension/src/browser/contributions/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@ export class About extends Contribution {
}

async showAbout(): Promise<void> {
const ideStatus = FrontendApplicationConfigProvider.get()['status'];
const { version, commit, status: cliStatus } = await this.configService.getVersion();
const buildDate = this.buildDate;
const detail = (useAgo: boolean) => `Version: ${remote.app.getVersion()}
Date: ${buildDate ? buildDate : 'dev build'}${buildDate && useAgo ? ` (${this.ago(buildDate)})` : ''}
const detail = (showAll: boolean) => `Version: ${remote.app.getVersion()}
Date: ${buildDate ? buildDate : 'dev build'}${buildDate && showAll ? ` (${this.ago(buildDate)})` : ''}
CLI Version: ${version}${cliStatus ? ` ${cliStatus}` : ''} [${commit}]

Copyright © ${new Date().getFullYear()} Arduino SA
${showAll ? `Copyright © ${new Date().getFullYear()} Arduino SA` : ''}
`;
const ok = 'OK';
const copy = 'Copy';
const buttons = !isWindows && !isOSX ? [copy, ok] : [ok, copy];
const { response } = await remote.dialog.showMessageBox(remote.getCurrentWindow(), {
message: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
title: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
message: `${this.applicationName}`,
title: `${this.applicationName}`,
type: 'info',
detail: detail(true),
buttons,
Expand All @@ -56,7 +55,7 @@ Copyright © ${new Date().getFullYear()} Arduino SA
});

if (buttons[response] === copy) {
await this.clipboardService.writeText(detail(false));
await this.clipboardService.writeText(detail(false).trim());
}
}

Expand Down
19 changes: 19 additions & 0 deletions arduino-ide-extension/src/browser/contributions/contribution.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { inject, injectable, interfaces } from 'inversify';
import URI from '@theia/core/lib/common/uri';
import { ILogger } from '@theia/core/lib/common/logger';
import { Saveable } from '@theia/core/lib/browser/saveable';
import { FileService } from '@theia/filesystem/lib/browser/file-service';
import { MaybePromise } from '@theia/core/lib/common/types';
import { LabelProvider } from '@theia/core/lib/browser/label-provider';
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
import { MessageService } from '@theia/core/lib/common/message-service';
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import { open, OpenerService } from '@theia/core/lib/browser/opener-service';
Expand Down Expand Up @@ -85,6 +87,23 @@ export abstract class SketchContribution extends Contribution {
@inject(ArduinoPreferences)
protected readonly preferences: ArduinoPreferences;

@inject(EditorManager)
protected readonly editorManager: EditorManager;

protected async sourceOverride(): Promise<Record<string, string>> {
const override: Record<string, string> = {};
const sketch = await this.sketchServiceClient.currentSketch();
if (sketch) {
for (const editor of this.editorManager.all) {
const uri = editor.editor.uri;
if (Saveable.isDirty(editor) && Sketch.isInSketch(uri, sketch)) {
override[uri.toString()] = editor.editor.document.getText();
}
}
}
return override;
}

}

export namespace Contribution {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class SketchControl extends SketchContribution {
return;
}

const { mainFileUri, otherSketchFileUris, additionalFileUris } = await this.sketchService.loadSketch(sketch.uri);
const uris = [mainFileUri, ...otherSketchFileUris, ...additionalFileUris];
const { mainFileUri, rootFolderFileUris } = await this.sketchService.loadSketch(sketch.uri);
const uris = [mainFileUri, ...rootFolderFileUris];
for (let i = 0; i < uris.length; i++) {
const uri = new URI(uris[i]);
const command = { id: `arduino-focus-file--${uri.toString()}` };
Expand Down
17 changes: 10 additions & 7 deletions arduino-ide-extension/src/browser/contributions/upload-sketch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class UploadSketch extends SketchContribution {
}

async uploadSketch(usingProgrammer: boolean = false): Promise<void> {
const uri = await this.sketchServiceClient.currentSketchFile();
if (!uri) {
const sketch = await this.sketchServiceClient.currentSketch();
if (!sketch) {
return;
}
let shouldAutoConnect = false;
Expand All @@ -88,15 +88,16 @@ export class UploadSketch extends SketchContribution {
}
try {
const { boardsConfig } = this.boardsServiceClientImpl;
const [fqbn, { selectedProgrammer }, verify, verbose] = await Promise.all([
const [fqbn, { selectedProgrammer }, verify, verbose, sourceOverride] = await Promise.all([
this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard?.fqbn),
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
this.preferences.get('arduino.upload.verify'),
this.preferences.get('arduino.upload.verbose')
this.preferences.get('arduino.upload.verbose'),
this.sourceOverride()
]);

let options: CoreService.Upload.Options | undefined = undefined;
const sketchUri = uri;
const sketchUri = sketch.uri;
const optimizeForDebug = this.editorMode.compileForDebug;
const { selectedPort } = boardsConfig;
const port = selectedPort?.address;
Expand All @@ -110,7 +111,8 @@ export class UploadSketch extends SketchContribution {
programmer,
port,
verbose,
verify
verify,
sourceOverride
};
} else {
options = {
Expand All @@ -119,7 +121,8 @@ export class UploadSketch extends SketchContribution {
optimizeForDebug,
port,
verbose,
verify
verify,
sourceOverride
};
}
this.outputChannelManager.getChannel('Arduino').clear();
Expand Down
16 changes: 10 additions & 6 deletions arduino-ide-extension/src/browser/contributions/verify-sketch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,26 @@ export class VerifySketch extends SketchContribution {
});
}

async verifySketch(exportBinaries: boolean = false): Promise<void> {
const uri = await this.sketchServiceClient.currentSketchFile();
if (!uri) {
async verifySketch(exportBinaries?: boolean): Promise<void> {
const sketch = await this.sketchServiceClient.currentSketch();
if (!sketch) {
return;
}
try {
const { boardsConfig } = this.boardsServiceClientImpl;
const fqbn = await this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard?.fqbn);
const [fqbn, sourceOverride] = await Promise.all([
this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard?.fqbn),
this.sourceOverride()
]);
const verbose = this.preferences.get('arduino.compile.verbose');
this.outputChannelManager.getChannel('Arduino').clear();
await this.coreService.compile({
sketchUri: uri,
sketchUri: sketch.uri,
fqbn,
optimizeForDebug: this.editorMode.compileForDebug,
verbose,
exportBinaries
exportBinaries,
sourceOverride
});
this.messageService.info('Done compiling.', { timeout: 1000 });
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
import { FocusTracker, Widget } from '@theia/core/lib/browser';
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
import { ConfigService } from '../../../common/protocol/config-service';
import { SketchesService, Sketch } from '../../../common/protocol/sketches-service';
import { ArduinoWorkspaceRootResolver } from '../../arduino-workspace-resolver';
Expand Down Expand Up @@ -98,9 +97,8 @@ export class WorkspaceService extends TheiaWorkspaceService {
}

protected formatTitle(title?: string): string {
const status = FrontendApplicationConfigProvider.get()['status'];
const version = this.version ? ` ${this.version}` : '';
const name = `${this.applicationName}${status ? ` – ${status}` : ''} ${version}`;
const name = `${this.applicationName} ${version}`;
return title ? `${title} | ${name}` : name;
}

Expand Down
4 changes: 2 additions & 2 deletions arduino-ide-extension/src/browser/widgets/arduino-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { ThemeConfig } from 'react-select/src/theme';

export class ArduinoSelect<T> extends Select<T> {

constructor(props: Readonly<Props<T>>) {
constructor(props: Readonly<Props<T, false>>) {
super(props);
}

render(): React.ReactNode {
const controlHeight = 27; // from `monitor.css` -> `.serial-monitor-container .head` (`height: 27px;`)
const styles: Styles = {
const styles: Styles<T, false> = {
control: styles => ({
...styles,
minWidth: 120,
Expand Down
6 changes: 5 additions & 1 deletion arduino-ide-extension/src/common/protocol/core-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Programmer } from './boards-service';
export const CoreServicePath = '/services/core-service';
export const CoreService = Symbol('CoreService');
export interface CoreService {
compile(options: CoreService.Compile.Options & Readonly<{ exportBinaries: boolean }>): Promise<void>;
compile(options: CoreService.Compile.Options & Readonly<{ exportBinaries?: boolean }>): Promise<void>;
upload(options: CoreService.Upload.Options): Promise<void>;
uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void>;
burnBootloader(options: CoreService.Bootloader.Options): Promise<void>;
Expand All @@ -13,10 +13,14 @@ export namespace CoreService {

export namespace Compile {
export interface Options {
/**
* `file` URI to the sketch folder.
*/
readonly sketchUri: string;
readonly fqbn?: string | undefined;
readonly optimizeForDebug: boolean;
readonly verbose: boolean;
readonly sourceOverride: Record<string, string>;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface Sketch {
readonly mainFileUri: string; // `MainFile`
readonly otherSketchFileUris: string[]; // `OtherSketchFiles`
readonly additionalFileUris: string[]; // `AdditionalFiles`
readonly rootFolderFileUris: string[]; // `RootFolderFiles` (does not include the main sketch file)
}
export namespace Sketch {
export function is(arg: any): arg is Sketch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ libraryInstall: {
responseSerialize: serialize_cc_arduino_cli_commands_LibraryInstallResp,
responseDeserialize: deserialize_cc_arduino_cli_commands_LibraryInstallResp,
},
// Install a library from a Zip File
// Install a library from a Zip File
zipLibraryInstall: {
path: '/cc.arduino.cli.commands.ArduinoCore/ZipLibraryInstall',
requestStream: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ export class LoadSketchResp extends jspb.Message {
setAdditionalFilesList(value: Array<string>): LoadSketchResp;
addAdditionalFiles(value: string, index?: number): string;

clearRootFolderFilesList(): void;
getRootFolderFilesList(): Array<string>;
setRootFolderFilesList(value: Array<string>): LoadSketchResp;
addRootFolderFiles(value: string, index?: number): string;


serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LoadSketchResp.AsObject;
Expand All @@ -529,6 +534,7 @@ export namespace LoadSketchResp {
locationPath: string,
otherSketchFilesList: Array<string>,
additionalFilesList: Array<string>,
rootFolderFilesList: Array<string>,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3639,7 +3639,7 @@ proto.cc.arduino.cli.commands.LoadSketchReq.prototype.setSketchPath = function(v
* @private {!Array<number>}
* @const
*/
proto.cc.arduino.cli.commands.LoadSketchResp.repeatedFields_ = [3,4];
proto.cc.arduino.cli.commands.LoadSketchResp.repeatedFields_ = [3,4,5];



Expand Down Expand Up @@ -3675,7 +3675,8 @@ proto.cc.arduino.cli.commands.LoadSketchResp.toObject = function(includeInstance
mainFile: jspb.Message.getFieldWithDefault(msg, 1, ""),
locationPath: jspb.Message.getFieldWithDefault(msg, 2, ""),
otherSketchFilesList: (f = jspb.Message.getRepeatedField(msg, 3)) == null ? undefined : f,
additionalFilesList: (f = jspb.Message.getRepeatedField(msg, 4)) == null ? undefined : f
additionalFilesList: (f = jspb.Message.getRepeatedField(msg, 4)) == null ? undefined : f,
rootFolderFilesList: (f = jspb.Message.getRepeatedField(msg, 5)) == null ? undefined : f
};

if (includeInstance) {
Expand Down Expand Up @@ -3728,6 +3729,10 @@ proto.cc.arduino.cli.commands.LoadSketchResp.deserializeBinaryFromReader = funct
var value = /** @type {string} */ (reader.readString());
msg.addAdditionalFiles(value);
break;
case 5:
var value = /** @type {string} */ (reader.readString());
msg.addRootFolderFiles(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -3785,6 +3790,13 @@ proto.cc.arduino.cli.commands.LoadSketchResp.serializeBinaryToWriter = function(
f
);
}
f = message.getRootFolderFilesList();
if (f.length > 0) {
writer.writeRepeatedString(
5,
f
);
}
};


Expand Down Expand Up @@ -3898,6 +3910,43 @@ proto.cc.arduino.cli.commands.LoadSketchResp.prototype.clearAdditionalFilesList
};


/**
* repeated string root_folder_files = 5;
* @return {!Array<string>}
*/
proto.cc.arduino.cli.commands.LoadSketchResp.prototype.getRootFolderFilesList = function() {
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 5));
};


/**
* @param {!Array<string>} value
* @return {!proto.cc.arduino.cli.commands.LoadSketchResp} returns this
*/
proto.cc.arduino.cli.commands.LoadSketchResp.prototype.setRootFolderFilesList = function(value) {
return jspb.Message.setField(this, 5, value || []);
};


/**
* @param {string} value
* @param {number=} opt_index
* @return {!proto.cc.arduino.cli.commands.LoadSketchResp} returns this
*/
proto.cc.arduino.cli.commands.LoadSketchResp.prototype.addRootFolderFiles = function(value, opt_index) {
return jspb.Message.addToRepeatedField(this, 5, value, opt_index);
};


/**
* Clears the list making it empty but non-null.
* @return {!proto.cc.arduino.cli.commands.LoadSketchResp} returns this
*/
proto.cc.arduino.cli.commands.LoadSketchResp.prototype.clearRootFolderFilesList = function() {
return this.setRootFolderFilesList([]);
};





Expand Down
Loading