ATL-74: Added Export compiled Binary.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2021-02-01 16:40:18 +01:00 committed by Akos Kitta
parent b65867d2f4
commit e957ac4331
7 changed files with 31 additions and 15 deletions

View File

@ -320,10 +320,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
} }
registry.registerSubmenu(ArduinoMenus.SKETCH, 'Sketch'); registry.registerSubmenu(ArduinoMenus.SKETCH, 'Sketch');
registry.registerSubmenu(ArduinoMenus.TOOLS, 'Tools'); registry.registerSubmenu(ArduinoMenus.TOOLS, 'Tools');
registry.registerMenuAction(ArduinoMenus.SKETCH, { registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
commandId: ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG.id, commandId: ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG.id,
label: 'Optimize for Debugging', label: 'Optimize for Debugging',
order: '1' order: '4'
}); });
registry.registerMenuAction(ArduinoMenus.HELP__CONTROL_GROUP, { registry.registerMenuAction(ArduinoMenus.HELP__CONTROL_GROUP, {
commandId: ArduinoCommands.TOGGLE_ADVANCED_MODE.id, commandId: ArduinoCommands.TOGGLE_ADVANCED_MODE.id,

View File

@ -43,12 +43,12 @@ export class UploadSketch extends SketchContribution {
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
commandId: UploadSketch.Commands.UPLOAD_SKETCH.id, commandId: UploadSketch.Commands.UPLOAD_SKETCH.id,
label: 'Upload', label: 'Upload',
order: '0' order: '1'
}); });
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
commandId: UploadSketch.Commands.UPLOAD_SKETCH_USING_PROGRAMMER.id, commandId: UploadSketch.Commands.UPLOAD_SKETCH_USING_PROGRAMMER.id,
label: 'Upload Using Programmer', label: 'Upload Using Programmer',
order: '1' order: '2'
}); });
} }

View File

@ -26,6 +26,9 @@ export class VerifySketch extends SketchContribution {
registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH, { registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH, {
execute: () => this.verifySketch() execute: () => this.verifySketch()
}); });
registry.registerCommand(VerifySketch.Commands.EXPORT_BINARIES, {
execute: () => this.verifySketch(true)
});
registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH_TOOLBAR, { registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH_TOOLBAR, {
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left', isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left',
execute: () => registry.executeCommand(VerifySketch.Commands.VERIFY_SKETCH.id) execute: () => registry.executeCommand(VerifySketch.Commands.VERIFY_SKETCH.id)
@ -36,7 +39,12 @@ export class VerifySketch extends SketchContribution {
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
commandId: VerifySketch.Commands.VERIFY_SKETCH.id, commandId: VerifySketch.Commands.VERIFY_SKETCH.id,
label: 'Verify/Compile', label: 'Verify/Compile',
order: '2' order: '0'
});
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
commandId: VerifySketch.Commands.EXPORT_BINARIES.id,
label: 'Export compiled Binary',
order: '3'
}); });
} }
@ -45,6 +53,10 @@ export class VerifySketch extends SketchContribution {
command: VerifySketch.Commands.VERIFY_SKETCH.id, command: VerifySketch.Commands.VERIFY_SKETCH.id,
keybinding: 'CtrlCmd+R' keybinding: 'CtrlCmd+R'
}); });
registry.registerKeybinding({
command: VerifySketch.Commands.EXPORT_BINARIES.id,
keybinding: 'CtrlCmd+Alt+S'
});
} }
registerToolbarItems(registry: TabBarToolbarRegistry): void { registerToolbarItems(registry: TabBarToolbarRegistry): void {
@ -56,7 +68,7 @@ export class VerifySketch extends SketchContribution {
}); });
} }
async verifySketch(): Promise<void> { async verifySketch(exportBinaries: boolean = false): Promise<void> {
const uri = await this.sketchServiceClient.currentSketchFile(); const uri = await this.sketchServiceClient.currentSketchFile();
if (!uri) { if (!uri) {
return; return;
@ -70,7 +82,8 @@ export class VerifySketch extends SketchContribution {
sketchUri: uri, sketchUri: uri,
fqbn, fqbn,
optimizeForDebug: this.editorMode.compileForDebug, optimizeForDebug: this.editorMode.compileForDebug,
verbose verbose,
exportBinaries
}); });
this.messageService.info('Done compiling.', { timeout: 1000 }); this.messageService.info('Done compiling.', { timeout: 1000 });
} catch (e) { } catch (e) {
@ -85,6 +98,9 @@ export namespace VerifySketch {
export const VERIFY_SKETCH: Command = { export const VERIFY_SKETCH: Command = {
id: 'arduino-verify-sketch' id: 'arduino-verify-sketch'
}; };
export const EXPORT_BINARIES: Command = {
id: 'arduino-export-binaries'
};
export const VERIFY_SKETCH_TOOLBAR: Command = { export const VERIFY_SKETCH_TOOLBAR: Command = {
id: 'arduino-verify-sketch--toolbar' id: 'arduino-verify-sketch--toolbar'
}; };

View File

@ -3,7 +3,7 @@ import { Programmer } from './boards-service';
export const CoreServicePath = '/services/core-service'; export const CoreServicePath = '/services/core-service';
export const CoreService = Symbol('CoreService'); export const CoreService = Symbol('CoreService');
export interface CoreService { export interface CoreService {
compile(options: CoreService.Compile.Options): Promise<void>; compile(options: CoreService.Compile.Options & Readonly<{ exportBinaries: boolean }>): Promise<void>;
upload(options: CoreService.Upload.Options): Promise<void>; upload(options: CoreService.Upload.Options): Promise<void>;
uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void>; uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void>;
burnBootloader(options: CoreService.Bootloader.Options): Promise<void>; burnBootloader(options: CoreService.Bootloader.Options): Promise<void>;

View File

@ -43,10 +43,9 @@ export class SketchesServiceClientImpl implements FrontendApplicationContributio
this.toDispose.push(this.fileService.watch(new URI(sketchDirUri), { recursive: true, excludes: [] })); this.toDispose.push(this.fileService.watch(new URI(sketchDirUri), { recursive: true, excludes: [] }));
this.toDispose.push(this.fileService.onDidFilesChange(async event => { this.toDispose.push(this.fileService.onDidFilesChange(async event => {
for (const { type, resource } of event.changes) { for (const { type, resource } of event.changes) {
// We track main sketch files changes only. // We track main sketch files changes only. // TODO: check sketch folder changes. One can rename the folder without renaming the `.ino` file.
if (sketchbookUri.isEqualOrParent(resource)) { if (sketchbookUri.isEqualOrParent(resource)) {
const { ext } = resource.path; // TODO: add support for `.pde`. if (Sketch.isSketchFile(resource)) {
if (ext === '.ino') {
if (type === FileChangeType.ADDED) { if (type === FileChangeType.ADDED) {
try { try {
const toAdd = await this.sketchService.loadSketch(resource.parent.toString()); const toAdd = await this.sketchService.loadSketch(resource.parent.toString());

View File

@ -23,7 +23,7 @@ export class CoreServiceImpl implements CoreService {
@inject(NotificationServiceServer) @inject(NotificationServiceServer)
protected readonly notificationService: NotificationServiceServer; protected readonly notificationService: NotificationServiceServer;
async compile(options: CoreService.Compile.Options): Promise<void> { async compile(options: CoreService.Compile.Options & { exportBinaries: boolean }): Promise<void> {
this.outputService.append({ name: 'compile', chunk: 'Compile...\n' + JSON.stringify(options, null, 2) + '\n--------------------------\n' }); this.outputService.append({ name: 'compile', chunk: 'Compile...\n' + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
const { sketchUri, fqbn } = options; const { sketchUri, fqbn } = options;
const sketchFilePath = FileUri.fsPath(sketchUri); const sketchFilePath = FileUri.fsPath(sketchUri);
@ -42,6 +42,7 @@ export class CoreServiceImpl implements CoreService {
compilerReq.setPreprocess(false); compilerReq.setPreprocess(false);
compilerReq.setVerbose(options.verbose); compilerReq.setVerbose(options.verbose);
compilerReq.setQuiet(false); compilerReq.setQuiet(false);
compilerReq.setExportBinaries(options.exportBinaries);
const result = client.compile(compilerReq); const result = client.compile(compilerReq);
try { try {
@ -74,7 +75,7 @@ export class CoreServiceImpl implements CoreService {
responseHandler: (client: ArduinoCoreClient, req: UploadReq | UploadUsingProgrammerReq) => ClientReadableStream<UploadResp | UploadUsingProgrammerResp>, responseHandler: (client: ArduinoCoreClient, req: UploadReq | UploadUsingProgrammerReq) => ClientReadableStream<UploadResp | UploadUsingProgrammerResp>,
task: string = 'upload'): Promise<void> { task: string = 'upload'): Promise<void> {
await this.compile(options); await this.compile(Object.assign(options, { exportBinaries: false }));
const chunk = firstToUpperCase(task) + '...\n'; const chunk = firstToUpperCase(task) + '...\n';
this.outputService.append({ name: 'upload', chunk: chunk + JSON.stringify(options, null, 2) + '\n--------------------------\n' }); this.outputService.append({ name: 'upload', chunk: chunk + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
const { sketchUri, fqbn, port, programmer } = options; const { sketchUri, fqbn, port, programmer } = options;

View File

@ -329,8 +329,8 @@ void loop() {
const { client } = await this.coreClient(); const { client } = await this.coreClient();
const archivePath = FileUri.fsPath(destinationUri); const archivePath = FileUri.fsPath(destinationUri);
// The CLI cannot override existing archives, so we have to wipe it manually: https://github.com/arduino/arduino-cli/issues/1160 // The CLI cannot override existing archives, so we have to wipe it manually: https://github.com/arduino/arduino-cli/issues/1160
if (await fs.exists(archivePath)) { if (await promisify(fs.exists)(archivePath)) {
await fs.unlink(archivePath); await promisify(fs.unlink)(archivePath);
} }
const req = new ArchiveSketchReq(); const req = new ArchiveSketchReq();
req.setSketchPath(FileUri.fsPath(sketch.uri)); req.setSketchPath(FileUri.fsPath(sketch.uri));