Dropped compile.optimizeForDebug preference.

Closes #1212.

Restored the `Optimize for Debugging` before:
abca14a02be77160a86d9f4fb6eca8c18d47312d2d4be37c50de50430bbbcd07

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-07-19 10:29:47 +02:00 committed by Akos Kitta
parent 5ff9ce0028
commit 337d22efbd
5 changed files with 52 additions and 50 deletions

View File

@ -92,14 +92,6 @@ export const ArduinoConfigSchema: PreferenceSchema = {
), ),
default: 'None', default: 'None',
}, },
'arduino.compile.optimizeForDebug': {
type: 'boolean',
description: nls.localize(
'arduino/preferences/compile.optimizeForDebug',
"Optimize compile output for debug, not for release. It's 'false' by default."
),
default: false,
},
'arduino.upload.verbose': { 'arduino.upload.verbose': {
type: 'boolean', type: 'boolean',
description: nls.localize( description: nls.localize(
@ -259,7 +251,6 @@ export interface ArduinoConfiguration {
'arduino.compile.experimental': boolean; 'arduino.compile.experimental': boolean;
'arduino.compile.revealRange': ErrorRevealStrategy; 'arduino.compile.revealRange': ErrorRevealStrategy;
'arduino.compile.warnings': CompilerWarnings; 'arduino.compile.warnings': CompilerWarnings;
'arduino.compile.optimizeForDebug': boolean;
'arduino.upload.verbose': boolean; 'arduino.upload.verbose': boolean;
'arduino.upload.verify': boolean; 'arduino.upload.verify': boolean;
'arduino.window.autoScale': boolean; 'arduino.window.autoScale': boolean;

View File

@ -14,11 +14,10 @@ import {
import { MaybePromise, MenuModelRegistry, nls } from '@theia/core/lib/common'; import { MaybePromise, MenuModelRegistry, nls } from '@theia/core/lib/common';
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl'; import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
import { ArduinoMenus } from '../menu/arduino-menus'; import { ArduinoMenus } from '../menu/arduino-menus';
import {
PreferenceScope,
PreferenceService,
} from '@theia/core/lib/browser/preferences/preference-service';
import { MainMenuManager } from '../../common/main-menu-manager';
const COMPILE_FOR_DEBUG_KEY = 'arduino-compile-for-debug';
@injectable() @injectable()
export class Debug extends SketchContribution { export class Debug extends SketchContribution {
@inject(HostedPluginSupport) @inject(HostedPluginSupport)
@ -36,8 +35,8 @@ export class Debug extends SketchContribution {
@inject(BoardsServiceProvider) @inject(BoardsServiceProvider)
private readonly boardsServiceProvider: BoardsServiceProvider; private readonly boardsServiceProvider: BoardsServiceProvider;
@inject(PreferenceService) @inject(MainMenuManager)
private readonly preferenceService: PreferenceService; private readonly mainMenuManager: MainMenuManager;
/** /**
* If `undefined`, debugging is enabled. Otherwise, the reason why it's disabled. * If `undefined`, debugging is enabled. Otherwise, the reason why it's disabled.
@ -105,16 +104,19 @@ export class Debug extends SketchContribution {
ArduinoToolbar.is(widget) && widget.side === 'left', ArduinoToolbar.is(widget) && widget.side === 'left',
isEnabled: () => !this.disabledMessage, isEnabled: () => !this.disabledMessage,
}); });
registry.registerCommand(Debug.Commands.OPTIMIZE_FOR_DEBUG, { registry.registerCommand(Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG, {
execute: () => this.toggleOptimizeForDebug(), execute: () => this.toggleCompileForDebug(),
isToggled: () => this.isOptimizeForDebug(), isToggled: () => this.compileForDebug,
});
registry.registerCommand(Debug.Commands.IS_OPTIMIZE_FOR_DEBUG, {
execute: () => this.compileForDebug,
}); });
} }
override registerMenus(registry: MenuModelRegistry): void { override registerMenus(registry: MenuModelRegistry): void {
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, { registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
commandId: Debug.Commands.OPTIMIZE_FOR_DEBUG.id, commandId: Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG.id,
label: Debug.Commands.OPTIMIZE_FOR_DEBUG.label, label: Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG.label,
order: '5', order: '5',
}); });
} }
@ -199,16 +201,16 @@ export class Debug extends SketchContribution {
return this.commandService.executeCommand('arduino.debug.start', config); return this.commandService.executeCommand('arduino.debug.start', config);
} }
private isOptimizeForDebug(): boolean { get compileForDebug(): boolean {
return this.preferences.get('arduino.compile.optimizeForDebug'); const value = window.localStorage.getItem(COMPILE_FOR_DEBUG_KEY);
return value === 'true';
} }
private async toggleOptimizeForDebug(): Promise<void> { async toggleCompileForDebug(): Promise<void> {
return this.preferenceService.set( const oldState = this.compileForDebug;
'arduino.compile.optimizeForDebug', const newState = !oldState;
!this.isOptimizeForDebug(), window.localStorage.setItem(COMPILE_FOR_DEBUG_KEY, String(newState));
PreferenceScope.User this.mainMenuManager.update();
);
} }
} }
export namespace Debug { export namespace Debug {
@ -221,13 +223,16 @@ export namespace Debug {
}, },
'vscode/debug.contribution/startDebuggingHelp' 'vscode/debug.contribution/startDebuggingHelp'
); );
export const OPTIMIZE_FOR_DEBUG = Command.toLocalizedCommand( export const TOGGLE_OPTIMIZE_FOR_DEBUG = Command.toLocalizedCommand(
{ {
id: 'arduino-optimize-for-debug', id: 'arduino-toggle-optimize-for-debug',
label: 'Optimize for Debugging', label: 'Optimize for Debugging',
category: 'Arduino', category: 'Arduino',
}, },
'arduino/debug/optimizeForDebugging' 'arduino/debug/optimizeForDebugging'
); );
export const IS_OPTIMIZE_FOR_DEBUG: Command = {
id: 'arduino-is-optimize-for-debug',
};
} }
} }

View File

@ -210,16 +210,25 @@ export class UploadSketch extends CoreServiceContribution {
this.coreErrorHandler.reset(); this.coreErrorHandler.reset();
this.onDidChangeEmitter.fire(); this.onDidChangeEmitter.fire();
const { boardsConfig } = this.boardsServiceClientImpl; const { boardsConfig } = this.boardsServiceClientImpl;
const [fqbn, { selectedProgrammer }, verify, verbose, sourceOverride] = const [
await Promise.all([ fqbn,
this.boardsDataStore.appendConfigToFqbn( { selectedProgrammer },
boardsConfig.selectedBoard?.fqbn verify,
), verbose,
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn), sourceOverride,
this.preferences.get('arduino.upload.verify'), optimizeForDebug,
this.preferences.get('arduino.upload.verbose'), ] = await Promise.all([
this.sourceOverride(), this.boardsDataStore.appendConfigToFqbn(
]); boardsConfig.selectedBoard?.fqbn
),
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
this.preferences.get('arduino.upload.verify'),
this.preferences.get('arduino.upload.verbose'),
this.sourceOverride(),
this.commandService.executeCommand<boolean>(
'arduino-is-optimize-for-debug'
),
]);
const board = { const board = {
...boardsConfig.selectedBoard, ...boardsConfig.selectedBoard,
@ -227,9 +236,6 @@ export class UploadSketch extends CoreServiceContribution {
fqbn, fqbn,
}; };
let options: CoreService.Upload.Options | undefined = undefined; let options: CoreService.Upload.Options | undefined = undefined;
const optimizeForDebug = this.preferences.get(
'arduino.compile.optimizeForDebug'
);
const { selectedPort } = boardsConfig; const { selectedPort } = boardsConfig;
const port = selectedPort; const port = selectedPort;
const userFields = const userFields =
@ -249,7 +255,7 @@ export class UploadSketch extends CoreServiceContribution {
options = { options = {
sketch, sketch,
board, board,
optimizeForDebug, optimizeForDebug: Boolean(optimizeForDebug),
programmer, programmer,
port, port,
verbose, verbose,
@ -261,7 +267,7 @@ export class UploadSketch extends CoreServiceContribution {
options = { options = {
sketch, sketch,
board, board,
optimizeForDebug, optimizeForDebug: Boolean(optimizeForDebug),
port, port,
verbose, verbose,
verify, verify,

View File

@ -114,14 +114,15 @@ export class VerifySketch extends CoreServiceContribution {
}; };
const verbose = this.preferences.get('arduino.compile.verbose'); const verbose = this.preferences.get('arduino.compile.verbose');
const compilerWarnings = this.preferences.get('arduino.compile.warnings'); const compilerWarnings = this.preferences.get('arduino.compile.warnings');
const optimizeForDebug = this.preferences.get( const optimizeForDebug =
'arduino.compile.optimizeForDebug' await this.commandService.executeCommand<boolean>(
); 'arduino-is-optimize-for-debug'
);
this.outputChannelManager.getChannel('Arduino').clear(); this.outputChannelManager.getChannel('Arduino').clear();
await this.coreService.compile({ await this.coreService.compile({
sketch, sketch,
board, board,
optimizeForDebug, optimizeForDebug: Boolean(optimizeForDebug),
verbose, verbose,
exportBinaries, exportBinaries,
sourceOverride, sourceOverride,

View File

@ -257,7 +257,6 @@
"cloud.sketchSyncEndpoint": "The endpoint used to push and pull sketches from a backend. By default it points to Arduino Cloud API.", "cloud.sketchSyncEndpoint": "The endpoint used to push and pull sketches from a backend. By default it points to Arduino Cloud API.",
"compile": "compile", "compile": "compile",
"compile.experimental": "True if the IDE should handle multiple compiler errors. False by default", "compile.experimental": "True if the IDE should handle multiple compiler errors. False by default",
"compile.optimizeForDebug": "Optimize compile output for debug, not for release. It's 'false' by default.",
"compile.revealRange": "Adjusts how compiler errors are revealed in the editor after a failed verify/upload. Possible values: 'auto': Scroll vertically as necessary and reveal a line. 'center': Scroll vertically as necessary and reveal a line centered vertically. 'top': Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition. 'centerIfOutsideViewport': Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport. The default value is '{0}'.", "compile.revealRange": "Adjusts how compiler errors are revealed in the editor after a failed verify/upload. Possible values: 'auto': Scroll vertically as necessary and reveal a line. 'center': Scroll vertically as necessary and reveal a line centered vertically. 'top': Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition. 'centerIfOutsideViewport': Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport. The default value is '{0}'.",
"compile.verbose": "True for verbose compile output. False by default", "compile.verbose": "True for verbose compile output. False by default",
"compile.warnings": "Tells gcc which warning level to use. It's 'None' by default", "compile.warnings": "Tells gcc which warning level to use. It's 'None' by default",