diff --git a/.vscode/launch.json b/.vscode/launch.json index 2cf29886..28b2c89a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,6 +10,13 @@ "name": "Attach by Process ID", "processId": "${command:PickProcess}" }, + { + "type": "node", + "request": "launch", + "name": "Launch Electron Packager", + "program": "${workspaceRoot}/electron/packager/index.js", + "cwd": "${workspaceFolder}/electron/packager" + }, { "type": "node", "request": "launch", @@ -99,13 +106,6 @@ "smartStep": true, "internalConsoleOptions": "openOnSessionStart", "outputCapture": "std" - }, - { - "type": "node", - "request": "launch", - "name": "Packager", - "program": "${workspaceRoot}/electron/packager/index.js", - "cwd": "${workspaceFolder}/electron/packager" } ] } diff --git a/arduino-debugger-extension/package.json b/arduino-debugger-extension/package.json new file mode 100644 index 00000000..282d505e --- /dev/null +++ b/arduino-debugger-extension/package.json @@ -0,0 +1,40 @@ +{ + "name": "arduino-debugger-extension", + "version": "0.0.4", + "description": "An extension for debugging Arduino programs", + "license": "MIT", + "engines": { + "node": ">=10.10.0" + }, + "dependencies": { + "@theia/debug": "next", + "arduino-ide-extension": "0.0.4", + "cdt-gdb-adapter": "^0.0.14", + "vscode-debugadapter": "^1.26.0", + "vscode-debugprotocol": "^1.26.0" + }, + "scripts": { + "prepare": "yarn run clean && yarn run build", + "clean": "rimraf lib", + "lint": "tslint -c ./tslint.json --project ./tsconfig.json", + "build": "tsc && yarn lint", + "watch": "tsc -w" + }, + "devDependencies": { + "rimraf": "^2.6.1", + "tslint": "^5.5.0", + "typescript": "3.5.1" + }, + "files": [ + "lib", + "src", + "build", + "data" + ], + "theiaExtensions": [ + { + "backend": "lib/node/backend-module", + "frontend": "lib/browser/frontend-module" + } + ] +} diff --git a/arduino-debugger-extension/src/browser/arduino-debug-configuration-manager.ts b/arduino-debugger-extension/src/browser/arduino-debug-configuration-manager.ts new file mode 100644 index 00000000..5e15f1cd --- /dev/null +++ b/arduino-debugger-extension/src/browser/arduino-debug-configuration-manager.ts @@ -0,0 +1,39 @@ +import { DebugConfigurationManager } from "@theia/debug/lib/browser/debug-configuration-manager"; +import { injectable } from "inversify"; + +@injectable() +export class ArduinoDebugConfigurationManager extends DebugConfigurationManager { + + get defaultDebugger(): Promise { + return this.debug.getDebuggersForLanguage('ino').then(debuggers => { + if (debuggers.length === 0) + return undefined; + return debuggers[0].type; + }); + } + + protected async selectDebugType(): Promise { + const widget = this.editorManager.currentEditor; + if (!widget) { + return this.defaultDebugger; + } + const { languageId } = widget.editor.document; + const debuggers = await this.debug.getDebuggersForLanguage(languageId); + if (debuggers.length === 0) { + return this.defaultDebugger; + } + return this.quickPick.show(debuggers.map( + ({ label, type }) => ({ label, value: type }), + { placeholder: 'Select Environment' }) + ); + } + + async createDefaultConfiguration(): Promise { + const { model } = this; + if (model) { + await this.doCreate(model); + await this.updateModels(); + } + } + +} diff --git a/arduino-debugger-extension/src/browser/arduino-debug-frontend-application-contribution.ts b/arduino-debugger-extension/src/browser/arduino-debug-frontend-application-contribution.ts new file mode 100644 index 00000000..60f9dd21 --- /dev/null +++ b/arduino-debugger-extension/src/browser/arduino-debug-frontend-application-contribution.ts @@ -0,0 +1,133 @@ +import { injectable, inject } from 'inversify'; +import { MenuModelRegistry, Path, MessageService, Command, CommandRegistry } from '@theia/core'; +import { KeybindingRegistry } from '@theia/core/lib/browser'; +import { TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; +import { DebugFrontendApplicationContribution, DebugCommands } from '@theia/debug/lib/browser/debug-frontend-application-contribution'; +import { DebugSessionOptions } from "@theia/debug/lib/browser/debug-session-options"; +import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service'; +import { FileSystem } from '@theia/filesystem/lib/common'; +import URI from '@theia/core/lib/common/uri'; +import { EditorManager } from '@theia/editor/lib/browser'; +import { EditorMode } from "arduino-ide-extension/lib/browser/editor-mode"; +import { SketchesService } from 'arduino-ide-extension/lib/common/protocol/sketches-service'; +import { ArduinoToolbar } from 'arduino-ide-extension/lib/browser/toolbar/arduino-toolbar'; +import { ArduinoDebugConfigurationManager } from './arduino-debug-configuration-manager'; + +export namespace ArduinoDebugCommands { + export const START_DEBUG: Command = { + id: 'arduino-start-debug', + label: 'Start Debugging' + } +} + +@injectable() +export class ArduinoDebugFrontendApplicationContribution extends DebugFrontendApplicationContribution { + + @inject(EditorMode) + protected readonly editorMode: EditorMode; + + @inject(WorkspaceService) + protected readonly workspaceService: WorkspaceService; + + @inject(SketchesService) + protected readonly sketchesService: SketchesService; + + @inject(FileSystem) + protected readonly fileSystem: FileSystem; + + @inject(EditorManager) + protected readonly editorManager: EditorManager; + + @inject(MessageService) + protected readonly messageService: MessageService; + + async start(noDebug?: boolean, debugSessionOptions?: DebugSessionOptions): Promise { + const configurations = this.configurations as ArduinoDebugConfigurationManager; + let current = debugSessionOptions ? debugSessionOptions : configurations.current; + // If no configurations are currently present, create them + if (!current) { + await configurations.createDefaultConfiguration(); + current = configurations.current; + } + if (current) { + if (noDebug !== undefined) { + current = { + ...current, + configuration: { + ...current.configuration, + noDebug + } + }; + } + if (current.configuration.type === 'arduino') { + const wsStat = this.workspaceService.workspace; + let sketchFileURI: URI | undefined; + if (wsStat && await this.sketchesService.isSketchFolder(wsStat.uri)) { + const wsPath = new Path(wsStat.uri); + const sketchFilePath = wsPath.join(wsPath.name + '.ino').toString(); + sketchFileURI = new URI(sketchFilePath); + } else if (this.editorManager.currentEditor) { + const editorURI = this.editorManager.currentEditor.getResourceUri(); + if (editorURI && editorURI.path && editorURI.path.ext === '.ino') { + sketchFileURI = editorURI; + } + } + if (sketchFileURI) { + await this.editorManager.open(sketchFileURI); + await this.manager.start(current); + } else { + this.messageService.error('Please open a sketch file to start debugging.') + } + } else { + await this.manager.start(current); + } + } + } + + initializeLayout(): Promise { + if (this.editorMode.proMode) { + return super.initializeLayout(); + } + return Promise.resolve(); + } + + registerMenus(menus: MenuModelRegistry): void { + if (this.editorMode.proMode) { + super.registerMenus(menus); + menus.unregisterMenuAction(DebugCommands.START_NO_DEBUG); + } + } + + registerKeybindings(keybindings: KeybindingRegistry): void { + if (this.editorMode.proMode) { + super.registerKeybindings(keybindings); + keybindings.unregisterKeybinding({ + command: DebugCommands.START_NO_DEBUG.id, + keybinding: 'ctrl+f5' + }); + } + } + + registerToolbarItems(toolbar: TabBarToolbarRegistry): void { + super.registerToolbarItems(toolbar); + toolbar.registerItem({ + id: ArduinoDebugCommands.START_DEBUG.id, + command: ArduinoDebugCommands.START_DEBUG.id, + tooltip: 'Start Debugging', + priority: 1 + }); + } + + registerCommands(registry: CommandRegistry): void { + super.registerCommands(registry); + registry.registerCommand(ArduinoDebugCommands.START_DEBUG, { + isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left', + isEnabled: widget => ArduinoToolbar.is(widget) && widget.side === 'left', + execute: () => { + registry.executeCommand(DebugCommands.START.id); + } + }); + } + + +} diff --git a/arduino-debugger-extension/src/browser/arduino-debug-session-manager.ts b/arduino-debugger-extension/src/browser/arduino-debug-session-manager.ts new file mode 100644 index 00000000..79f81d58 --- /dev/null +++ b/arduino-debugger-extension/src/browser/arduino-debug-session-manager.ts @@ -0,0 +1,14 @@ +import { DebugSessionManager } from "@theia/debug/lib/browser/debug-session-manager"; +import { DebugSessionOptions } from "@theia/debug/lib/browser/debug-session-options"; + +export class ArduinoDebugSessionManager extends DebugSessionManager { + + start(options: DebugSessionOptions) { + if (options.configuration.type === 'arduino' && this.sessions.find(s => s.configuration.type === 'arduino')) { + this.messageService.info('A debug session is already running. You must stop the running session before starting a new one.') + return Promise.resolve(undefined); + } + return super.start(options); + } + +} diff --git a/arduino-debugger-extension/src/browser/arduino-variable-resolver.ts b/arduino-debugger-extension/src/browser/arduino-variable-resolver.ts new file mode 100644 index 00000000..eb3028ef --- /dev/null +++ b/arduino-debugger-extension/src/browser/arduino-variable-resolver.ts @@ -0,0 +1,46 @@ + +import { VariableContribution, VariableRegistry, Variable } from '@theia/variable-resolver/lib/browser'; +import { injectable, inject } from 'inversify'; +import { MessageService } from '@theia/core/lib/common/message-service'; +import { BoardsServiceClientImpl } from 'arduino-ide-extension/lib/browser/boards/boards-service-client-impl'; + +@injectable() +export class ArduinoVariableResolver implements VariableContribution { + + @inject(BoardsServiceClientImpl) + protected readonly boardsServiceClient: BoardsServiceClientImpl; + + @inject(MessageService) + protected readonly messageService: MessageService + + registerVariables(variables: VariableRegistry): void { + variables.registerVariable({ + name: 'fqbn', + description: 'Qualified name of the selected board', + resolve: this.resolveFqbn.bind(this), + }); + variables.registerVariable({ + name: 'port', + description: 'Selected upload port', + resolve: this.resolvePort.bind(this) + }); + } + + protected async resolveFqbn(): Promise { + const { boardsConfig } = this.boardsServiceClient; + if (!boardsConfig || !boardsConfig.selectedBoard) { + this.messageService.error('No board selected. Please select a board for debugging.'); + return undefined; + } + return boardsConfig.selectedBoard.fqbn; + } + + protected async resolvePort(): Promise { + const { boardsConfig } = this.boardsServiceClient; + if (!boardsConfig || !boardsConfig.selectedPort) { + return undefined; + } + return boardsConfig.selectedPort.address; + } + +} diff --git a/arduino-debugger-extension/src/browser/frontend-module.ts b/arduino-debugger-extension/src/browser/frontend-module.ts new file mode 100644 index 00000000..1270812a --- /dev/null +++ b/arduino-debugger-extension/src/browser/frontend-module.ts @@ -0,0 +1,20 @@ +import { ContainerModule } from 'inversify'; +import { VariableContribution } from '@theia/variable-resolver/lib/browser'; +import { ArduinoVariableResolver } from './arduino-variable-resolver'; +import { DebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager'; +import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution'; +import { DebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager'; +import { ArduinoDebugConfigurationManager } from './arduino-debug-configuration-manager'; +import { ArduinoDebugFrontendApplicationContribution } from './arduino-debug-frontend-application-contribution'; +import { ArduinoDebugSessionManager } from './arduino-debug-session-manager'; + +import '../../src/browser/style/index.css'; + + +export default new ContainerModule((bind, unbind, isBound, rebind) => { + bind(ArduinoVariableResolver).toSelf().inSingletonScope(); + bind(VariableContribution).toService(ArduinoVariableResolver); + rebind(DebugSessionManager).to(ArduinoDebugSessionManager).inSingletonScope(); + rebind(DebugConfigurationManager).to(ArduinoDebugConfigurationManager).inSingletonScope(); + rebind(DebugFrontendApplicationContribution).to(ArduinoDebugFrontendApplicationContribution); +}); diff --git a/arduino-debugger-extension/src/browser/style/debug-dark.svg b/arduino-debugger-extension/src/browser/style/debug-dark.svg new file mode 100644 index 00000000..5c414170 --- /dev/null +++ b/arduino-debugger-extension/src/browser/style/debug-dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/arduino-debugger-extension/src/browser/style/index.css b/arduino-debugger-extension/src/browser/style/index.css new file mode 100644 index 00000000..1e3d51a6 --- /dev/null +++ b/arduino-debugger-extension/src/browser/style/index.css @@ -0,0 +1,16 @@ +.arduino-start-debug-icon { + -webkit-mask: url('debug-dark.svg') 50%; + mask: url('debug-dark.svg') 50%; + -webkit-mask-size: 100%; + mask-size: 100%; + -webkit-mask-repeat: no-repeat; + mask-repeat: no-repeat; + display: flex; + justify-content: center; + align-items: center; + color: var(--theia-ui-button-font-color); +} + +.arduino-start-debug { + border-radius: 12px; +} diff --git a/arduino-debugger-extension/src/node/arduino-debug-adapter-contribution.ts b/arduino-debugger-extension/src/node/arduino-debug-adapter-contribution.ts new file mode 100644 index 00000000..9f6ee487 --- /dev/null +++ b/arduino-debugger-extension/src/node/arduino-debug-adapter-contribution.ts @@ -0,0 +1,89 @@ +import * as path from 'path'; +import { injectable, inject } from 'inversify'; +import { DebugAdapterContribution, DebugAdapterExecutable } from '@theia/debug/lib/common/debug-model'; +import { DebugConfiguration } from '@theia/debug/lib/common/debug-configuration'; +import { IJSONSchema } from '@theia/core/lib/common/json-schema'; +import { ArduinoCli } from 'arduino-ide-extension/lib/node/arduino-cli'; + +@injectable() +export class ArduinoDebugAdapterContribution implements DebugAdapterContribution { + + readonly type = 'arduino'; + readonly label = 'Arduino'; + readonly languages = ['c', 'cpp', 'ino']; + + @inject(ArduinoCli) arduinoCli: ArduinoCli; + + getSchemaAttributes(): IJSONSchema[] { + return [ + { + 'properties': { + 'sketch': { + 'type': 'string', + 'description': 'path to the sketch root ino file', + 'default': '${file}', + }, + 'pauseAtMain': { + 'description': 'If enabled the debugger will pause at the start of the main function.', + 'type': 'boolean', + 'default': false + }, + 'debugDebugAdapter': { + 'type': 'boolean', + 'description': 'Start the debug adapter in debug mode (with --inspect-brk)', + 'default': false + }, + } + } + ] + } + + provideDebugAdapterExecutable(config: DebugConfiguration): DebugAdapterExecutable { + const debugAdapterMain = path.join(__dirname, 'debug-adapter', 'main'); + if (config.debugDebugAdapter) { + return { + command: process.execPath, + args: ['--inspect-brk', debugAdapterMain], + } + } + return { + modulePath: debugAdapterMain, + args: [], + } + } + + provideDebugConfigurations(): DebugConfiguration[] { + return [ + { + name: this.label, + type: this.type, + request: 'launch' + } + ]; + } + + async resolveDebugConfiguration(config: DebugConfiguration): Promise { + const startFunction = config.pauseAtMain ? 'main' : 'setup'; + const res: ActualDebugConfig = { + ...config, + arduinoCli: await this.arduinoCli.getExecPath(), + fqbn: '${fqbn}', + uploadPort: '${port}', + initCommands: [ + `-break-insert -t --function ${startFunction}` + ] + } + if (!res.sketch) { + res.sketch = '${file}'; + } + return res; + } + +} + +interface ActualDebugConfig extends DebugConfiguration { + arduinoCli?: string; + sketch?: string; + fqbn?: string; + uploadPort?: string; +} diff --git a/arduino-debugger-extension/src/node/backend-module.ts b/arduino-debugger-extension/src/node/backend-module.ts new file mode 100644 index 00000000..f9e72972 --- /dev/null +++ b/arduino-debugger-extension/src/node/backend-module.ts @@ -0,0 +1,7 @@ +import { ContainerModule } from 'inversify'; +import { DebugAdapterContribution } from '@theia/debug/lib/common/debug-model'; +import { ArduinoDebugAdapterContribution } from './arduino-debug-adapter-contribution'; + +export default new ContainerModule((bind, unbind, isBound, rebind) => { + bind(DebugAdapterContribution).to(ArduinoDebugAdapterContribution).inSingletonScope(); +}); diff --git a/arduino-debugger-extension/src/node/debug-adapter/arduino-debug-session.ts b/arduino-debugger-extension/src/node/debug-adapter/arduino-debug-session.ts new file mode 100644 index 00000000..87eba74a --- /dev/null +++ b/arduino-debugger-extension/src/node/debug-adapter/arduino-debug-session.ts @@ -0,0 +1,140 @@ +import { DebugProtocol } from 'vscode-debugprotocol'; +import { GDBDebugSession, FrameVariableReference } from 'cdt-gdb-adapter/dist/GDBDebugSession'; +import { GDBBackend } from 'cdt-gdb-adapter/dist/GDBBackend'; +import * as mi from 'cdt-gdb-adapter/dist/mi'; +import { ArduinoGDBBackend } from './arduino-gdb-backend'; +import { ArduinoVariableHandler } from './arduino-variable-handler'; +import { Scope, OutputEvent } from 'vscode-debugadapter'; + +export interface ArduinoLaunchRequestArguments extends DebugProtocol.LaunchRequestArguments { + arduinoCli?: string; + sketch?: string; + fqbn?: string; + uploadPort?: string; +} + +const GLOBAL_HANDLE_ID = 0xFE; +const STATIC_HANDLES_START = 0x010000; +const STATIC_HANDLES_FINISH = 0x01FFFF; + +export class ArduinoDebugSession extends GDBDebugSession { + + private _variableHandler: ArduinoVariableHandler; + + get arduinoBackend(): ArduinoGDBBackend { + return this.gdb as ArduinoGDBBackend; + } + + protected get variableHandler() { + if (this._variableHandler) { + return this._variableHandler; + } + if (!this.gdb) { + throw new Error("GDB backend is not ready."); + } + const handler = new ArduinoVariableHandler(this, this.frameHandles, this.variableHandles); + this._variableHandler = handler; + return handler; + } + + protected createBackend(): GDBBackend { + return new ArduinoGDBBackend(); + } + + protected async configurationDoneRequest(response: DebugProtocol.ConfigurationDoneResponse): Promise { + try { + await this.gdb.sendCommand('-interpreter-exec console "monitor reset halt"') + await mi.sendExecContinue(this.gdb); + this.sendResponse(response); + } catch (err) { + this.sendErrorResponse(response, 100, err.message); + } + } + + protected pauseRequest(response: DebugProtocol.PauseResponse, args: DebugProtocol.PauseArguments): Promise { + if (process.platform === 'win32') { + const message = 'Pause is not supported on Windows. Please stop the debug session and set a breakpoint instead.'; + this.sendEvent(new OutputEvent(message)); + this.sendErrorResponse(response, 1, message); + return Promise.resolve(); + } + return super.pauseRequest(response, args); + } + + protected async disconnectRequest(response: DebugProtocol.DisconnectResponse): Promise { + try { + if (this.isRunning) { + if (process.platform === 'win32') { + // We cannot pause on Windows + this.arduinoBackend.kill(); + this.sendResponse(response); + return; + } + // Need to pause first + const waitPromise = new Promise(resolve => this.waitPaused = resolve); + this.gdb.pause(); + await waitPromise; + } + await this.gdb.sendGDBExit(); + this.sendResponse(response); + } catch (err) { + this.sendErrorResponse(response, 1, err.message); + } + } + + protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments): void { + try { + const frame: FrameVariableReference = { + type: 'frame', + frameHandle: args.frameId, + }; + // const pins: ObjectVariableReference = { + // type: "object", + // varobjName: "__pins", + // frameHandle: 42000, + // } + + response.body = { + scopes: [ + // new Scope('Pins', this.variableHandles.create(pins), false), + new Scope('Local', this.variableHandles.create(frame), false), + new Scope('Global', GLOBAL_HANDLE_ID, false), + // new Scope('Static', STATIC_HANDLES_START + parseInt(args.frameId as any, 10), false) + ], + }; + + this.sendResponse(response); + } catch (err) { + this.sendErrorResponse(response, 1, err.message); + } + } + + protected async variablesRequest(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments): Promise { + try { + response.body = { + variables: [] as DebugProtocol.Variable[] + }; + const ref = this.variableHandles.get(args.variablesReference); + if (args.variablesReference === GLOBAL_HANDLE_ID) { + // Use hardcoded global handle to load and store global variables + response.body.variables = await this.variableHandler.getGlobalVariables(); + } else if (args.variablesReference >= STATIC_HANDLES_START && args.variablesReference <= STATIC_HANDLES_FINISH) { + // Use STATIC_HANDLES_START to shift the framehandles back + const frameHandle = args.variablesReference - STATIC_HANDLES_START; + response.body.variables = await this.variableHandler.getStaticVariables(frameHandle); + } else if (ref && ref.type === 'frame') { + // List variables for current frame + response.body.variables = await this.handleVariableRequestFrame(ref); + } else if (ref && ref.varobjName === '__pins') { + response.body.variables = await this.variableHandler.handlePinStatusRequest(); + } else if (ref && ref.type === 'object') { + // List data under any variable + response.body.variables = await this.handleVariableRequestObject(ref); + } + this.sendResponse(response); + } catch (err) { + this.sendErrorResponse(response, 1, err.message); + } + } + +} diff --git a/arduino-debugger-extension/src/node/debug-adapter/arduino-gdb-backend.ts b/arduino-debugger-extension/src/node/debug-adapter/arduino-gdb-backend.ts new file mode 100644 index 00000000..b1dd3fa5 --- /dev/null +++ b/arduino-debugger-extension/src/node/debug-adapter/arduino-gdb-backend.ts @@ -0,0 +1,71 @@ +import * as path from 'path'; +import * as fs from 'arduino-ide-extension/lib/node/fs-extra' +import { spawn } from 'child_process'; +import { GDBBackend } from 'cdt-gdb-adapter/dist/GDBBackend'; +import { MIFrameInfo } from 'cdt-gdb-adapter/dist/mi'; +import { ArduinoLaunchRequestArguments } from './arduino-debug-session'; +import { ArduinoParser } from './arduino-parser'; + +export class ArduinoGDBBackend extends GDBBackend { + + constructor() { + super(); + this.parser = new ArduinoParser(this); + } + + spawn(requestArgs: ArduinoLaunchRequestArguments): Promise { + if (!requestArgs.sketch) { + throw new Error('Missing argument: sketch'); + } + if (!requestArgs.fqbn) { + throw new Error('Missing argument: fqbn') + } + const sketchFS = fs.statSync(requestArgs.sketch); + const sketchDir = sketchFS.isFile() ? path.dirname(requestArgs.sketch) : requestArgs.sketch; + const command = requestArgs.arduinoCli || 'arduino-cli'; + const args = [ + 'debug', + '-p', requestArgs.uploadPort || 'none', + '-b', requestArgs.fqbn, + sketchDir + ]; + const proc = spawn(command, args); + this.proc = proc; + this.out = proc.stdin; + return (this.parser as ArduinoParser).parseFull(proc); + } + + sendFileExecAndSymbols(): Promise { + // The program file is already sent by `arduino-cli` + return Promise.resolve(); + } + + sendExecInterrupt(threadId?: number) { + let command = '-exec-interrupt'; + if (threadId) { + command += ` --thread ${threadId}`; + } + return this.sendCommand(command); + } + + sendStackInfoFrame(threadId: number, frameId: number): Promise<{ frame: MIFrameInfo }> { + const command = `-stack-info-frame --thread ${threadId} --frame ${frameId}`; + return this.sendCommand(command); + } + + sendTargetDetach(): Promise { + return this.sendCommand('-target-detach'); + } + + kill(): void { + if (!this.proc) { + return; + } + if (process.platform === 'win32') { + spawn('taskkill', ['/pid', this.proc.pid.toString(), '/f', '/t']); + } else { + this.proc.kill('SIGKILL'); + } + } + +} diff --git a/arduino-debugger-extension/src/node/debug-adapter/arduino-parser.ts b/arduino-debugger-extension/src/node/debug-adapter/arduino-parser.ts new file mode 100644 index 00000000..07767baf --- /dev/null +++ b/arduino-debugger-extension/src/node/debug-adapter/arduino-parser.ts @@ -0,0 +1,76 @@ +import { ChildProcessWithoutNullStreams } from 'child_process'; +import { Readable } from 'stream'; +import { MIParser } from "cdt-gdb-adapter/dist/MIParser"; + +const LINE_REGEX = /(.*)(\r?\n)/; + +export class ArduinoParser extends MIParser { + + protected rejectReady?: (error: Error) => void; + + parseFull(proc: ChildProcessWithoutNullStreams): Promise { + return new Promise((resolve, reject) => { + // Detect errors when the child process could not be spawned + proc.on('error', reject); + + this.waitReady = () => { + this.rejectReady = undefined; + resolve(); + } + this.rejectReady = (error: Error) => { + this.waitReady = undefined; + reject(error); + } + // Detect unexpected termination + proc.on('exit', () => { + if (this.rejectReady) { + this.rejectReady(new Error('The gdb debugger terminated unexpectedly.')); + } + }); + this.readInputStream(proc.stdout); + this.readErrorStream(proc.stderr); + }); + } + + private readInputStream(stream: Readable) { + let buff = ''; + stream.on('data', chunk => { + buff += chunk.toString(); + let regexArray = LINE_REGEX.exec(buff); + while (regexArray) { + const line = regexArray[1]; + this.line = line; + this.pos = 0; + this.handleLine(); + // Detect error emitted as log message + if (this.rejectReady && line.toLowerCase().startsWith('&"error')) { + this.pos = 1; + this.rejectReady(new Error(this.handleCString() || regexArray[1])); + this.rejectReady = undefined; + } + buff = buff.substring(regexArray[1].length + regexArray[2].length); + regexArray = LINE_REGEX.exec(buff); + } + }); + } + + private readErrorStream(stream: Readable) { + let buff = ''; + stream.on('data', chunk => { + buff += chunk.toString(); + let regexArray = LINE_REGEX.exec(buff); + while (regexArray) { + const line = regexArray[1]; + this.gdb.emit('consoleStreamOutput', line + '\n', 'stderr'); + // Detect error emitted on the stderr stream + if (this.rejectReady && line.toLowerCase().startsWith('error')) { + this.rejectReady(new Error(line)); + this.rejectReady = undefined; + } + buff = buff.substring(regexArray[1].length + regexArray[2].length); + regexArray = LINE_REGEX.exec(buff); + } + }); + } + +} diff --git a/arduino-debugger-extension/src/node/debug-adapter/arduino-variable-handler.ts b/arduino-debugger-extension/src/node/debug-adapter/arduino-variable-handler.ts new file mode 100644 index 00000000..e440c946 --- /dev/null +++ b/arduino-debugger-extension/src/node/debug-adapter/arduino-variable-handler.ts @@ -0,0 +1,115 @@ +import * as path from 'path'; +import { DebugProtocol } from "vscode-debugprotocol"; +import { Handles } from 'vscode-debugadapter/lib/handles'; +import { FrameReference, VariableReference } from "cdt-gdb-adapter/dist/GDBDebugSession"; +import { VarManager } from 'cdt-gdb-adapter/dist/varManager'; +import * as mi from 'cdt-gdb-adapter/dist/mi'; +import { ArduinoDebugSession } from "./arduino-debug-session"; +import { ArduinoGDBBackend } from './arduino-gdb-backend'; + +export class ArduinoVariableHandler { + + protected readonly gdb: ArduinoGDBBackend; + protected readonly varMgr: VarManager; + + protected globalHandle: number; + + constructor(protected readonly session: ArduinoDebugSession, + protected frameHandles: Handles, + protected variableHandles: Handles) { + this.gdb = session.arduinoBackend; + this.varMgr = new VarManager(this.gdb); + } + + createGlobalHandle() { + this.globalHandle = this.frameHandles.create({ + threadId: -1, + frameId: -1 + }); + } + + /** TODO */ + async getGlobalVariables(): Promise { + throw new Error('Global variables are not supported yet.'); + const frame = this.frameHandles.get(this.globalHandle); + const symbolInfo: any[] = [] // this.symbolTable.getGlobalVariables(); + const variables: DebugProtocol.Variable[] = []; + + for (const symbol of symbolInfo) { + const name = `global_var_${symbol.name}`; + const variable = await this.getVariables(frame, name, symbol.name, -1); + variables.push(variable); + } + + return variables; + } + + /** TODO */ + async getStaticVariables(frameHandle: number): Promise { + throw new Error('Static variables are not supported yet.'); + const frame = this.frameHandles.get(frameHandle); + const result = await this.gdb.sendStackInfoFrame(frame.threadId, frame.frameId); + const file = path.normalize(result.frame.file || ''); + const symbolInfo: any[] = [] // this.symbolTable.getStaticVariables(file); + const variables: DebugProtocol.Variable[] = []; + + // Fetch stack depth to obtain frameId/threadId/depth tuple + const stackDepth = await mi.sendStackInfoDepth(this.gdb, { maxDepth: 100 }); + const depth = parseInt(stackDepth.depth, 10); + + for (const symbol of symbolInfo) { + const name = `${file}_static_var_${symbol.name}`; + const variable = await this.getVariables(frame, name, symbol.name, depth); + variables.push(variable); + } + + return variables; + } + + private async getVariables(frame: FrameReference, name: string, expression: string, depth: number): Promise { + let global = this.varMgr.getVar(frame.frameId, frame.threadId, depth, name); + + if (global) { + // Update value if it is already loaded + const vup = await mi.sendVarUpdate(this.gdb, { name }); + const update = vup.changelist[0]; + if (update && update.in_scope === 'true' && update.name === global.varname) { + global.value = update.value; + } + } else { + // create var in GDB and store it in the varMgr + const varCreateResponse = await mi.sendVarCreate(this.gdb, { + name, + frame: 'current', + expression, + }); + + global = this.varMgr.addVar(frame.frameId, frame.threadId, depth, name, true, false, varCreateResponse); + } + + return { + name: expression, + value: (global.value === void 0) ? '' : global.value, + type: global.type, + variablesReference: parseInt(global.numchild, 10) > 0 + ? this.variableHandles.create({ + frameHandle: this.globalHandle, + type: 'object', + varobjName: global.varname, + }) + : 0, + }; + } + + async handlePinStatusRequest(): Promise { + const variables: DebugProtocol.Variable[] = []; + variables.push({ + name: "D2", + type: "gpio", + value: "0x00", + variablesReference: 0 + }) + return variables; + } + +} diff --git a/arduino-debugger-extension/src/node/debug-adapter/main.ts b/arduino-debugger-extension/src/node/debug-adapter/main.ts new file mode 100644 index 00000000..59fa0ee9 --- /dev/null +++ b/arduino-debugger-extension/src/node/debug-adapter/main.ts @@ -0,0 +1,10 @@ +import * as process from 'process'; +import { logger } from 'vscode-debugadapter/lib/logger'; +import { ArduinoDebugSession } from './arduino-debug-session'; +import { DebugSession } from 'vscode-debugadapter'; + +process.on('uncaughtException', (err: any) => { + logger.error(JSON.stringify(err)); +}); + +DebugSession.run(ArduinoDebugSession); diff --git a/arduino-debugger-extension/tsconfig.json b/arduino-debugger-extension/tsconfig.json new file mode 100644 index 00000000..86907b52 --- /dev/null +++ b/arduino-debugger-extension/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "noImplicitAny": true, + "noEmitOnError": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "strictNullChecks": true, + "experimentalDecorators": true, + "downlevelIteration": true, + "emitDecoratorMetadata": true, + "module": "commonjs", + "moduleResolution": "node", + "target": "es6", + "outDir": "lib", + "lib": [ + "es6", + "dom" + ], + "jsx": "react", + "sourceMap": true, + "skipLibCheck": true + }, + "include": [ + "src" + ], + "files": [ + "../node_modules/@theia/monaco/src/typings/monaco/index.d.ts" + ] +} \ No newline at end of file diff --git a/arduino-debugger-extension/tslint.json b/arduino-debugger-extension/tslint.json new file mode 100644 index 00000000..55b00628 --- /dev/null +++ b/arduino-debugger-extension/tslint.json @@ -0,0 +1,37 @@ +{ + "rules": { + "class-name": true, + "comment-format": [true, "check-space"], + "curly": false, + "forin": false, + "indent": [true, "spaces"], + "max-line-length": [true, 180], + "no-trailing-whitespace": false, + "no-unused-expression": true, + "no-var-keyword": true, + "one-line": [true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "radix": true, + "trailing-comma": [false], + "triple-equals": [true, "allow-null-check"], + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }], + "variable-name": false, + "whitespace": [true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} \ No newline at end of file diff --git a/arduino-ide-extension/scripts/download-cli.js b/arduino-ide-extension/scripts/download-cli.js index 79ac7cfa..7009a077 100755 --- a/arduino-ide-extension/scripts/download-cli.js +++ b/arduino-ide-extension/scripts/download-cli.js @@ -10,7 +10,7 @@ (() => { - const DEFAULT_VERSION = '0.7.1'; // require('moment')().format('YYYYMMDD'); + const DEFAULT_VERSION = '0.9.0-rc2'; // require('moment')().format('YYYYMMDD'); const path = require('path'); const shell = require('shelljs'); diff --git a/arduino-ide-extension/src/browser/arduino-commands.ts b/arduino-ide-extension/src/browser/arduino-commands.ts index d0b3dcb7..94376fe5 100644 --- a/arduino-ide-extension/src/browser/arduino-commands.ts +++ b/arduino-ide-extension/src/browser/arduino-commands.ts @@ -6,11 +6,21 @@ export namespace ArduinoCommands { id: 'arduino-verify', label: 'Verify Sketch' } + export const VERIFY_TOOLBAR: Command = { + id: 'arduino-verify-toolbar', + } export const UPLOAD: Command = { id: 'arduino-upload', label: 'Upload Sketch' } + export const UPLOAD_TOOLBAR: Command = { + id: 'arduino-upload-toolbar', + } + + export const TOGGLE_COMPILE_FOR_DEBUG: Command = { + id: "arduino-toggle-compile-for-debug" + } export const SHOW_OPEN_CONTEXT_MENU: Command = { id: 'arduino-show-open-context-menu', @@ -42,4 +52,7 @@ export namespace ArduinoCommands { export const TOGGLE_ADVANCED_MODE: Command = { id: "arduino-toggle-advanced-mode" } + export const TOGGLE_ADVANCED_MODE_TOOLBAR: Command = { + id: "arduino-toggle-advanced-mode-toolbar" + } } diff --git a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx index bcdd133a..299d4cfb 100644 --- a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx +++ b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx @@ -181,23 +181,25 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut registerToolbarItems(registry: TabBarToolbarRegistry): void { registry.registerItem({ id: ArduinoCommands.VERIFY.id, - command: ArduinoCommands.VERIFY.id, + command: ArduinoCommands.VERIFY_TOOLBAR.id, tooltip: 'Verify' }); registry.registerItem({ id: ArduinoCommands.UPLOAD.id, - command: ArduinoCommands.UPLOAD.id, + command: ArduinoCommands.UPLOAD_TOOLBAR.id, tooltip: 'Upload' }); registry.registerItem({ id: ArduinoCommands.SHOW_OPEN_CONTEXT_MENU.id, command: ArduinoCommands.SHOW_OPEN_CONTEXT_MENU.id, - tooltip: 'Open' + tooltip: 'Open', + priority: 2 }); registry.registerItem({ id: ArduinoCommands.SAVE_SKETCH.id, command: ArduinoCommands.SAVE_SKETCH.id, - tooltip: 'Save' + tooltip: 'Save', + priority: 2 }); registry.registerItem({ id: BoardsToolBarItem.TOOLBAR_ID, @@ -206,21 +208,20 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut commands={this.commandRegistry} boardsServiceClient={this.boardsServiceClient} boardService={this.boardsService} />, - isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left' + isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left', + priority: 2 }); registry.registerItem({ id: 'toggle-serial-monitor', - command: MonitorViewContribution.OPEN_SERIAL_MONITOR, - tooltip: 'Toggle Serial Monitor', - isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right' + command: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR, + tooltip: 'Toggle Serial Monitor' }); registry.registerItem({ id: ArduinoCommands.TOGGLE_ADVANCED_MODE.id, - command: ArduinoCommands.TOGGLE_ADVANCED_MODE.id, + command: ArduinoCommands.TOGGLE_ADVANCED_MODE_TOOLBAR.id, tooltip: 'Toggle Advanced Mode', - text: (this.editorMode.proMode ? '$(toggle-on)' : '$(toggle-off)'), - isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right' + text: (this.editorMode.proMode ? '$(toggle-on)' : '$(toggle-off)') }); } @@ -263,80 +264,31 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut } registry.registerCommand(ArduinoCommands.VERIFY, { + execute: this.verify.bind(this) + }); + registry.registerCommand(ArduinoCommands.VERIFY_TOOLBAR, { isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left', - isEnabled: widget => true, - execute: async () => { - const widget = this.getCurrentWidget(); - if (widget instanceof EditorWidget) { - await widget.saveable.save(); - } + execute: this.verify.bind(this) + }); - const uri = this.toUri(widget); - if (!uri) { - return; - } - - try { - const { boardsConfig } = this.boardsServiceClient; - if (!boardsConfig || !boardsConfig.selectedBoard) { - throw new Error('No boards selected. Please select a board.'); - } - if (!boardsConfig.selectedBoard.fqbn) { - throw new Error(`No core is installed for ${boardsConfig.selectedBoard.name}. Please install the board.`); - } - // Reveal the Output view asynchronously (don't await it) - this.outputContribution.openView({ reveal: true }); - await this.coreService.compile({ uri: uri.toString(), board: boardsConfig.selectedBoard }); - } catch (e) { - await this.messageService.error(e.toString()); - } - } + registry.registerCommand(ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG, { + execute: () => { + this.editorMode.toggleCompileForDebug(); + this.editorMode.menuContentChanged.fire(); + }, + isToggled: () => this.editorMode.compileForDebug }); registry.registerCommand(ArduinoCommands.UPLOAD, { + execute: this.upload.bind(this) + }); + registry.registerCommand(ArduinoCommands.UPLOAD_TOOLBAR, { isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left', - isEnabled: widget => true, - execute: async () => { - const widget = this.getCurrentWidget(); - if (widget instanceof EditorWidget) { - await widget.saveable.save(); - } - - const uri = this.toUri(widget); - if (!uri) { - return; - } - - const monitorConfig = this.monitorConnection.monitorConfig; - if (monitorConfig) { - await this.monitorConnection.disconnect(); - } - - try { - const { boardsConfig } = this.boardsServiceClient; - if (!boardsConfig || !boardsConfig.selectedBoard) { - throw new Error('No boards selected. Please select a board.'); - } - const { selectedPort } = boardsConfig; - if (!selectedPort) { - throw new Error('No ports selected. Please select a port.'); - } - // Reveal the Output view asynchronously (don't await it) - this.outputContribution.openView({ reveal: true }); - await this.coreService.upload({ uri: uri.toString(), board: boardsConfig.selectedBoard, port: selectedPort.address }); - } catch (e) { - await this.messageService.error(e.toString()); - } finally { - if (monitorConfig) { - await this.monitorConnection.connect(monitorConfig); - } - } - } + execute: this.upload.bind(this) }); registry.registerCommand(ArduinoCommands.SHOW_OPEN_CONTEXT_MENU, { isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left', - isEnabled: widget => ArduinoToolbar.is(widget) && widget.side === 'left', execute: async (widget: Widget, target: EventTarget) => { if (this.wsSketchCount) { const el = (target as HTMLElement).parentElement; @@ -365,7 +317,6 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut }); registry.registerCommand(ArduinoCommands.SAVE_SKETCH, { - isEnabled: widget => ArduinoToolbar.is(widget) && widget.side === 'left', isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left', execute: async (sketch: Sketch) => { registry.executeCommand(CommonCommands.SAVE_ALL.id); @@ -399,10 +350,87 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut }); registry.registerCommand(ArduinoCommands.TOGGLE_ADVANCED_MODE, { - execute: () => this.editorMode.toggle(), - isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right', - isToggled: () => this.editorMode.proMode + isToggled: () => this.editorMode.proMode, + execute: () => this.editorMode.toggleProMode() }); + registry.registerCommand(ArduinoCommands.TOGGLE_ADVANCED_MODE_TOOLBAR, { + isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right', + isToggled: () => this.editorMode.proMode, + execute: () => this.editorMode.toggleProMode() + }); + } + + protected async verify() { + const widget = this.getCurrentWidget(); + if (widget instanceof EditorWidget) { + await widget.saveable.save(); + } + + const uri = this.toUri(widget); + if (!uri) { + return; + } + + try { + const { boardsConfig } = this.boardsServiceClient; + if (!boardsConfig || !boardsConfig.selectedBoard) { + throw new Error('No boards selected. Please select a board.'); + } + if (!boardsConfig.selectedBoard.fqbn) { + throw new Error(`No core is installed for ${boardsConfig.selectedBoard.name}. Please install the board.`); + } + // Reveal the Output view asynchronously (don't await it) + this.outputContribution.openView({ reveal: true }); + await this.coreService.compile({ + uri: uri.toString(), + board: boardsConfig.selectedBoard, + optimizeForDebug: this.editorMode.compileForDebug + }); + } catch (e) { + await this.messageService.error(e.toString()); + } + } + + protected async upload() { + const widget = this.getCurrentWidget(); + if (widget instanceof EditorWidget) { + await widget.saveable.save(); + } + + const uri = this.toUri(widget); + if (!uri) { + return; + } + + const monitorConfig = this.monitorConnection.monitorConfig; + if (monitorConfig) { + await this.monitorConnection.disconnect(); + } + + try { + const { boardsConfig } = this.boardsServiceClient; + if (!boardsConfig || !boardsConfig.selectedBoard) { + throw new Error('No boards selected. Please select a board.'); + } + const { selectedPort } = boardsConfig; + if (!selectedPort) { + throw new Error('No ports selected. Please select a port.'); + } + // Reveal the Output view asynchronously (don't await it) + this.outputContribution.openView({ reveal: true }); + await this.coreService.upload({ + uri: uri.toString(), + board: boardsConfig.selectedBoard, + port: selectedPort.address, + optimizeForDebug: this.editorMode.compileForDebug + }); + } catch (e) { + await this.messageService.error(e.toString()); + } finally { + if (monitorConfig) { + await this.monitorConnection.connect(monitorConfig); + } + } } registerMenus(registry: MenuModelRegistry) { @@ -437,15 +465,20 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut } registry.registerSubmenu(ArduinoMenus.SKETCH, 'Sketch'); + registry.registerMenuAction(ArduinoMenus.SKETCH, { + commandId: ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG.id, + label: 'Optimize for Debugging', + order: '1' + }); registry.registerMenuAction(ArduinoMenus.SKETCH, { commandId: ArduinoCommands.VERIFY.id, label: 'Verify/Compile', - order: '1' + order: '2' }); registry.registerMenuAction(ArduinoMenus.SKETCH, { commandId: ArduinoCommands.UPLOAD.id, label: 'Upload', - order: '2' + order: '3' }); registry.registerMenuAction(ArduinoToolbarContextMenu.OPEN_GROUP, { commandId: ArduinoCommands.OPEN_FILE_NAVIGATOR.id, diff --git a/arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts b/arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts index d46b3f39..fa21e31d 100644 --- a/arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts +++ b/arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts @@ -23,6 +23,10 @@ export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendCont }); } + async initializeLayout(): Promise { + this.openView(); + } + registerMenus(menus: MenuModelRegistry): void { if (this.toggleCommand) { menus.registerMenuAction(ArduinoMenus.TOOLS, { diff --git a/arduino-ide-extension/src/browser/editor-mode.ts b/arduino-ide-extension/src/browser/editor-mode.ts index 872b4648..c697edd4 100644 --- a/arduino-ide-extension/src/browser/editor-mode.ts +++ b/arduino-ide-extension/src/browser/editor-mode.ts @@ -1,12 +1,17 @@ import { injectable } from 'inversify'; -import { ApplicationShell, FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser'; -import { ArduinoShellLayoutRestorer } from './shell/arduino-shell-layout-restorer'; +import { Emitter } from '@theia/core/lib/common/event'; +import { ApplicationShell, FrontendApplicationContribution, FrontendApplication, Widget } from '@theia/core/lib/browser'; import { OutputWidget } from '@theia/output/lib/browser/output-widget'; import { EditorWidget } from '@theia/editor/lib/browser'; +import { ArduinoShellLayoutRestorer } from './shell/arduino-shell-layout-restorer'; +import { BoardsListWidget } from './boards/boards-list-widget'; +import { LibraryListWidget } from './library/library-list-widget'; @injectable() export class EditorMode implements FrontendApplicationContribution { + readonly menuContentChanged = new Emitter(); + protected app: FrontendApplication; onStart(app: FrontendApplication): void { @@ -22,15 +27,15 @@ export class EditorMode implements FrontendApplicationContribution { return value === 'true'; } - async toggle(): Promise { + async toggleProMode(): Promise { const oldState = this.proMode; const inAdvancedMode = !oldState; window.localStorage.setItem(EditorMode.PRO_MODE_KEY, String(inAdvancedMode)); if (!inAdvancedMode) { const { shell } = this.app; - // Close all widget that is neither editor nor `Output`. + // Close all widgets that are neither editor nor `Output` / `Boards Manager` / `Library Manager`. for (const area of ['left', 'right', 'bottom', 'main'] as Array) { - shell.closeTabs(area, ({ owner }) => !(owner instanceof EditorWidget || owner instanceof OutputWidget)); + shell.closeTabs(area, title => !this.isInSimpleMode(title.owner)); } } // `storeLayout` has a sync API but the implementation is async, we store the layout manually before we reload the page. @@ -41,8 +46,27 @@ export class EditorMode implements FrontendApplicationContribution { window.location.reload(true); } + protected isInSimpleMode(widget: Widget): boolean { + return widget instanceof EditorWidget + || widget instanceof OutputWidget + || widget instanceof BoardsListWidget + || widget instanceof LibraryListWidget; + } + + get compileForDebug(): boolean { + const value = window.localStorage.getItem(EditorMode.COMPILE_FOR_DEBUG_KEY); + return value === 'true'; + } + + async toggleCompileForDebug(): Promise { + const oldState = this.compileForDebug; + const newState = !oldState; + window.localStorage.setItem(EditorMode.COMPILE_FOR_DEBUG_KEY, String(newState)); + } + } export namespace EditorMode { export const PRO_MODE_KEY = 'arduino-advanced-mode'; + export const COMPILE_FOR_DEBUG_KEY = 'arduino-compile-for-debug'; } diff --git a/arduino-ide-extension/src/browser/library/library-widget-frontend-contribution.ts b/arduino-ide-extension/src/browser/library/library-widget-frontend-contribution.ts index 349f0185..ed165c7a 100644 --- a/arduino-ide-extension/src/browser/library/library-widget-frontend-contribution.ts +++ b/arduino-ide-extension/src/browser/library/library-widget-frontend-contribution.ts @@ -14,20 +14,20 @@ export class LibraryListWidgetFrontendContribution extends AbstractViewContribut widgetName: LibraryListWidget.WIDGET_LABEL, defaultWidgetOptions: { area: 'left', - rank: 600 + rank: 700 }, toggleCommandId: `${LibraryListWidget.WIDGET_ID}:toggle`, toggleKeybinding: 'ctrlcmd+shift+l' }); } - initializeLayout(): void { - // NOOP + async initializeLayout(): Promise { + this.openView(); } registerMenus(menus: MenuModelRegistry): void { if (this.toggleCommand) { - menus.registerMenuAction(ArduinoMenus.SKETCH, { + menus.registerMenuAction(ArduinoMenus.TOOLS, { commandId: this.toggleCommand.id, label: 'Manage Libraries...' }); diff --git a/arduino-ide-extension/src/browser/monitor/monitor-view-contribution.tsx b/arduino-ide-extension/src/browser/monitor/monitor-view-contribution.tsx index 821de29f..343cb796 100644 --- a/arduino-ide-extension/src/browser/monitor/monitor-view-contribution.tsx +++ b/arduino-ide-extension/src/browser/monitor/monitor-view-contribution.tsx @@ -5,8 +5,8 @@ import { MonitorWidget } from "./monitor-widget"; import { MenuModelRegistry, Command, CommandRegistry } from "@theia/core"; import { ArduinoMenus } from "../arduino-frontend-contribution"; import { TabBarToolbarContribution, TabBarToolbarRegistry } from "@theia/core/lib/browser/shell/tab-bar-toolbar"; -import { MonitorModel } from './monitor-model'; import { ArduinoToolbar } from '../toolbar/arduino-toolbar'; +import { MonitorModel } from './monitor-model'; export namespace SerialMonitor { export namespace Commands { @@ -29,7 +29,8 @@ export namespace SerialMonitor { @injectable() export class MonitorViewContribution extends AbstractViewContribution implements TabBarToolbarContribution { - static readonly OPEN_SERIAL_MONITOR = MonitorWidget.ID + ':toggle'; + static readonly TOGGLE_SERIAL_MONITOR = MonitorWidget.ID + ':toggle'; + static readonly TOGGLE_SERIAL_MONITOR_TOOLBAR = MonitorWidget.ID + ':toggle-toolbar'; @inject(MonitorModel) protected readonly model: MonitorModel; @@ -40,7 +41,7 @@ export class MonitorViewContribution extends AbstractViewContribution this.openView({ toggle: true, activate: true - }), - isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right' + }) + }); + const toolbarCmd = { + id: MonitorViewContribution.TOGGLE_SERIAL_MONITOR_TOOLBAR + } + commands.registerCommand(toolbarCmd, { + isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right', + execute: () => this.openView({ + toggle: true, + activate: true + }) }); } } diff --git a/arduino-ide-extension/src/browser/toolbar/arduino-toolbar.tsx b/arduino-ide-extension/src/browser/toolbar/arduino-toolbar.tsx index 88a6ed3a..f9b6b5ab 100644 --- a/arduino-ide-extension/src/browser/toolbar/arduino-toolbar.tsx +++ b/arduino-ide-extension/src/browser/toolbar/arduino-toolbar.tsx @@ -91,7 +91,7 @@ export class ArduinoToolbar extends ReactWidget { protected updateItems(items: Array): void { this.items.clear(); - const revItems = items.reverse(); + const revItems = items.sort(TabBarToolbarItem.PRIORITY_COMPARATOR).reverse(); for (const item of revItems) { this.items.set(item.id, item); } diff --git a/arduino-ide-extension/src/common/protocol/boards-service.ts b/arduino-ide-extension/src/common/protocol/boards-service.ts index 2a786567..d7f0b631 100644 --- a/arduino-ide-extension/src/common/protocol/boards-service.ts +++ b/arduino-ide-extension/src/common/protocol/boards-service.ts @@ -2,6 +2,7 @@ import { isWindows, isOSX } from '@theia/core/lib/common/os'; import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; import { Searchable } from './searchable'; import { Installable } from './installable'; +import { Detailable } from './detailable'; import { ArduinoComponent } from './arduino-component'; const naturalCompare: (left: string, right: string) => number = require('string-natural-compare').caseInsensitive; @@ -59,7 +60,7 @@ export interface BoardsServiceClient { export const BoardsServicePath = '/services/boards-service'; export const BoardsService = Symbol('BoardsService'); -export interface BoardsService extends Installable, Searchable, JsonRpcServer { +export interface BoardsService extends Installable, Searchable, Detailable, JsonRpcServer { getAttachedBoards(): Promise<{ boards: Board[] }>; getAvailablePorts(): Promise<{ ports: Port[] }>; } @@ -181,6 +182,18 @@ export interface Board { fqbn?: string } +export interface BoardDetails extends Board { + fqbn: string; + + requiredTools: Tool[]; +} + +export interface Tool { + readonly packager: string; + readonly name: string; + readonly version: string; +} + export namespace Board { export function is(board: any): board is Board { diff --git a/arduino-ide-extension/src/common/protocol/core-service.ts b/arduino-ide-extension/src/common/protocol/core-service.ts index a6318b55..9b6b2b90 100644 --- a/arduino-ide-extension/src/common/protocol/core-service.ts +++ b/arduino-ide-extension/src/common/protocol/core-service.ts @@ -14,6 +14,7 @@ export namespace CoreService { readonly uri: string; readonly board: Board; readonly port: string; + readonly optimizeForDebug: boolean; } } @@ -21,6 +22,7 @@ export namespace CoreService { export interface Options { readonly uri: string; readonly board: Board; + readonly optimizeForDebug: boolean; } } -} \ No newline at end of file +} diff --git a/arduino-ide-extension/src/common/protocol/detailable.ts b/arduino-ide-extension/src/common/protocol/detailable.ts new file mode 100644 index 00000000..456dd626 --- /dev/null +++ b/arduino-ide-extension/src/common/protocol/detailable.ts @@ -0,0 +1,10 @@ + +export interface Detailable { + detail(options: Detailable.Options): Promise<{ item?: T }>; +} + +export namespace Detailable { + export interface Options { + readonly id: string; + } +} \ No newline at end of file diff --git a/arduino-ide-extension/src/electron-browser/electron-arduino-menu-contribution.ts b/arduino-ide-extension/src/electron-browser/electron-arduino-menu-contribution.ts index 4fce50ef..4559c6d7 100644 --- a/arduino-ide-extension/src/electron-browser/electron-arduino-menu-contribution.ts +++ b/arduino-ide-extension/src/electron-browser/electron-arduino-menu-contribution.ts @@ -1,9 +1,27 @@ -import { injectable } from 'inversify'; +import * as electron from 'electron'; +import { injectable, inject, postConstruct } from 'inversify'; +import { isOSX } from '@theia/core/lib/common/os'; import { ElectronMenuContribution } from '@theia/core/lib/electron-browser/menu/electron-menu-contribution'; +import { EditorMode } from '../browser/editor-mode'; @injectable() export class ElectronArduinoMenuContribution extends ElectronMenuContribution { + @inject(EditorMode) + protected readonly editorMode: EditorMode; + + @postConstruct() + protected init(): void { + this.editorMode.menuContentChanged.event(() => { + const createdMenuBar = this.factory.createMenuBar(); + if (isOSX) { + electron.remote.Menu.setApplicationMenu(createdMenuBar); + } else { + electron.remote.getCurrentWindow().setMenu(createdMenuBar); + } + }); + } + protected hideTopPanel(): void { // NOOP // We reuse the `div` for the Arduino toolbar. diff --git a/arduino-ide-extension/src/node/boards-service-impl.ts b/arduino-ide-extension/src/node/boards-service-impl.ts index a79af50f..e668d13f 100644 --- a/arduino-ide-extension/src/node/boards-service-impl.ts +++ b/arduino-ide-extension/src/node/boards-service-impl.ts @@ -2,20 +2,16 @@ import * as PQueue from 'p-queue'; import { injectable, inject, postConstruct, named } from 'inversify'; import { ILogger } from '@theia/core/lib/common/logger'; import { Deferred } from '@theia/core/lib/common/promise-util'; -import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, Port } from '../common/protocol/boards-service'; import { - PlatformSearchReq, - PlatformSearchResp, - PlatformInstallReq, - PlatformInstallResp, - PlatformListReq, - PlatformListResp, - Platform, - PlatformUninstallReq, - PlatformUninstallResp + BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, + Port, BoardDetails, Tool +} from '../common/protocol/boards-service'; +import { + PlatformSearchReq, PlatformSearchResp, PlatformInstallReq, PlatformInstallResp, PlatformListReq, + PlatformListResp, Platform, PlatformUninstallResp, PlatformUninstallReq } from './cli-protocol/commands/core_pb'; import { CoreClientProvider } from './core-client-provider'; -import { BoardListReq, BoardListResp } from './cli-protocol/commands/board_pb'; +import { BoardListReq, BoardListResp, BoardDetailsReq, BoardDetailsResp } from './cli-protocol/commands/board_pb'; import { ToolOutputServiceServer } from '../common/protocol/tool-output-service'; import { Installable } from '../common/protocol/installable'; @@ -215,6 +211,33 @@ export class BoardsServiceImpl implements BoardsService { }); } + async detail(options: { id: string }): Promise<{ item?: BoardDetails }> { + const coreClient = await this.coreClientProvider.getClient(); + if (!coreClient) { + return {}; + } + const { client, instance } = coreClient; + + const req = new BoardDetailsReq(); + req.setInstance(instance); + req.setFqbn(options.id); + const resp = await new Promise((resolve, reject) => client.boardDetails(req, (err, resp) => (!!err ? reject : resolve)(!!err ? err : resp))); + + const tools = await Promise.all(resp.getRequiredToolsList().map(async t => { + name: t.getName(), + packager: t.getPackager(), + version: t.getVersion() + })); + + return { + item: { + name: resp.getName(), + fqbn: options.id, + requiredTools: tools + } + }; + } + async search(options: { query?: string }): Promise<{ items: BoardPackage[] }> { const coreClient = await this.coreClientProvider.getClient(); if (!coreClient) { diff --git a/arduino-ide-extension/src/node/cli-protocol/commands/commands_grpc_pb.js b/arduino-ide-extension/src/node/cli-protocol/commands/commands_grpc_pb.js index 71be95be..615964a5 100644 --- a/arduino-ide-extension/src/node/cli-protocol/commands/commands_grpc_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/commands/commands_grpc_pb.js @@ -1,10 +1,9 @@ // GENERATED CODE -- DO NOT EDIT! // Original file comments: -// // This file is part of arduino-cli. // -// Copyright 2018 ARDUINO SA (http://www.arduino.cc/) +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) // // This software is released under the GNU General Public License version 3, // which covers the main part of arduino-cli. @@ -12,11 +11,10 @@ // https://www.gnu.org/licenses/gpl-3.0.en.html // // You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. // 'use strict'; var grpc = require('@grpc/grpc-js'); @@ -582,7 +580,7 @@ function deserialize_cc_arduino_cli_commands_VersionResp(buffer_arg) { // The main Arduino Platform Service var ArduinoCoreService = exports.ArduinoCoreService = { // Start a new instance of the Arduino Core Service - init: { +init: { path: '/cc.arduino.cli.commands.ArduinoCore/Init', requestStream: false, responseStream: true, @@ -594,7 +592,7 @@ var ArduinoCoreService = exports.ArduinoCoreService = { responseDeserialize: deserialize_cc_arduino_cli_commands_InitResp, }, // Destroy an instance of the Arduino Core Service - destroy: { +destroy: { path: '/cc.arduino.cli.commands.ArduinoCore/Destroy', requestStream: false, responseStream: false, @@ -606,7 +604,7 @@ var ArduinoCoreService = exports.ArduinoCoreService = { responseDeserialize: deserialize_cc_arduino_cli_commands_DestroyResp, }, // Rescan instance of the Arduino Core Service - rescan: { +rescan: { path: '/cc.arduino.cli.commands.ArduinoCore/Rescan', requestStream: false, responseStream: false, @@ -618,7 +616,7 @@ var ArduinoCoreService = exports.ArduinoCoreService = { responseDeserialize: deserialize_cc_arduino_cli_commands_RescanResp, }, // Update package index of the Arduino Core Service - updateIndex: { +updateIndex: { path: '/cc.arduino.cli.commands.ArduinoCore/UpdateIndex', requestStream: false, responseStream: true, @@ -630,7 +628,7 @@ var ArduinoCoreService = exports.ArduinoCoreService = { responseDeserialize: deserialize_cc_arduino_cli_commands_UpdateIndexResp, }, // Update libraries index - updateLibrariesIndex: { +updateLibrariesIndex: { path: '/cc.arduino.cli.commands.ArduinoCore/UpdateLibrariesIndex', requestStream: false, responseStream: true, @@ -653,10 +651,10 @@ var ArduinoCoreService = exports.ArduinoCoreService = { responseDeserialize: deserialize_cc_arduino_cli_commands_VersionResp, }, // BOARD COMMANDS - // -------------- - // - // Requests details about a board - boardDetails: { +// -------------- +// +// Requests details about a board +boardDetails: { path: '/cc.arduino.cli.commands.ArduinoCore/BoardDetails', requestStream: false, responseStream: false, diff --git a/arduino-ide-extension/src/node/cli-protocol/commands/commands_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/commands/commands_pb.d.ts index f012e4c6..c414a765 100644 --- a/arduino-ide-extension/src/node/cli-protocol/commands/commands_pb.d.ts +++ b/arduino-ide-extension/src/node/cli-protocol/commands/commands_pb.d.ts @@ -12,48 +12,7 @@ import * as commands_core_pb from "../commands/core_pb"; import * as commands_upload_pb from "../commands/upload_pb"; import * as commands_lib_pb from "../commands/lib_pb"; -export class Configuration extends jspb.Message { - getDatadir(): string; - setDatadir(value: string): void; - - getSketchbookdir(): string; - setSketchbookdir(value: string): void; - - getDownloadsdir(): string; - setDownloadsdir(value: string): void; - - clearBoardmanageradditionalurlsList(): void; - getBoardmanageradditionalurlsList(): Array; - setBoardmanageradditionalurlsList(value: Array): void; - addBoardmanageradditionalurls(value: string, index?: number): string; - - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Configuration.AsObject; - static toObject(includeInstance: boolean, msg: Configuration): Configuration.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Configuration, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Configuration; - static deserializeBinaryFromReader(message: Configuration, reader: jspb.BinaryReader): Configuration; -} - -export namespace Configuration { - export type AsObject = { - datadir: string, - sketchbookdir: string, - downloadsdir: string, - boardmanageradditionalurlsList: Array, - } -} - export class InitReq extends jspb.Message { - - hasConfiguration(): boolean; - clearConfiguration(): void; - getConfiguration(): Configuration | undefined; - setConfiguration(value?: Configuration): void; - getLibraryManagerOnly(): boolean; setLibraryManagerOnly(value: boolean): void; @@ -70,7 +29,6 @@ export class InitReq extends jspb.Message { export namespace InitReq { export type AsObject = { - configuration?: Configuration.AsObject, libraryManagerOnly: boolean, } } diff --git a/arduino-ide-extension/src/node/cli-protocol/commands/commands_pb.js b/arduino-ide-extension/src/node/cli-protocol/commands/commands_pb.js index 1fc0068b..16849da5 100644 --- a/arduino-ide-extension/src/node/cli-protocol/commands/commands_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/commands/commands_pb.js @@ -23,7 +23,6 @@ var commands_upload_pb = require('../commands/upload_pb.js'); goog.object.extend(proto, commands_upload_pb); var commands_lib_pb = require('../commands/lib_pb.js'); goog.object.extend(proto, commands_lib_pb); -goog.exportSymbol('proto.cc.arduino.cli.commands.Configuration', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.DestroyReq', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.DestroyResp', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.InitReq', null, global); @@ -37,250 +36,6 @@ goog.exportSymbol('proto.cc.arduino.cli.commands.UpdateLibrariesIndexResp', null goog.exportSymbol('proto.cc.arduino.cli.commands.VersionReq', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.VersionResp', null, global); -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.cc.arduino.cli.commands.Configuration = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.cc.arduino.cli.commands.Configuration.repeatedFields_, null); -}; -goog.inherits(proto.cc.arduino.cli.commands.Configuration, jspb.Message); -if (goog.DEBUG && !COMPILED) { - proto.cc.arduino.cli.commands.Configuration.displayName = 'proto.cc.arduino.cli.commands.Configuration'; -} -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.cc.arduino.cli.commands.Configuration.repeatedFields_ = [4]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto suitable for use in Soy templates. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. - * @param {boolean=} opt_includeInstance Whether to include the JSPB instance - * for transitional soy proto support: http://goto/soy-param-migration - * @return {!Object} - */ -proto.cc.arduino.cli.commands.Configuration.prototype.toObject = function(opt_includeInstance) { - return proto.cc.arduino.cli.commands.Configuration.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Whether to include the JSPB - * instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.cc.arduino.cli.commands.Configuration} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.cc.arduino.cli.commands.Configuration.toObject = function(includeInstance, msg) { - var f, obj = { - datadir: jspb.Message.getFieldWithDefault(msg, 1, ""), - sketchbookdir: jspb.Message.getFieldWithDefault(msg, 2, ""), - downloadsdir: jspb.Message.getFieldWithDefault(msg, 3, ""), - boardmanageradditionalurlsList: jspb.Message.getRepeatedField(msg, 4) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.cc.arduino.cli.commands.Configuration} - */ -proto.cc.arduino.cli.commands.Configuration.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.cc.arduino.cli.commands.Configuration; - return proto.cc.arduino.cli.commands.Configuration.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.cc.arduino.cli.commands.Configuration} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.cc.arduino.cli.commands.Configuration} - */ -proto.cc.arduino.cli.commands.Configuration.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setDatadir(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setSketchbookdir(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setDownloadsdir(value); - break; - case 4: - var value = /** @type {string} */ (reader.readString()); - msg.addBoardmanageradditionalurls(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.cc.arduino.cli.commands.Configuration.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.cc.arduino.cli.commands.Configuration.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.cc.arduino.cli.commands.Configuration} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.cc.arduino.cli.commands.Configuration.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getDatadir(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getSketchbookdir(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getDownloadsdir(); - if (f.length > 0) { - writer.writeString( - 3, - f - ); - } - f = message.getBoardmanageradditionalurlsList(); - if (f.length > 0) { - writer.writeRepeatedString( - 4, - f - ); - } -}; - - -/** - * optional string dataDir = 1; - * @return {string} - */ -proto.cc.arduino.cli.commands.Configuration.prototype.getDatadir = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** @param {string} value */ -proto.cc.arduino.cli.commands.Configuration.prototype.setDatadir = function(value) { - jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional string sketchbookDir = 2; - * @return {string} - */ -proto.cc.arduino.cli.commands.Configuration.prototype.getSketchbookdir = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** @param {string} value */ -proto.cc.arduino.cli.commands.Configuration.prototype.setSketchbookdir = function(value) { - jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional string downloadsDir = 3; - * @return {string} - */ -proto.cc.arduino.cli.commands.Configuration.prototype.getDownloadsdir = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); -}; - - -/** @param {string} value */ -proto.cc.arduino.cli.commands.Configuration.prototype.setDownloadsdir = function(value) { - jspb.Message.setProto3StringField(this, 3, value); -}; - - -/** - * repeated string boardManagerAdditionalUrls = 4; - * @return {!Array} - */ -proto.cc.arduino.cli.commands.Configuration.prototype.getBoardmanageradditionalurlsList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 4)); -}; - - -/** @param {!Array} value */ -proto.cc.arduino.cli.commands.Configuration.prototype.setBoardmanageradditionalurlsList = function(value) { - jspb.Message.setField(this, 4, value || []); -}; - - -/** - * @param {string} value - * @param {number=} opt_index - */ -proto.cc.arduino.cli.commands.Configuration.prototype.addBoardmanageradditionalurls = function(value, opt_index) { - jspb.Message.addToRepeatedField(this, 4, value, opt_index); -}; - - -proto.cc.arduino.cli.commands.Configuration.prototype.clearBoardmanageradditionalurlsList = function() { - this.setBoardmanageradditionalurlsList([]); -}; - - - /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -327,7 +82,6 @@ proto.cc.arduino.cli.commands.InitReq.prototype.toObject = function(opt_includeI */ proto.cc.arduino.cli.commands.InitReq.toObject = function(includeInstance, msg) { var f, obj = { - configuration: (f = msg.getConfiguration()) && proto.cc.arduino.cli.commands.Configuration.toObject(includeInstance, f), libraryManagerOnly: jspb.Message.getFieldWithDefault(msg, 2, false) }; @@ -365,11 +119,6 @@ proto.cc.arduino.cli.commands.InitReq.deserializeBinaryFromReader = function(msg } var field = reader.getFieldNumber(); switch (field) { - case 1: - var value = new proto.cc.arduino.cli.commands.Configuration; - reader.readMessage(value,proto.cc.arduino.cli.commands.Configuration.deserializeBinaryFromReader); - msg.setConfiguration(value); - break; case 2: var value = /** @type {boolean} */ (reader.readBool()); msg.setLibraryManagerOnly(value); @@ -403,14 +152,6 @@ proto.cc.arduino.cli.commands.InitReq.prototype.serializeBinary = function() { */ proto.cc.arduino.cli.commands.InitReq.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getConfiguration(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.cc.arduino.cli.commands.Configuration.serializeBinaryToWriter - ); - } f = message.getLibraryManagerOnly(); if (f) { writer.writeBool( @@ -421,36 +162,6 @@ proto.cc.arduino.cli.commands.InitReq.serializeBinaryToWriter = function(message }; -/** - * optional Configuration configuration = 1; - * @return {?proto.cc.arduino.cli.commands.Configuration} - */ -proto.cc.arduino.cli.commands.InitReq.prototype.getConfiguration = function() { - return /** @type{?proto.cc.arduino.cli.commands.Configuration} */ ( - jspb.Message.getWrapperField(this, proto.cc.arduino.cli.commands.Configuration, 1)); -}; - - -/** @param {?proto.cc.arduino.cli.commands.Configuration|undefined} value */ -proto.cc.arduino.cli.commands.InitReq.prototype.setConfiguration = function(value) { - jspb.Message.setWrapperField(this, 1, value); -}; - - -proto.cc.arduino.cli.commands.InitReq.prototype.clearConfiguration = function() { - this.setConfiguration(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.cc.arduino.cli.commands.InitReq.prototype.hasConfiguration = function() { - return jspb.Message.getField(this, 1) != null; -}; - - /** * optional bool library_manager_only = 2; * Note that Boolean fields may be set to 0/1 when serialized from a Java server. diff --git a/arduino-ide-extension/src/node/cli-protocol/commands/compile_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/commands/compile_pb.d.ts index 3045037d..6c1c79d5 100644 --- a/arduino-ide-extension/src/node/cli-protocol/commands/compile_pb.d.ts +++ b/arduino-ide-extension/src/node/cli-protocol/commands/compile_pb.d.ts @@ -55,6 +55,14 @@ export class CompileReq extends jspb.Message { getJobs(): number; setJobs(value: number): void; + clearLibrariesList(): void; + getLibrariesList(): Array; + setLibrariesList(value: Array): void; + addLibraries(value: string, index?: number): string; + + getOptimizefordebug(): boolean; + setOptimizefordebug(value: boolean): void; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): CompileReq.AsObject; @@ -82,6 +90,8 @@ export namespace CompileReq { vidpid: string, exportfile: string, jobs: number, + librariesList: Array, + optimizefordebug: boolean, } } diff --git a/arduino-ide-extension/src/node/cli-protocol/commands/compile_pb.js b/arduino-ide-extension/src/node/cli-protocol/commands/compile_pb.js index 1b3f213f..6563fd7d 100644 --- a/arduino-ide-extension/src/node/cli-protocol/commands/compile_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/commands/compile_pb.js @@ -38,7 +38,7 @@ if (goog.DEBUG && !COMPILED) { * @private {!Array} * @const */ -proto.cc.arduino.cli.commands.CompileReq.repeatedFields_ = [8]; +proto.cc.arduino.cli.commands.CompileReq.repeatedFields_ = [8,15]; @@ -82,7 +82,9 @@ proto.cc.arduino.cli.commands.CompileReq.toObject = function(includeInstance, ms quiet: jspb.Message.getFieldWithDefault(msg, 11, false), vidpid: jspb.Message.getFieldWithDefault(msg, 12, ""), exportfile: jspb.Message.getFieldWithDefault(msg, 13, ""), - jobs: jspb.Message.getFieldWithDefault(msg, 14, 0) + jobs: jspb.Message.getFieldWithDefault(msg, 14, 0), + librariesList: jspb.Message.getRepeatedField(msg, 15), + optimizefordebug: jspb.Message.getFieldWithDefault(msg, 16, false) }; if (includeInstance) { @@ -176,6 +178,14 @@ proto.cc.arduino.cli.commands.CompileReq.deserializeBinaryFromReader = function( var value = /** @type {number} */ (reader.readInt32()); msg.setJobs(value); break; + case 15: + var value = /** @type {string} */ (reader.readString()); + msg.addLibraries(value); + break; + case 16: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setOptimizefordebug(value); + break; default: reader.skipField(); break; @@ -304,6 +314,20 @@ proto.cc.arduino.cli.commands.CompileReq.serializeBinaryToWriter = function(mess f ); } + f = message.getLibrariesList(); + if (f.length > 0) { + writer.writeRepeatedString( + 15, + f + ); + } + f = message.getOptimizefordebug(); + if (f) { + writer.writeBool( + 16, + f + ); + } }; @@ -554,6 +578,52 @@ proto.cc.arduino.cli.commands.CompileReq.prototype.setJobs = function(value) { }; +/** + * repeated string libraries = 15; + * @return {!Array} + */ +proto.cc.arduino.cli.commands.CompileReq.prototype.getLibrariesList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 15)); +}; + + +/** @param {!Array} value */ +proto.cc.arduino.cli.commands.CompileReq.prototype.setLibrariesList = function(value) { + jspb.Message.setField(this, 15, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + */ +proto.cc.arduino.cli.commands.CompileReq.prototype.addLibraries = function(value, opt_index) { + jspb.Message.addToRepeatedField(this, 15, value, opt_index); +}; + + +proto.cc.arduino.cli.commands.CompileReq.prototype.clearLibrariesList = function() { + this.setLibrariesList([]); +}; + + +/** + * optional bool optimizeForDebug = 16; + * Note that Boolean fields may be set to 0/1 when serialized from a Java server. + * You should avoid comparisons like {@code val === true/false} in those cases. + * @return {boolean} + */ +proto.cc.arduino.cli.commands.CompileReq.prototype.getOptimizefordebug = function() { + return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 16, false)); +}; + + +/** @param {boolean} value */ +proto.cc.arduino.cli.commands.CompileReq.prototype.setOptimizefordebug = function(value) { + jspb.Message.setProto3BooleanField(this, 16, value); +}; + + /** * Generated by JsPbCodeGenerator. diff --git a/arduino-ide-extension/src/node/cli-protocol/debug/debug_grpc_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/debug/debug_grpc_pb.d.ts new file mode 100644 index 00000000..8df745f1 --- /dev/null +++ b/arduino-ide-extension/src/node/cli-protocol/debug/debug_grpc_pb.d.ts @@ -0,0 +1,40 @@ +// package: cc.arduino.cli.debug +// file: debug/debug.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "@grpc/grpc-js"; +import * as debug_debug_pb from "../debug/debug_pb"; + +interface IDebugService extends grpc.ServiceDefinition { + debug: IDebugService_IDebug; +} + +interface IDebugService_IDebug extends grpc.MethodDefinition { + path: string; // "/cc.arduino.cli.debug.Debug/Debug" + requestStream: boolean; // true + responseStream: boolean; // true + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const DebugService: IDebugService; + +export interface IDebugServer { + debug: grpc.handleBidiStreamingCall; +} + +export interface IDebugClient { + debug(): grpc.ClientDuplexStream; + debug(options: Partial): grpc.ClientDuplexStream; + debug(metadata: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; +} + +export class DebugClient extends grpc.Client implements IDebugClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); + public debug(options?: Partial): grpc.ClientDuplexStream; + public debug(metadata?: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; +} diff --git a/arduino-ide-extension/src/node/cli-protocol/debug/debug_grpc_pb.js b/arduino-ide-extension/src/node/cli-protocol/debug/debug_grpc_pb.js new file mode 100644 index 00000000..9dd14a05 --- /dev/null +++ b/arduino-ide-extension/src/node/cli-protocol/debug/debug_grpc_pb.js @@ -0,0 +1,61 @@ +// GENERATED CODE -- DO NOT EDIT! + +// Original file comments: +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. +// +'use strict'; +var grpc = require('@grpc/grpc-js'); +var debug_debug_pb = require('../debug/debug_pb.js'); + +function serialize_cc_arduino_cli_debug_DebugReq(arg) { + if (!(arg instanceof debug_debug_pb.DebugReq)) { + throw new Error('Expected argument of type cc.arduino.cli.debug.DebugReq'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_cc_arduino_cli_debug_DebugReq(buffer_arg) { + return debug_debug_pb.DebugReq.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_cc_arduino_cli_debug_DebugResp(arg) { + if (!(arg instanceof debug_debug_pb.DebugResp)) { + throw new Error('Expected argument of type cc.arduino.cli.debug.DebugResp'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_cc_arduino_cli_debug_DebugResp(buffer_arg) { + return debug_debug_pb.DebugResp.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +// Service that abstract a debug Session usage +var DebugService = exports.DebugService = { + debug: { + path: '/cc.arduino.cli.debug.Debug/Debug', + requestStream: true, + responseStream: true, + requestType: debug_debug_pb.DebugReq, + responseType: debug_debug_pb.DebugResp, + requestSerialize: serialize_cc_arduino_cli_debug_DebugReq, + requestDeserialize: deserialize_cc_arduino_cli_debug_DebugReq, + responseSerialize: serialize_cc_arduino_cli_debug_DebugResp, + responseDeserialize: deserialize_cc_arduino_cli_debug_DebugResp, + }, +}; + +exports.DebugClient = grpc.makeGenericClientConstructor(DebugService); diff --git a/arduino-ide-extension/src/node/cli-protocol/debug/debug_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/debug/debug_pb.d.ts new file mode 100644 index 00000000..98e4aaf1 --- /dev/null +++ b/arduino-ide-extension/src/node/cli-protocol/debug/debug_pb.d.ts @@ -0,0 +1,129 @@ +// package: cc.arduino.cli.debug +// file: debug/debug.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; + +export class DebugReq extends jspb.Message { + + hasDebugreq(): boolean; + clearDebugreq(): void; + getDebugreq(): DebugConfigReq | undefined; + setDebugreq(value?: DebugConfigReq): void; + + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DebugReq.AsObject; + static toObject(includeInstance: boolean, msg: DebugReq): DebugReq.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DebugReq, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DebugReq; + static deserializeBinaryFromReader(message: DebugReq, reader: jspb.BinaryReader): DebugReq; +} + +export namespace DebugReq { + export type AsObject = { + debugreq?: DebugConfigReq.AsObject, + data: Uint8Array | string, + } +} + +export class DebugConfigReq extends jspb.Message { + + hasInstance(): boolean; + clearInstance(): void; + getInstance(): Instance | undefined; + setInstance(value?: Instance): void; + + getFqbn(): string; + setFqbn(value: string): void; + + getSketchPath(): string; + setSketchPath(value: string): void; + + getPort(): string; + setPort(value: string): void; + + getVerbose(): boolean; + setVerbose(value: boolean): void; + + getImportFile(): string; + setImportFile(value: string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DebugConfigReq.AsObject; + static toObject(includeInstance: boolean, msg: DebugConfigReq): DebugConfigReq.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DebugConfigReq, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DebugConfigReq; + static deserializeBinaryFromReader(message: DebugConfigReq, reader: jspb.BinaryReader): DebugConfigReq; +} + +export namespace DebugConfigReq { + export type AsObject = { + instance?: Instance.AsObject, + fqbn: string, + sketchPath: string, + port: string, + verbose: boolean, + importFile: string, + } +} + +export class DebugResp extends jspb.Message { + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): void; + + getError(): string; + setError(value: string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DebugResp.AsObject; + static toObject(includeInstance: boolean, msg: DebugResp): DebugResp.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DebugResp, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DebugResp; + static deserializeBinaryFromReader(message: DebugResp, reader: jspb.BinaryReader): DebugResp; +} + +export namespace DebugResp { + export type AsObject = { + data: Uint8Array | string, + error: string, + } +} + +export class Instance extends jspb.Message { + getId(): number; + setId(value: number): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Instance.AsObject; + static toObject(includeInstance: boolean, msg: Instance): Instance.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Instance, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Instance; + static deserializeBinaryFromReader(message: Instance, reader: jspb.BinaryReader): Instance; +} + +export namespace Instance { + export type AsObject = { + id: number, + } +} diff --git a/arduino-ide-extension/src/node/cli-protocol/debug/debug_pb.js b/arduino-ide-extension/src/node/cli-protocol/debug/debug_pb.js new file mode 100644 index 00000000..c2b7d41d --- /dev/null +++ b/arduino-ide-extension/src/node/cli-protocol/debug/debug_pb.js @@ -0,0 +1,859 @@ +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +goog.exportSymbol('proto.cc.arduino.cli.debug.DebugConfigReq', null, global); +goog.exportSymbol('proto.cc.arduino.cli.debug.DebugReq', null, global); +goog.exportSymbol('proto.cc.arduino.cli.debug.DebugResp', null, global); +goog.exportSymbol('proto.cc.arduino.cli.debug.Instance', null, global); + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.debug.DebugReq = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.debug.DebugReq, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.debug.DebugReq.displayName = 'proto.cc.arduino.cli.debug.DebugReq'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.debug.DebugReq.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.debug.DebugReq.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.debug.DebugReq} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.debug.DebugReq.toObject = function(includeInstance, msg) { + var f, obj = { + debugreq: (f = msg.getDebugreq()) && proto.cc.arduino.cli.debug.DebugConfigReq.toObject(includeInstance, f), + data: msg.getData_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.debug.DebugReq} + */ +proto.cc.arduino.cli.debug.DebugReq.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.debug.DebugReq; + return proto.cc.arduino.cli.debug.DebugReq.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.debug.DebugReq} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.debug.DebugReq} + */ +proto.cc.arduino.cli.debug.DebugReq.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.cc.arduino.cli.debug.DebugConfigReq; + reader.readMessage(value,proto.cc.arduino.cli.debug.DebugConfigReq.deserializeBinaryFromReader); + msg.setDebugreq(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.debug.DebugReq.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.debug.DebugReq.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.debug.DebugReq} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.debug.DebugReq.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDebugreq(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.cc.arduino.cli.debug.DebugConfigReq.serializeBinaryToWriter + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } +}; + + +/** + * optional DebugConfigReq debugReq = 1; + * @return {?proto.cc.arduino.cli.debug.DebugConfigReq} + */ +proto.cc.arduino.cli.debug.DebugReq.prototype.getDebugreq = function() { + return /** @type{?proto.cc.arduino.cli.debug.DebugConfigReq} */ ( + jspb.Message.getWrapperField(this, proto.cc.arduino.cli.debug.DebugConfigReq, 1)); +}; + + +/** @param {?proto.cc.arduino.cli.debug.DebugConfigReq|undefined} value */ +proto.cc.arduino.cli.debug.DebugReq.prototype.setDebugreq = function(value) { + jspb.Message.setWrapperField(this, 1, value); +}; + + +proto.cc.arduino.cli.debug.DebugReq.prototype.clearDebugreq = function() { + this.setDebugreq(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.cc.arduino.cli.debug.DebugReq.prototype.hasDebugreq = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional bytes data = 2; + * @return {!(string|Uint8Array)} + */ +proto.cc.arduino.cli.debug.DebugReq.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes data = 2; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.cc.arduino.cli.debug.DebugReq.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.debug.DebugReq.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** @param {!(string|Uint8Array)} value */ +proto.cc.arduino.cli.debug.DebugReq.prototype.setData = function(value) { + jspb.Message.setProto3BytesField(this, 2, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.debug.DebugConfigReq = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.debug.DebugConfigReq, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.debug.DebugConfigReq.displayName = 'proto.cc.arduino.cli.debug.DebugConfigReq'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.debug.DebugConfigReq.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.debug.DebugConfigReq} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.debug.DebugConfigReq.toObject = function(includeInstance, msg) { + var f, obj = { + instance: (f = msg.getInstance()) && proto.cc.arduino.cli.debug.Instance.toObject(includeInstance, f), + fqbn: jspb.Message.getFieldWithDefault(msg, 2, ""), + sketchPath: jspb.Message.getFieldWithDefault(msg, 3, ""), + port: jspb.Message.getFieldWithDefault(msg, 4, ""), + verbose: jspb.Message.getFieldWithDefault(msg, 5, false), + importFile: jspb.Message.getFieldWithDefault(msg, 7, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.debug.DebugConfigReq} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.debug.DebugConfigReq; + return proto.cc.arduino.cli.debug.DebugConfigReq.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.debug.DebugConfigReq} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.debug.DebugConfigReq} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.cc.arduino.cli.debug.Instance; + reader.readMessage(value,proto.cc.arduino.cli.debug.Instance.deserializeBinaryFromReader); + msg.setInstance(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setFqbn(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setSketchPath(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setPort(value); + break; + case 5: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setVerbose(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setImportFile(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.debug.DebugConfigReq.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.debug.DebugConfigReq} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.debug.DebugConfigReq.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getInstance(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.cc.arduino.cli.debug.Instance.serializeBinaryToWriter + ); + } + f = message.getFqbn(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getSketchPath(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getPort(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getVerbose(); + if (f) { + writer.writeBool( + 5, + f + ); + } + f = message.getImportFile(); + if (f.length > 0) { + writer.writeString( + 7, + f + ); + } +}; + + +/** + * optional Instance instance = 1; + * @return {?proto.cc.arduino.cli.debug.Instance} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.getInstance = function() { + return /** @type{?proto.cc.arduino.cli.debug.Instance} */ ( + jspb.Message.getWrapperField(this, proto.cc.arduino.cli.debug.Instance, 1)); +}; + + +/** @param {?proto.cc.arduino.cli.debug.Instance|undefined} value */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.setInstance = function(value) { + jspb.Message.setWrapperField(this, 1, value); +}; + + +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.clearInstance = function() { + this.setInstance(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.hasInstance = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string fqbn = 2; + * @return {string} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.getFqbn = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.setFqbn = function(value) { + jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string sketch_path = 3; + * @return {string} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.getSketchPath = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.setSketchPath = function(value) { + jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string port = 4; + * @return {string} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.getPort = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.setPort = function(value) { + jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * optional bool verbose = 5; + * Note that Boolean fields may be set to 0/1 when serialized from a Java server. + * You should avoid comparisons like {@code val === true/false} in those cases. + * @return {boolean} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.getVerbose = function() { + return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 5, false)); +}; + + +/** @param {boolean} value */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.setVerbose = function(value) { + jspb.Message.setProto3BooleanField(this, 5, value); +}; + + +/** + * optional string import_file = 7; + * @return {string} + */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.getImportFile = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.debug.DebugConfigReq.prototype.setImportFile = function(value) { + jspb.Message.setProto3StringField(this, 7, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.debug.DebugResp = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.debug.DebugResp, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.debug.DebugResp.displayName = 'proto.cc.arduino.cli.debug.DebugResp'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.debug.DebugResp.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.debug.DebugResp.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.debug.DebugResp} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.debug.DebugResp.toObject = function(includeInstance, msg) { + var f, obj = { + data: msg.getData_asB64(), + error: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.debug.DebugResp} + */ +proto.cc.arduino.cli.debug.DebugResp.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.debug.DebugResp; + return proto.cc.arduino.cli.debug.DebugResp.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.debug.DebugResp} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.debug.DebugResp} + */ +proto.cc.arduino.cli.debug.DebugResp.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setError(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.debug.DebugResp.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.debug.DebugResp.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.debug.DebugResp} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.debug.DebugResp.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getError(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional bytes data = 1; + * @return {!(string|Uint8Array)} + */ +proto.cc.arduino.cli.debug.DebugResp.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes data = 1; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.cc.arduino.cli.debug.DebugResp.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.debug.DebugResp.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** @param {!(string|Uint8Array)} value */ +proto.cc.arduino.cli.debug.DebugResp.prototype.setData = function(value) { + jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional string error = 2; + * @return {string} + */ +proto.cc.arduino.cli.debug.DebugResp.prototype.getError = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.debug.DebugResp.prototype.setError = function(value) { + jspb.Message.setProto3StringField(this, 2, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.debug.Instance = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.debug.Instance, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.debug.Instance.displayName = 'proto.cc.arduino.cli.debug.Instance'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.debug.Instance.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.debug.Instance.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.debug.Instance} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.debug.Instance.toObject = function(includeInstance, msg) { + var f, obj = { + id: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.debug.Instance} + */ +proto.cc.arduino.cli.debug.Instance.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.debug.Instance; + return proto.cc.arduino.cli.debug.Instance.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.debug.Instance} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.debug.Instance} + */ +proto.cc.arduino.cli.debug.Instance.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.debug.Instance.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.debug.Instance.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.debug.Instance} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.debug.Instance.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId(); + if (f !== 0) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 id = 1; + * @return {number} + */ +proto.cc.arduino.cli.debug.Instance.prototype.getId = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** @param {number} value */ +proto.cc.arduino.cli.debug.Instance.prototype.setId = function(value) { + jspb.Message.setProto3IntField(this, 1, value); +}; + + +goog.object.extend(exports, proto.cc.arduino.cli.debug); diff --git a/arduino-ide-extension/src/node/cli-protocol/monitor/monitor_grpc_pb.js b/arduino-ide-extension/src/node/cli-protocol/monitor/monitor_grpc_pb.js index 6caca263..c9821121 100644 --- a/arduino-ide-extension/src/node/cli-protocol/monitor/monitor_grpc_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/monitor/monitor_grpc_pb.js @@ -3,7 +3,7 @@ // Original file comments: // This file is part of arduino-cli. // -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) // // This software is released under the GNU General Public License version 3, // which covers the main part of arduino-cli. diff --git a/arduino-ide-extension/src/node/cli-protocol/settings/settings_grpc_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/settings/settings_grpc_pb.d.ts new file mode 100644 index 00000000..0c251539 --- /dev/null +++ b/arduino-ide-extension/src/node/cli-protocol/settings/settings_grpc_pb.d.ts @@ -0,0 +1,92 @@ +// package: cc.arduino.cli.settings +// file: settings/settings.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "@grpc/grpc-js"; +import * as settings_settings_pb from "../settings/settings_pb"; + +interface ISettingsService extends grpc.ServiceDefinition { + getAll: ISettingsService_IGetAll; + merge: ISettingsService_IMerge; + getValue: ISettingsService_IGetValue; + setValue: ISettingsService_ISetValue; +} + +interface ISettingsService_IGetAll extends grpc.MethodDefinition { + path: string; // "/cc.arduino.cli.settings.Settings/GetAll" + requestStream: boolean; // false + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface ISettingsService_IMerge extends grpc.MethodDefinition { + path: string; // "/cc.arduino.cli.settings.Settings/Merge" + requestStream: boolean; // false + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface ISettingsService_IGetValue extends grpc.MethodDefinition { + path: string; // "/cc.arduino.cli.settings.Settings/GetValue" + requestStream: boolean; // false + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface ISettingsService_ISetValue extends grpc.MethodDefinition { + path: string; // "/cc.arduino.cli.settings.Settings/SetValue" + requestStream: boolean; // false + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const SettingsService: ISettingsService; + +export interface ISettingsServer { + getAll: grpc.handleUnaryCall; + merge: grpc.handleUnaryCall; + getValue: grpc.handleUnaryCall; + setValue: grpc.handleUnaryCall; +} + +export interface ISettingsClient { + getAll(request: settings_settings_pb.GetAllRequest, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.RawData) => void): grpc.ClientUnaryCall; + getAll(request: settings_settings_pb.GetAllRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.RawData) => void): grpc.ClientUnaryCall; + getAll(request: settings_settings_pb.GetAllRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.RawData) => void): grpc.ClientUnaryCall; + merge(request: settings_settings_pb.RawData, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.MergeResponse) => void): grpc.ClientUnaryCall; + merge(request: settings_settings_pb.RawData, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.MergeResponse) => void): grpc.ClientUnaryCall; + merge(request: settings_settings_pb.RawData, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.MergeResponse) => void): grpc.ClientUnaryCall; + getValue(request: settings_settings_pb.GetValueRequest, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.Value) => void): grpc.ClientUnaryCall; + getValue(request: settings_settings_pb.GetValueRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.Value) => void): grpc.ClientUnaryCall; + getValue(request: settings_settings_pb.GetValueRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.Value) => void): grpc.ClientUnaryCall; + setValue(request: settings_settings_pb.Value, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.SetValueResponse) => void): grpc.ClientUnaryCall; + setValue(request: settings_settings_pb.Value, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.SetValueResponse) => void): grpc.ClientUnaryCall; + setValue(request: settings_settings_pb.Value, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.SetValueResponse) => void): grpc.ClientUnaryCall; +} + +export class SettingsClient extends grpc.Client implements ISettingsClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); + public getAll(request: settings_settings_pb.GetAllRequest, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.RawData) => void): grpc.ClientUnaryCall; + public getAll(request: settings_settings_pb.GetAllRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.RawData) => void): grpc.ClientUnaryCall; + public getAll(request: settings_settings_pb.GetAllRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.RawData) => void): grpc.ClientUnaryCall; + public merge(request: settings_settings_pb.RawData, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.MergeResponse) => void): grpc.ClientUnaryCall; + public merge(request: settings_settings_pb.RawData, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.MergeResponse) => void): grpc.ClientUnaryCall; + public merge(request: settings_settings_pb.RawData, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.MergeResponse) => void): grpc.ClientUnaryCall; + public getValue(request: settings_settings_pb.GetValueRequest, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.Value) => void): grpc.ClientUnaryCall; + public getValue(request: settings_settings_pb.GetValueRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.Value) => void): grpc.ClientUnaryCall; + public getValue(request: settings_settings_pb.GetValueRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.Value) => void): grpc.ClientUnaryCall; + public setValue(request: settings_settings_pb.Value, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.SetValueResponse) => void): grpc.ClientUnaryCall; + public setValue(request: settings_settings_pb.Value, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.SetValueResponse) => void): grpc.ClientUnaryCall; + public setValue(request: settings_settings_pb.Value, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: settings_settings_pb.SetValueResponse) => void): grpc.ClientUnaryCall; +} diff --git a/arduino-ide-extension/src/node/cli-protocol/settings/settings_grpc_pb.js b/arduino-ide-extension/src/node/cli-protocol/settings/settings_grpc_pb.js new file mode 100644 index 00000000..0e42e729 --- /dev/null +++ b/arduino-ide-extension/src/node/cli-protocol/settings/settings_grpc_pb.js @@ -0,0 +1,137 @@ +// GENERATED CODE -- DO NOT EDIT! + +// Original file comments: +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. +// +'use strict'; +var grpc = require('@grpc/grpc-js'); +var settings_settings_pb = require('../settings/settings_pb.js'); + +function serialize_cc_arduino_cli_settings_GetAllRequest(arg) { + if (!(arg instanceof settings_settings_pb.GetAllRequest)) { + throw new Error('Expected argument of type cc.arduino.cli.settings.GetAllRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_cc_arduino_cli_settings_GetAllRequest(buffer_arg) { + return settings_settings_pb.GetAllRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_cc_arduino_cli_settings_GetValueRequest(arg) { + if (!(arg instanceof settings_settings_pb.GetValueRequest)) { + throw new Error('Expected argument of type cc.arduino.cli.settings.GetValueRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_cc_arduino_cli_settings_GetValueRequest(buffer_arg) { + return settings_settings_pb.GetValueRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_cc_arduino_cli_settings_MergeResponse(arg) { + if (!(arg instanceof settings_settings_pb.MergeResponse)) { + throw new Error('Expected argument of type cc.arduino.cli.settings.MergeResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_cc_arduino_cli_settings_MergeResponse(buffer_arg) { + return settings_settings_pb.MergeResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_cc_arduino_cli_settings_RawData(arg) { + if (!(arg instanceof settings_settings_pb.RawData)) { + throw new Error('Expected argument of type cc.arduino.cli.settings.RawData'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_cc_arduino_cli_settings_RawData(buffer_arg) { + return settings_settings_pb.RawData.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_cc_arduino_cli_settings_SetValueResponse(arg) { + if (!(arg instanceof settings_settings_pb.SetValueResponse)) { + throw new Error('Expected argument of type cc.arduino.cli.settings.SetValueResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_cc_arduino_cli_settings_SetValueResponse(buffer_arg) { + return settings_settings_pb.SetValueResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_cc_arduino_cli_settings_Value(arg) { + if (!(arg instanceof settings_settings_pb.Value)) { + throw new Error('Expected argument of type cc.arduino.cli.settings.Value'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_cc_arduino_cli_settings_Value(buffer_arg) { + return settings_settings_pb.Value.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +var SettingsService = exports.SettingsService = { + getAll: { + path: '/cc.arduino.cli.settings.Settings/GetAll', + requestStream: false, + responseStream: false, + requestType: settings_settings_pb.GetAllRequest, + responseType: settings_settings_pb.RawData, + requestSerialize: serialize_cc_arduino_cli_settings_GetAllRequest, + requestDeserialize: deserialize_cc_arduino_cli_settings_GetAllRequest, + responseSerialize: serialize_cc_arduino_cli_settings_RawData, + responseDeserialize: deserialize_cc_arduino_cli_settings_RawData, + }, + merge: { + path: '/cc.arduino.cli.settings.Settings/Merge', + requestStream: false, + responseStream: false, + requestType: settings_settings_pb.RawData, + responseType: settings_settings_pb.MergeResponse, + requestSerialize: serialize_cc_arduino_cli_settings_RawData, + requestDeserialize: deserialize_cc_arduino_cli_settings_RawData, + responseSerialize: serialize_cc_arduino_cli_settings_MergeResponse, + responseDeserialize: deserialize_cc_arduino_cli_settings_MergeResponse, + }, + getValue: { + path: '/cc.arduino.cli.settings.Settings/GetValue', + requestStream: false, + responseStream: false, + requestType: settings_settings_pb.GetValueRequest, + responseType: settings_settings_pb.Value, + requestSerialize: serialize_cc_arduino_cli_settings_GetValueRequest, + requestDeserialize: deserialize_cc_arduino_cli_settings_GetValueRequest, + responseSerialize: serialize_cc_arduino_cli_settings_Value, + responseDeserialize: deserialize_cc_arduino_cli_settings_Value, + }, + setValue: { + path: '/cc.arduino.cli.settings.Settings/SetValue', + requestStream: false, + responseStream: false, + requestType: settings_settings_pb.Value, + responseType: settings_settings_pb.SetValueResponse, + requestSerialize: serialize_cc_arduino_cli_settings_Value, + requestDeserialize: deserialize_cc_arduino_cli_settings_Value, + responseSerialize: serialize_cc_arduino_cli_settings_SetValueResponse, + responseDeserialize: deserialize_cc_arduino_cli_settings_SetValueResponse, + }, +}; + +exports.SettingsClient = grpc.makeGenericClientConstructor(SettingsService); diff --git a/arduino-ide-extension/src/node/cli-protocol/settings/settings_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/settings/settings_pb.d.ts new file mode 100644 index 00000000..e5278795 --- /dev/null +++ b/arduino-ide-extension/src/node/cli-protocol/settings/settings_pb.d.ts @@ -0,0 +1,125 @@ +// package: cc.arduino.cli.settings +// file: settings/settings.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; + +export class RawData extends jspb.Message { + getJsondata(): string; + setJsondata(value: string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): RawData.AsObject; + static toObject(includeInstance: boolean, msg: RawData): RawData.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: RawData, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): RawData; + static deserializeBinaryFromReader(message: RawData, reader: jspb.BinaryReader): RawData; +} + +export namespace RawData { + export type AsObject = { + jsondata: string, + } +} + +export class Value extends jspb.Message { + getKey(): string; + setKey(value: string): void; + + getJsondata(): string; + setJsondata(value: string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Value.AsObject; + static toObject(includeInstance: boolean, msg: Value): Value.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Value, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Value; + static deserializeBinaryFromReader(message: Value, reader: jspb.BinaryReader): Value; +} + +export namespace Value { + export type AsObject = { + key: string, + jsondata: string, + } +} + +export class GetAllRequest extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetAllRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetAllRequest): GetAllRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetAllRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetAllRequest; + static deserializeBinaryFromReader(message: GetAllRequest, reader: jspb.BinaryReader): GetAllRequest; +} + +export namespace GetAllRequest { + export type AsObject = { + } +} + +export class GetValueRequest extends jspb.Message { + getKey(): string; + setKey(value: string): void; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetValueRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetValueRequest): GetValueRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetValueRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetValueRequest; + static deserializeBinaryFromReader(message: GetValueRequest, reader: jspb.BinaryReader): GetValueRequest; +} + +export namespace GetValueRequest { + export type AsObject = { + key: string, + } +} + +export class MergeResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): MergeResponse.AsObject; + static toObject(includeInstance: boolean, msg: MergeResponse): MergeResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: MergeResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): MergeResponse; + static deserializeBinaryFromReader(message: MergeResponse, reader: jspb.BinaryReader): MergeResponse; +} + +export namespace MergeResponse { + export type AsObject = { + } +} + +export class SetValueResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SetValueResponse.AsObject; + static toObject(includeInstance: boolean, msg: SetValueResponse): SetValueResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SetValueResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SetValueResponse; + static deserializeBinaryFromReader(message: SetValueResponse, reader: jspb.BinaryReader): SetValueResponse; +} + +export namespace SetValueResponse { + export type AsObject = { + } +} diff --git a/arduino-ide-extension/src/node/cli-protocol/settings/settings_pb.js b/arduino-ide-extension/src/node/cli-protocol/settings/settings_pb.js new file mode 100644 index 00000000..dd356474 --- /dev/null +++ b/arduino-ide-extension/src/node/cli-protocol/settings/settings_pb.js @@ -0,0 +1,821 @@ +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +goog.exportSymbol('proto.cc.arduino.cli.settings.GetAllRequest', null, global); +goog.exportSymbol('proto.cc.arduino.cli.settings.GetValueRequest', null, global); +goog.exportSymbol('proto.cc.arduino.cli.settings.MergeResponse', null, global); +goog.exportSymbol('proto.cc.arduino.cli.settings.RawData', null, global); +goog.exportSymbol('proto.cc.arduino.cli.settings.SetValueResponse', null, global); +goog.exportSymbol('proto.cc.arduino.cli.settings.Value', null, global); + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.settings.RawData = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.settings.RawData, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.settings.RawData.displayName = 'proto.cc.arduino.cli.settings.RawData'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.settings.RawData.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.settings.RawData.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.settings.RawData} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.RawData.toObject = function(includeInstance, msg) { + var f, obj = { + jsondata: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.settings.RawData} + */ +proto.cc.arduino.cli.settings.RawData.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.settings.RawData; + return proto.cc.arduino.cli.settings.RawData.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.settings.RawData} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.settings.RawData} + */ +proto.cc.arduino.cli.settings.RawData.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setJsondata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.settings.RawData.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.settings.RawData.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.settings.RawData} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.RawData.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getJsondata(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string jsonData = 1; + * @return {string} + */ +proto.cc.arduino.cli.settings.RawData.prototype.getJsondata = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.settings.RawData.prototype.setJsondata = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.settings.Value = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.settings.Value, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.settings.Value.displayName = 'proto.cc.arduino.cli.settings.Value'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.settings.Value.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.settings.Value.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.settings.Value} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.Value.toObject = function(includeInstance, msg) { + var f, obj = { + key: jspb.Message.getFieldWithDefault(msg, 1, ""), + jsondata: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.settings.Value} + */ +proto.cc.arduino.cli.settings.Value.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.settings.Value; + return proto.cc.arduino.cli.settings.Value.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.settings.Value} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.settings.Value} + */ +proto.cc.arduino.cli.settings.Value.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setKey(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setJsondata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.settings.Value.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.settings.Value.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.settings.Value} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.Value.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getKey(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getJsondata(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional string key = 1; + * @return {string} + */ +proto.cc.arduino.cli.settings.Value.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.settings.Value.prototype.setKey = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string jsonData = 2; + * @return {string} + */ +proto.cc.arduino.cli.settings.Value.prototype.getJsondata = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.settings.Value.prototype.setJsondata = function(value) { + jspb.Message.setProto3StringField(this, 2, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.settings.GetAllRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.settings.GetAllRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.settings.GetAllRequest.displayName = 'proto.cc.arduino.cli.settings.GetAllRequest'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.settings.GetAllRequest.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.settings.GetAllRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.settings.GetAllRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.GetAllRequest.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.settings.GetAllRequest} + */ +proto.cc.arduino.cli.settings.GetAllRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.settings.GetAllRequest; + return proto.cc.arduino.cli.settings.GetAllRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.settings.GetAllRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.settings.GetAllRequest} + */ +proto.cc.arduino.cli.settings.GetAllRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.settings.GetAllRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.settings.GetAllRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.settings.GetAllRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.GetAllRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.settings.GetValueRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.settings.GetValueRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.settings.GetValueRequest.displayName = 'proto.cc.arduino.cli.settings.GetValueRequest'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.settings.GetValueRequest.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.settings.GetValueRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.settings.GetValueRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.GetValueRequest.toObject = function(includeInstance, msg) { + var f, obj = { + key: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.settings.GetValueRequest} + */ +proto.cc.arduino.cli.settings.GetValueRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.settings.GetValueRequest; + return proto.cc.arduino.cli.settings.GetValueRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.settings.GetValueRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.settings.GetValueRequest} + */ +proto.cc.arduino.cli.settings.GetValueRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setKey(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.settings.GetValueRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.settings.GetValueRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.settings.GetValueRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.GetValueRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getKey(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string key = 1; + * @return {string} + */ +proto.cc.arduino.cli.settings.GetValueRequest.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.cc.arduino.cli.settings.GetValueRequest.prototype.setKey = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.settings.MergeResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.settings.MergeResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.settings.MergeResponse.displayName = 'proto.cc.arduino.cli.settings.MergeResponse'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.settings.MergeResponse.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.settings.MergeResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.settings.MergeResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.MergeResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.settings.MergeResponse} + */ +proto.cc.arduino.cli.settings.MergeResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.settings.MergeResponse; + return proto.cc.arduino.cli.settings.MergeResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.settings.MergeResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.settings.MergeResponse} + */ +proto.cc.arduino.cli.settings.MergeResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.settings.MergeResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.settings.MergeResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.settings.MergeResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.MergeResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.cc.arduino.cli.settings.SetValueResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.settings.SetValueResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.cc.arduino.cli.settings.SetValueResponse.displayName = 'proto.cc.arduino.cli.settings.SetValueResponse'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.cc.arduino.cli.settings.SetValueResponse.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.settings.SetValueResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.cc.arduino.cli.settings.SetValueResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.SetValueResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.cc.arduino.cli.settings.SetValueResponse} + */ +proto.cc.arduino.cli.settings.SetValueResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.settings.SetValueResponse; + return proto.cc.arduino.cli.settings.SetValueResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.cc.arduino.cli.settings.SetValueResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.settings.SetValueResponse} + */ +proto.cc.arduino.cli.settings.SetValueResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.settings.SetValueResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.settings.SetValueResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.cc.arduino.cli.settings.SetValueResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.settings.SetValueResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + +goog.object.extend(exports, proto.cc.arduino.cli.settings); diff --git a/arduino-ide-extension/src/node/core-client-provider-impl.ts b/arduino-ide-extension/src/node/core-client-provider-impl.ts index 92692feb..a56ec2b7 100644 --- a/arduino-ide-extension/src/node/core-client-provider-impl.ts +++ b/arduino-ide-extension/src/node/core-client-provider-impl.ts @@ -11,7 +11,6 @@ import { ArduinoCoreClient } from './cli-protocol/commands/commands_grpc_pb'; import { InitResp, InitReq, - Configuration, UpdateIndexReq, UpdateIndexResp, UpdateLibrariesIndexReq, @@ -91,7 +90,6 @@ export class CoreClientProviderImpl implements CoreClientProvider { console.info(` >>> Creating and caching a new client for ${rootUri}...`); const client = new ArduinoCoreClient('localhost:50051', grpc.credentials.createInsecure()); - const config = new Configuration(); const rootPath = await this.fileSystem.getFsPath(rootUri); if (!rootPath) { throw new Error(`Could not resolve filesystem path of URI: ${rootUri}.`); @@ -114,13 +112,7 @@ export class CoreClientProviderImpl implements CoreClientProvider { fs.mkdirSync(downloadDir); } - config.setSketchbookdir(sketchDirPath); - config.setDatadir(dataDirPath); - config.setDownloadsdir(downloadDir); - config.setBoardmanageradditionalurlsList(['https://downloads.arduino.cc/packages/package_index.json']); - const initReq = new InitReq(); - initReq.setConfiguration(config); initReq.setLibraryManagerOnly(false); const initResp = await new Promise(resolve => { let resp: InitResp | undefined = undefined; diff --git a/arduino-ide-extension/src/node/core-service-impl.ts b/arduino-ide-extension/src/node/core-service-impl.ts index 549611d9..24862806 100644 --- a/arduino-ide-extension/src/node/core-service-impl.ts +++ b/arduino-ide-extension/src/node/core-service-impl.ts @@ -50,6 +50,7 @@ export class CoreServiceImpl implements CoreService { compilerReq.setInstance(instance); compilerReq.setSketchpath(sketchpath); compilerReq.setFqbn(currentBoard.fqbn!); + compilerReq.setOptimizefordebug(options.optimizeForDebug); compilerReq.setPreprocess(false); compilerReq.setVerbose(true); compilerReq.setQuiet(false); @@ -72,7 +73,7 @@ export class CoreServiceImpl implements CoreService { } async upload(options: CoreService.Upload.Options): Promise { - await this.compile({ uri: options.uri, board: options.board }); + await this.compile({ uri: options.uri, board: options.board, optimizeForDebug: options.optimizeForDebug }); console.log('upload', options); const { uri } = options; diff --git a/arduino-ide-extension/src/node/exec-util.ts b/arduino-ide-extension/src/node/exec-util.ts index cb865602..6c1368fe 100644 --- a/arduino-ide-extension/src/node/exec-util.ts +++ b/arduino-ide-extension/src/node/exec-util.ts @@ -30,28 +30,44 @@ export async function getExecPath(commandName: string, logger: ILogger, versionA return buildCommand; } -export function spawnCommand(command: string, args: string[], logger: ILogger): Promise { +export function spawnCommand(command: string, args: string[], logger?: ILogger): Promise { return new Promise((resolve, reject) => { const cp = spawn(command, args, { windowsHide: true, shell: true }); - const buffers: Buffer[] = []; - cp.stdout.on('data', (b: Buffer) => buffers.push(b)); + const outBuffers: Buffer[] = []; + const errBuffers: Buffer[] = []; + cp.stdout.on('data', (b: Buffer) => outBuffers.push(b)); + cp.stderr.on('data', (b: Buffer) => errBuffers.push(b)); cp.on('error', error => { - logger.error(`Error executing ${command} with args: ${JSON.stringify(args)}.`, error); + if (logger) { + logger.error(`Error executing ${command} ${args.join(' ')}`, error); + } reject(error); }); cp.on('exit', (code, signal) => { if (code === 0) { - const result = Buffer.concat(buffers).toString('utf8').trim() + const result = Buffer.concat(outBuffers).toString('utf8').trim() resolve(result); return; } + if (errBuffers.length > 0) { + const message = Buffer.concat(errBuffers).toString('utf8').trim(); + if (logger) { + logger.error(`Error executing ${command} ${args.join(' ')}: ${message}`); + } + reject(new Error(`Process failed with error: ${message}`)); + return; + } if (signal) { - logger.error(`Unexpected signal '${signal}' when executing ${command} with args: ${JSON.stringify(args)}.`); + if (logger) { + logger.error(`Unexpected signal '${signal}' when executing ${command} ${args.join(' ')}`); + } reject(new Error(`Process exited with signal: ${signal}`)); return; } if (code) { - logger.error(`Unexpected exit code '${code}' when executing ${command} with args: ${JSON.stringify(args)}.`); + if (logger) { + logger.error(`Unexpected exit code '${code}' when executing ${command} ${args.join(' ')}`); + } reject(new Error(`Process exited with exit code: ${code}`)); return; } diff --git a/arduino-ide-extension/src/node/language/arduino-language-server-contribution.ts b/arduino-ide-extension/src/node/language/arduino-language-server-contribution.ts index 00620c49..d3db36e7 100644 --- a/arduino-ide-extension/src/node/language/arduino-language-server-contribution.ts +++ b/arduino-ide-extension/src/node/language/arduino-language-server-contribution.ts @@ -44,8 +44,6 @@ export class ArduinoLanguageServerContribution extends BaseLanguageServerContrib console.log(`Starting language server ${languageServer} ${args.join(' ')}`); const serverConnection = await this.createProcessStreamConnectionAsync(languageServer, args); this.forward(clientConnection, serverConnection); - // https://github.com/eclipse-theia/theia/issues/6308 - serverConnection.onClose(() => (clientConnection as any).reader.socket.close()); } } diff --git a/browser-app/package.json b/browser-app/package.json index e6426c4f..d8c6175f 100644 --- a/browser-app/package.json +++ b/browser-app/package.json @@ -6,6 +6,7 @@ "dependencies": { "@theia/core": "next", "@theia/cpp": "next", + "@theia/debug": "next", "@theia/editor": "next", "@theia/file-search": "next", "@theia/filesystem": "next", @@ -18,14 +19,15 @@ "@theia/terminal": "next", "@theia/workspace": "next", "@theia/textmate-grammars": "next", - "arduino-ide-extension": "0.0.4" + "arduino-ide-extension": "0.0.4", + "arduino-debugger-extension": "0.0.4" }, "devDependencies": { "@theia/cli": "next" }, "scripts": { "prepare": "theia build --mode development", - "start": "theia start", + "start": "theia start --plugins=local-dir:../", "watch": "theia build --watch --mode development" }, "theia": { diff --git a/electron-app/package.json b/electron-app/package.json index 976187c0..434acfbc 100644 --- a/electron-app/package.json +++ b/electron-app/package.json @@ -6,6 +6,7 @@ "dependencies": { "@theia/core": "next", "@theia/cpp": "next", + "@theia/debug": "next", "@theia/editor": "next", "@theia/electron": "next", "@theia/file-search": "next", @@ -19,7 +20,8 @@ "@theia/terminal": "next", "@theia/workspace": "next", "@theia/textmate-grammars": "next", - "arduino-ide-extension": "0.0.4" + "arduino-ide-extension": "0.0.4", + "arduino-debugger-extension": "0.0.4" }, "devDependencies": { "@theia/cli": "next" diff --git a/electron/build/template-package.json b/electron/build/template-package.json index 9373471f..03a7ddf1 100644 --- a/electron/build/template-package.json +++ b/electron/build/template-package.json @@ -4,7 +4,8 @@ "main": "src-gen/frontend/electron-main.js", "author": "Arduino SA", "dependencies": { - "arduino-ide-extension": "file:../working-copy/arduino-ide-extension" + "arduino-ide-extension": "file:../working-copy/arduino-ide-extension", + "arduino-debugger-extension": "file:../working-copy/arduino-debugger-extension" }, "resolutions": { "**/fs-extra": "^4.0.3" diff --git a/electron/packager/index.js b/electron/packager/index.js index 974a2438..55f1dcec 100644 --- a/electron/packager/index.js +++ b/electron/packager/index.js @@ -42,13 +42,13 @@ // Copy the following items into the `working-copy` folder. Make sure to reuse the `yarn.lock`. | //----------------------------------------------------------------------------------------------+ mkdir('-p', path('..', workingCopy)); - for (const name of ['arduino-ide-extension', 'electron-app', 'yarn.lock', 'package.json', 'lerna.json']) { + for (const name of ['arduino-ide-extension', 'arduino-debugger-extension', 'electron-app', 'yarn.lock', 'package.json', 'lerna.json']) { cp('-rf', path(rootPath, name), path('..', workingCopy)); } - //-----------------------------------------------------+ + //---------------------------------------------+ // No need to build the `browser-app` example. | - //-----------------------------------------------------+ + //---------------------------------------------+ //@ts-ignore let pkg = require('../working-copy/package.json'); const workspaces = pkg.workspaces; @@ -72,6 +72,14 @@ // We have to do it before changing the dependencies to `local-path`. const unusedDependencies = await utils.collectUnusedDependencies('../working-copy/electron-app/'); + //-------------------------------------------------------------------------------------------------------------+ + // Change the regular NPM dependencies to `local-paths`, so that we can build them without any NPM registries. | + //-------------------------------------------------------------------------------------------------------------+ + // @ts-ignore + pkg = require('../working-copy/arduino-debugger-extension/package.json'); + pkg.dependencies['arduino-ide-extension'] = 'file:../arduino-ide-extension'; + fs.writeFileSync(path('..', workingCopy, 'arduino-debugger-extension', 'package.json'), JSON.stringify(pkg, null, 2)); + //------------------------------------------------------------------------------------+ // Merge the `working-copy/package.json` with `electron/build/template-package.json`. | //------------------------------------------------------------------------------------+ diff --git a/package.json b/package.json index d3418702..e68c9283 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "workspaces": [ "arduino-ide-extension", + "arduino-debugger-extension", "electron-app", "browser-app" ] diff --git a/yarn.lock b/yarn.lock index a9161a10..ad260e98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1880,6 +1880,15 @@ serialize-javascript "^1.4.0" webpack-sources "^1.0.1" +"@theia/console@0.16.0-next.46a2d510": + version "0.16.0-next.46a2d510" + resolved "https://registry.yarnpkg.com/@theia/console/-/console-0.16.0-next.46a2d510.tgz#ba5926258cf58b4fbe64460239f4af38a98ff883" + integrity sha512-yJk6+H6xzNO+fmJuz7k47cMjZsA2b4wgEp9FVaHCkn3fmTjMo/Qv3PCH78S8bSMQcKmfqFDCACj/X96cTmMAfg== + dependencies: + "@theia/core" "0.16.0-next.46a2d510" + "@theia/monaco" "0.16.0-next.46a2d510" + anser "^1.4.7" + "@theia/core@0.16.0-next.46a2d510", "@theia/core@next": version "0.16.0-next.46a2d510" resolved "https://registry.yarnpkg.com/@theia/core/-/core-0.16.0-next.46a2d510.tgz#2ff298bf34721a2dc7a3ae1c261f0f01b2d6b0be" @@ -1942,6 +1951,36 @@ "@theia/workspace" next string-argv "^0.1.1" +"@theia/debug@next": + version "0.16.0-next.46a2d510" + resolved "https://registry.yarnpkg.com/@theia/debug/-/debug-0.16.0-next.46a2d510.tgz#702b7c9a44cab46f368fbafe2776c5ec703f97fb" + integrity sha512-iUvNV3UGFGBFEE0lpBlcLQoklr86Az2G36ORpVw9VPWTHkm21RKdmwY2M0rF1+JnaENz0iFJEVayD2rzNQGTdA== + dependencies: + "@theia/application-package" "0.16.0-next.46a2d510" + "@theia/console" "0.16.0-next.46a2d510" + "@theia/core" "0.16.0-next.46a2d510" + "@theia/editor" "0.16.0-next.46a2d510" + "@theia/filesystem" "0.16.0-next.46a2d510" + "@theia/languages" "0.16.0-next.46a2d510" + "@theia/markers" "0.16.0-next.46a2d510" + "@theia/monaco" "0.16.0-next.46a2d510" + "@theia/output" "0.16.0-next.46a2d510" + "@theia/preferences" "0.16.0-next.46a2d510" + "@theia/process" "0.16.0-next.46a2d510" + "@theia/task" "0.16.0-next.46a2d510" + "@theia/terminal" "0.16.0-next.46a2d510" + "@theia/userstorage" "0.16.0-next.46a2d510" + "@theia/variable-resolver" "0.16.0-next.46a2d510" + "@theia/workspace" "0.16.0-next.46a2d510" + "@types/p-debounce" "^1.0.1" + jsonc-parser "^2.0.2" + mkdirp "^0.5.0" + p-debounce "^2.1.0" + requestretry "^3.1.0" + tar "^4.0.0" + unzip-stream "^0.3.0" + vscode-debugprotocol "^1.32.0" + "@theia/editor@0.16.0-next.46a2d510", "@theia/editor@next": version "0.16.0-next.46a2d510" resolved "https://registry.yarnpkg.com/@theia/editor/-/editor-0.16.0-next.46a2d510.tgz#8c49de165b37d64f480626c07bced71572f86182" @@ -2169,7 +2208,7 @@ "@theia/workspace" "0.16.0-next.46a2d510" vscode-ripgrep "^1.2.4" -"@theia/task@next": +"@theia/task@0.16.0-next.46a2d510", "@theia/task@next": version "0.16.0-next.46a2d510" resolved "https://registry.yarnpkg.com/@theia/task/-/task-0.16.0-next.46a2d510.tgz#004ca4f4256351c63602332798dd6d98e3c387cf" integrity sha512-390Meof3StbHNBNfQY8f/opNBj/IZN8z/ZjhRNf/0vtu1b6aZGMo1z/9e8eLcCwDyAdFvSCHRk1bny+rhB4//w== @@ -2863,6 +2902,11 @@ alphanum-sort@^1.0.1, alphanum-sort@^1.0.2: resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3" integrity sha1-l6ERlkmyEa0zaR2fn0hqjsn74KM= +anser@^1.4.7: + version "1.4.9" + resolved "https://registry.yarnpkg.com/anser/-/anser-1.4.9.tgz#1f85423a5dcf8da4631a341665ff675b96845760" + integrity sha512-AI+BjTeGt2+WFk4eWcqbQ7snZpDBt8SaLlj0RT2h5xfdWaiy51OjYvqwMrNzJLGy8iOAL6nKDITWO+rd4MkYEA== + ansi-bgblack@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ansi-bgblack/-/ansi-bgblack-0.1.1.tgz#a68ba5007887701b6aafbe3fa0dadfdfa8ee3ca2" @@ -4666,6 +4710,15 @@ caw@^2.0.1: tunnel-agent "^0.6.0" url-to-options "^1.0.1" +cdt-gdb-adapter@^0.0.14: + version "0.0.14" + resolved "https://registry.yarnpkg.com/cdt-gdb-adapter/-/cdt-gdb-adapter-0.0.14.tgz#0b4cc8650699572003e52a9f8265e9c65055339c" + integrity sha512-SDRVECyEkgePj0AJNVp8HUOw/ObXSlakQNxMasC1wlCn6eE8HcLAdYqdIgwRtnkp2Ct96/U5mXHFHWQDan6ckw== + dependencies: + node-addon-api "^1.6.2" + vscode-debugadapter "^1.37.1" + vscode-debugprotocol "^1.37.0" + chai-string@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.5.0.tgz#0bdb2d8a5f1dbe90bc78ec493c1c1c180dd4d3d2" @@ -9719,6 +9772,11 @@ node-abi@^2.11.0, node-abi@^2.2.0: dependencies: semver "^5.4.1" +node-addon-api@^1.6.2: + version "1.7.1" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-1.7.1.tgz#cf813cd69bb8d9100f6bdca6755fc268f54ac492" + integrity sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ== + node-dir@0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.8.tgz#55fb8deb699070707fb67f91a460f0448294c77d" @@ -9827,22 +9885,6 @@ node-libs-browser@^2.2.1: util "^0.11.0" vm-browserify "^1.0.1" -node-pre-gyp@*: - version "0.14.0" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz#9a0596533b877289bcad4e143982ca3d904ddc83" - integrity sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4.4.2" - node-pre-gyp@^0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz#39ba4bb1439da030295f899e3b520b7785766149" @@ -12850,7 +12892,7 @@ tar@^2.0.0: fstream "^1.0.12" inherits "2" -tar@^4, tar@^4.0.0, tar@^4.0.2, tar@^4.4.10, tar@^4.4.12, tar@^4.4.2, tar@^4.4.8: +tar@^4, tar@^4.0.0, tar@^4.0.2, tar@^4.4.10, tar@^4.4.12, tar@^4.4.8: version "4.4.13" resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== @@ -13227,6 +13269,11 @@ typeof-article@^0.1.1: dependencies: kind-of "^3.1.0" +typescript@3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.1.tgz#ba72a6a600b2158139c5dd8850f700e231464202" + integrity sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw== + typescript@3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977" @@ -13577,6 +13624,19 @@ vm-browserify@^1.0.1: resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== +vscode-debugadapter@^1.26.0, vscode-debugadapter@^1.37.1: + version "1.38.0" + resolved "https://registry.yarnpkg.com/vscode-debugadapter/-/vscode-debugadapter-1.38.0.tgz#764a2cef6634cf17c35e1ca97fa1faa253ac87c1" + integrity sha512-rm4qmbqj8aAaE8sUt4hX2HZUi7Nmtmf10fiGPqbLZWSFPrBi6myxhrQ0HPeG6Xep5rEgrGzVwCJ/lSGPz2ja1A== + dependencies: + mkdirp "^0.5.1" + vscode-debugprotocol "1.38.0" + +vscode-debugprotocol@1.38.0, vscode-debugprotocol@^1.26.0, vscode-debugprotocol@^1.32.0, vscode-debugprotocol@^1.37.0: + version "1.38.0" + resolved "https://registry.yarnpkg.com/vscode-debugprotocol/-/vscode-debugprotocol-1.38.0.tgz#7a9bcd457e6642f48fabef114c0fa1c25a2fb1e7" + integrity sha512-oam9iSjNfXSn71a8bmNsXv8k/rIKSOcllIPrFnNgxd1EMBpfnum+gb7lmRpcH0zSjGb+OH8Ncn8B5tv8srWbNQ== + vscode-jsonrpc@^4.1.0-next: version "4.1.0-next.3" resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-4.1.0-next.3.tgz#05fe742959a2726020d4d0bfbc3d3c97873c7fde"