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',
},
'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': {
type: 'boolean',
description: nls.localize(
@ -259,7 +251,6 @@ export interface ArduinoConfiguration {
'arduino.compile.experimental': boolean;
'arduino.compile.revealRange': ErrorRevealStrategy;
'arduino.compile.warnings': CompilerWarnings;
'arduino.compile.optimizeForDebug': boolean;
'arduino.upload.verbose': boolean;
'arduino.upload.verify': boolean;
'arduino.window.autoScale': boolean;

View File

@ -14,11 +14,10 @@ import {
import { MaybePromise, MenuModelRegistry, nls } from '@theia/core/lib/common';
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
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()
export class Debug extends SketchContribution {
@inject(HostedPluginSupport)
@ -36,8 +35,8 @@ export class Debug extends SketchContribution {
@inject(BoardsServiceProvider)
private readonly boardsServiceProvider: BoardsServiceProvider;
@inject(PreferenceService)
private readonly preferenceService: PreferenceService;
@inject(MainMenuManager)
private readonly mainMenuManager: MainMenuManager;
/**
* 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',
isEnabled: () => !this.disabledMessage,
});
registry.registerCommand(Debug.Commands.OPTIMIZE_FOR_DEBUG, {
execute: () => this.toggleOptimizeForDebug(),
isToggled: () => this.isOptimizeForDebug(),
registry.registerCommand(Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG, {
execute: () => this.toggleCompileForDebug(),
isToggled: () => this.compileForDebug,
});
registry.registerCommand(Debug.Commands.IS_OPTIMIZE_FOR_DEBUG, {
execute: () => this.compileForDebug,
});
}
override registerMenus(registry: MenuModelRegistry): void {
registry.registerMenuAction(ArduinoMenus.SKETCH__MAIN_GROUP, {
commandId: Debug.Commands.OPTIMIZE_FOR_DEBUG.id,
label: Debug.Commands.OPTIMIZE_FOR_DEBUG.label,
commandId: Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG.id,
label: Debug.Commands.TOGGLE_OPTIMIZE_FOR_DEBUG.label,
order: '5',
});
}
@ -199,16 +201,16 @@ export class Debug extends SketchContribution {
return this.commandService.executeCommand('arduino.debug.start', config);
}
private isOptimizeForDebug(): boolean {
return this.preferences.get('arduino.compile.optimizeForDebug');
get compileForDebug(): boolean {
const value = window.localStorage.getItem(COMPILE_FOR_DEBUG_KEY);
return value === 'true';
}
private async toggleOptimizeForDebug(): Promise<void> {
return this.preferenceService.set(
'arduino.compile.optimizeForDebug',
!this.isOptimizeForDebug(),
PreferenceScope.User
);
async toggleCompileForDebug(): Promise<void> {
const oldState = this.compileForDebug;
const newState = !oldState;
window.localStorage.setItem(COMPILE_FOR_DEBUG_KEY, String(newState));
this.mainMenuManager.update();
}
}
export namespace Debug {
@ -221,13 +223,16 @@ export namespace Debug {
},
'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',
category: 'Arduino',
},
'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.onDidChangeEmitter.fire();
const { boardsConfig } = this.boardsServiceClientImpl;
const [fqbn, { selectedProgrammer }, verify, verbose, sourceOverride] =
await Promise.all([
this.boardsDataStore.appendConfigToFqbn(
boardsConfig.selectedBoard?.fqbn
),
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
this.preferences.get('arduino.upload.verify'),
this.preferences.get('arduino.upload.verbose'),
this.sourceOverride(),
]);
const [
fqbn,
{ selectedProgrammer },
verify,
verbose,
sourceOverride,
optimizeForDebug,
] = await Promise.all([
this.boardsDataStore.appendConfigToFqbn(
boardsConfig.selectedBoard?.fqbn
),
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
this.preferences.get('arduino.upload.verify'),
this.preferences.get('arduino.upload.verbose'),
this.sourceOverride(),
this.commandService.executeCommand<boolean>(
'arduino-is-optimize-for-debug'
),
]);
const board = {
...boardsConfig.selectedBoard,
@ -227,9 +236,6 @@ export class UploadSketch extends CoreServiceContribution {
fqbn,
};
let options: CoreService.Upload.Options | undefined = undefined;
const optimizeForDebug = this.preferences.get(
'arduino.compile.optimizeForDebug'
);
const { selectedPort } = boardsConfig;
const port = selectedPort;
const userFields =
@ -249,7 +255,7 @@ export class UploadSketch extends CoreServiceContribution {
options = {
sketch,
board,
optimizeForDebug,
optimizeForDebug: Boolean(optimizeForDebug),
programmer,
port,
verbose,
@ -261,7 +267,7 @@ export class UploadSketch extends CoreServiceContribution {
options = {
sketch,
board,
optimizeForDebug,
optimizeForDebug: Boolean(optimizeForDebug),
port,
verbose,
verify,

View File

@ -114,14 +114,15 @@ export class VerifySketch extends CoreServiceContribution {
};
const verbose = this.preferences.get('arduino.compile.verbose');
const compilerWarnings = this.preferences.get('arduino.compile.warnings');
const optimizeForDebug = this.preferences.get(
'arduino.compile.optimizeForDebug'
);
const optimizeForDebug =
await this.commandService.executeCommand<boolean>(
'arduino-is-optimize-for-debug'
);
this.outputChannelManager.getChannel('Arduino').clear();
await this.coreService.compile({
sketch,
board,
optimizeForDebug,
optimizeForDebug: Boolean(optimizeForDebug),
verbose,
exportBinaries,
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.",
"compile": "compile",
"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.verbose": "True for verbose compile output. False by default",
"compile.warnings": "Tells gcc which warning level to use. It's 'None' by default",