Skip to content

Commit e957ac4

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
ATL-74: Added Export compiled Binary.
Signed-off-by: Akos Kitta <[email protected]>
1 parent b65867d commit e957ac4

File tree

7 files changed

+31
-15
lines changed

7 files changed

+31
-15
lines changed

Diff for: arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
320320
}
321321
registry.registerSubmenu(ArduinoMenus.SKETCH, 'Sketch');
322322
registry.registerSubmenu(ArduinoMenus.TOOLS, 'Tools');
323-
registry.registerMenuAction(ArduinoMenus.SKETCH, {
323+
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
324324
commandId: ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG.id,
325325
label: 'Optimize for Debugging',
326-
order: '1'
326+
order: '4'
327327
});
328328
registry.registerMenuAction(ArduinoMenus.HELP__CONTROL_GROUP, {
329329
commandId: ArduinoCommands.TOGGLE_ADVANCED_MODE.id,

Diff for: arduino-ide-extension/src/browser/contributions/upload-sketch.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ export class UploadSketch extends SketchContribution {
4343
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
4444
commandId: UploadSketch.Commands.UPLOAD_SKETCH.id,
4545
label: 'Upload',
46-
order: '0'
46+
order: '1'
4747
});
4848
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
4949
commandId: UploadSketch.Commands.UPLOAD_SKETCH_USING_PROGRAMMER.id,
5050
label: 'Upload Using Programmer',
51-
order: '1'
51+
order: '2'
5252
});
5353
}
5454

Diff for: arduino-ide-extension/src/browser/contributions/verify-sketch.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export class VerifySketch extends SketchContribution {
2626
registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH, {
2727
execute: () => this.verifySketch()
2828
});
29+
registry.registerCommand(VerifySketch.Commands.EXPORT_BINARIES, {
30+
execute: () => this.verifySketch(true)
31+
});
2932
registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH_TOOLBAR, {
3033
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left',
3134
execute: () => registry.executeCommand(VerifySketch.Commands.VERIFY_SKETCH.id)
@@ -36,7 +39,12 @@ export class VerifySketch extends SketchContribution {
3639
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
3740
commandId: VerifySketch.Commands.VERIFY_SKETCH.id,
3841
label: 'Verify/Compile',
39-
order: '2'
42+
order: '0'
43+
});
44+
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
45+
commandId: VerifySketch.Commands.EXPORT_BINARIES.id,
46+
label: 'Export compiled Binary',
47+
order: '3'
4048
});
4149
}
4250

@@ -45,6 +53,10 @@ export class VerifySketch extends SketchContribution {
4553
command: VerifySketch.Commands.VERIFY_SKETCH.id,
4654
keybinding: 'CtrlCmd+R'
4755
});
56+
registry.registerKeybinding({
57+
command: VerifySketch.Commands.EXPORT_BINARIES.id,
58+
keybinding: 'CtrlCmd+Alt+S'
59+
});
4860
}
4961

5062
registerToolbarItems(registry: TabBarToolbarRegistry): void {
@@ -56,7 +68,7 @@ export class VerifySketch extends SketchContribution {
5668
});
5769
}
5870

59-
async verifySketch(): Promise<void> {
71+
async verifySketch(exportBinaries: boolean = false): Promise<void> {
6072
const uri = await this.sketchServiceClient.currentSketchFile();
6173
if (!uri) {
6274
return;
@@ -70,7 +82,8 @@ export class VerifySketch extends SketchContribution {
7082
sketchUri: uri,
7183
fqbn,
7284
optimizeForDebug: this.editorMode.compileForDebug,
73-
verbose
85+
verbose,
86+
exportBinaries
7487
});
7588
this.messageService.info('Done compiling.', { timeout: 1000 });
7689
} catch (e) {
@@ -85,6 +98,9 @@ export namespace VerifySketch {
8598
export const VERIFY_SKETCH: Command = {
8699
id: 'arduino-verify-sketch'
87100
};
101+
export const EXPORT_BINARIES: Command = {
102+
id: 'arduino-export-binaries'
103+
};
88104
export const VERIFY_SKETCH_TOOLBAR: Command = {
89105
id: 'arduino-verify-sketch--toolbar'
90106
};

Diff for: arduino-ide-extension/src/common/protocol/core-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Programmer } from './boards-service';
33
export const CoreServicePath = '/services/core-service';
44
export const CoreService = Symbol('CoreService');
55
export interface CoreService {
6-
compile(options: CoreService.Compile.Options): Promise<void>;
6+
compile(options: CoreService.Compile.Options & Readonly<{ exportBinaries: boolean }>): Promise<void>;
77
upload(options: CoreService.Upload.Options): Promise<void>;
88
uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void>;
99
burnBootloader(options: CoreService.Bootloader.Options): Promise<void>;

Diff for: arduino-ide-extension/src/common/protocol/sketches-service-client-impl.ts

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

Diff for: arduino-ide-extension/src/node/core-service-impl.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class CoreServiceImpl implements CoreService {
2323
@inject(NotificationServiceServer)
2424
protected readonly notificationService: NotificationServiceServer;
2525

26-
async compile(options: CoreService.Compile.Options): Promise<void> {
26+
async compile(options: CoreService.Compile.Options & { exportBinaries: boolean }): Promise<void> {
2727
this.outputService.append({ name: 'compile', chunk: 'Compile...\n' + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
2828
const { sketchUri, fqbn } = options;
2929
const sketchFilePath = FileUri.fsPath(sketchUri);
@@ -42,6 +42,7 @@ export class CoreServiceImpl implements CoreService {
4242
compilerReq.setPreprocess(false);
4343
compilerReq.setVerbose(options.verbose);
4444
compilerReq.setQuiet(false);
45+
compilerReq.setExportBinaries(options.exportBinaries);
4546

4647
const result = client.compile(compilerReq);
4748
try {
@@ -74,7 +75,7 @@ export class CoreServiceImpl implements CoreService {
7475
responseHandler: (client: ArduinoCoreClient, req: UploadReq | UploadUsingProgrammerReq) => ClientReadableStream<UploadResp | UploadUsingProgrammerResp>,
7576
task: string = 'upload'): Promise<void> {
7677

77-
await this.compile(options);
78+
await this.compile(Object.assign(options, { exportBinaries: false }));
7879
const chunk = firstToUpperCase(task) + '...\n';
7980
this.outputService.append({ name: 'upload', chunk: chunk + JSON.stringify(options, null, 2) + '\n--------------------------\n' });
8081
const { sketchUri, fqbn, port, programmer } = options;

Diff for: arduino-ide-extension/src/node/sketches-service-impl.ts

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

0 commit comments

Comments
 (0)