Skip to content

Commit 48d6d37

Browse files
dankeboy36giacomocusinato
authored andcommitted
feat: can skip verify before upload
Adds a new preference to control whether the verify command should automatically run before the upload. If the `arduino.upload.autoVerify` setting value is `false`, IDE does not recompile the sketch code before uploading it to the board. Signed-off-by: dankeboy36 <[email protected]>
1 parent d106588 commit 48d6d37

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

arduino-ide-extension/src/browser/arduino-preferences.ts

+13
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ const properties: ArduinoPreferenceSchemaProperties = {
137137
'arduino.upload.verify': {
138138
type: 'boolean',
139139
default: false,
140+
description: nls.localize(
141+
'arduino/preferences/upload.verify',
142+
'After upload, verify that the contents of the memory on the board match the uploaded binary.'
143+
),
144+
},
145+
'arduino.upload.autoVerify': {
146+
type: 'boolean',
147+
default: true,
148+
description: nls.localize(
149+
'arduino/preferences/upload.autoVerify',
150+
"True if the IDE should automatically verify the code before the upload. True by default. When this value is false, IDE does not recompile the code before uploading the binary to the board. It's highly advised to only set this value to false if you know what you are doing."
151+
),
140152
},
141153
'arduino.window.autoScale': {
142154
type: 'boolean',
@@ -327,6 +339,7 @@ export interface ArduinoConfiguration {
327339
'arduino.compile.warnings': CompilerWarnings;
328340
'arduino.upload.verbose': boolean;
329341
'arduino.upload.verify': boolean;
342+
'arduino.upload.autoVerify': boolean;
330343
'arduino.window.autoScale': boolean;
331344
'arduino.ide.updateChannel': UpdateChannel;
332345
'arduino.ide.updateBaseUrl': string;

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export class UploadSketch extends CoreServiceContribution {
104104
}
105105

106106
try {
107+
const autoVerify = this.preferences['arduino.upload.autoVerify'];
107108
// toggle the toolbar button and menu item state.
108109
// uploadInProgress will be set to false whether the upload fails or not
109110
this.uploadInProgress = true;
@@ -116,7 +117,7 @@ export class UploadSketch extends CoreServiceContribution {
116117
'arduino-verify-sketch',
117118
<VerifySketchParams>{
118119
exportBinaries: false,
119-
silent: true,
120+
mode: autoVerify ? 'auto' : 'dry-run',
120121
}
121122
);
122123
if (!verifyOptions) {

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

+26-11
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,35 @@ import {
1515
} from './contribution';
1616
import { CoreErrorHandler } from './core-error-handler';
1717

18+
export type VerifySketchMode =
19+
/**
20+
* When the user explicitly triggers the verify command from the primary UI: menu, toolbar, or keybinding. The UI shows the output, updates the toolbar items state, etc.
21+
*/
22+
| 'explicit'
23+
/**
24+
* When the verify phase automatically runs as part of the upload but there is no UI indication of the command: the toolbar items do not update.
25+
*/
26+
| 'auto'
27+
/**
28+
* The verify does not run. There is no UI indication of the command. For example, when the user decides to disable the auto verify (`'arduino.upload.autoVerify'`) to skips the code recompilation phase.
29+
*/
30+
| 'dry-run';
31+
1832
export interface VerifySketchParams {
1933
/**
2034
* Same as `CoreService.Options.Compile#exportBinaries`
2135
*/
2236
readonly exportBinaries?: boolean;
2337
/**
24-
* If `true`, there won't be any UI indication of the verify command in the toolbar. It's `false` by default.
38+
* The mode specifying how verify should run. It's `'explicit'` by default.
2539
*/
26-
readonly silent?: boolean;
40+
readonly mode?: VerifySketchMode;
2741
}
2842

2943
/**
30-
* - `"idle"` when neither verify, nor upload is running,
31-
* - `"explicit-verify"` when only verify is running triggered by the user, and
32-
* - `"automatic-verify"` is when the automatic verify phase is running as part of an upload triggered by the user.
44+
* - `"idle"` when neither verify, nor upload is running
3345
*/
34-
type VerifyProgress = 'idle' | 'explicit-verify' | 'automatic-verify';
46+
type VerifyProgress = 'idle' | VerifySketchMode;
3547

3648
@injectable()
3749
export class VerifySketch extends CoreServiceContribution {
@@ -54,10 +66,10 @@ export class VerifySketch extends CoreServiceContribution {
5466
registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH_TOOLBAR, {
5567
isVisible: (widget) =>
5668
ArduinoToolbar.is(widget) && widget.side === 'left',
57-
isEnabled: () => this.verifyProgress !== 'explicit-verify',
69+
isEnabled: () => this.verifyProgress !== 'explicit',
5870
// toggled only when verify is running, but not toggled when automatic verify is running before the upload
5971
// https://github.com/arduino/arduino-ide/pull/1750#pullrequestreview-1214762975
60-
isToggled: () => this.verifyProgress === 'explicit-verify',
72+
isToggled: () => this.verifyProgress === 'explicit',
6173
execute: () =>
6274
registry.executeCommand(VerifySketch.Commands.VERIFY_SKETCH.id),
6375
});
@@ -113,19 +125,22 @@ export class VerifySketch extends CoreServiceContribution {
113125
}
114126

115127
try {
116-
this.verifyProgress = params?.silent
117-
? 'automatic-verify'
118-
: 'explicit-verify';
128+
this.verifyProgress = params?.mode ?? 'explicit';
119129
this.onDidChangeEmitter.fire();
120130
this.menuManager.update();
121131
this.clearVisibleNotification();
122132
this.coreErrorHandler.reset();
133+
const dryRun = this.verifyProgress === 'dry-run';
123134

124135
const options = await this.options(params?.exportBinaries);
125136
if (!options) {
126137
return undefined;
127138
}
128139

140+
if (dryRun) {
141+
return options;
142+
}
143+
129144
await this.doWithProgress({
130145
progressText: nls.localize(
131146
'arduino/sketch/compile',

i18n/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,9 @@
415415
"survey.notification": "True if users should be notified if a survey is available. True by default.",
416416
"unofficialBoardSupport": "Click for a list of unofficial board support URLs",
417417
"upload": "upload",
418+
"upload.autoVerify": "True if the IDE should automatically verify the code before the upload. True by default. When this value is false, IDE does not recompile the code before uploading the binary to the board. It's highly advised to only set this value to false if you know what you are doing.",
418419
"upload.verbose": "True for verbose upload output. False by default.",
420+
"upload.verify": "After upload, verify that the contents of the memory on the board match the uploaded binary.",
419421
"verifyAfterUpload": "Verify code after upload",
420422
"window.autoScale": "True if the user interface automatically scales with the font size.",
421423
"window.zoomLevel": {

0 commit comments

Comments
 (0)