Skip to content

Dropped compile.optimizeForDebug preference. #1213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions arduino-ide-extension/src/browser/arduino-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
47 changes: 26 additions & 21 deletions arduino-ide-extension/src/browser/contributions/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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',
});
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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',
};
}
}
36 changes: 21 additions & 15 deletions arduino-ide-extension/src/browser/contributions/upload-sketch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,32 @@ 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,
name: boardsConfig.selectedBoard?.name || '',
fqbn,
};
let options: CoreService.Upload.Options | undefined = undefined;
const optimizeForDebug = this.preferences.get(
'arduino.compile.optimizeForDebug'
);
const { selectedPort } = boardsConfig;
const port = selectedPort;
const userFields =
Expand All @@ -249,7 +255,7 @@ export class UploadSketch extends CoreServiceContribution {
options = {
sketch,
board,
optimizeForDebug,
optimizeForDebug: Boolean(optimizeForDebug),
programmer,
port,
verbose,
Expand All @@ -261,7 +267,7 @@ export class UploadSketch extends CoreServiceContribution {
options = {
sketch,
board,
optimizeForDebug,
optimizeForDebug: Boolean(optimizeForDebug),
port,
verbose,
verify,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down