Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 1da81e0

Browse files
authored
Merge pull request #1421 from microsoft/main
Bump to v0.4.10
2 parents 9434aad + 0d85734 commit 1da81e0

File tree

12 files changed

+160
-46
lines changed

12 files changed

+160
-46
lines changed

.github/workflows/fixed-issues.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Close fixed issues
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
workflow_dispatch:
8+
9+
jobs:
10+
fixed:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/[email protected]
14+
with:
15+
days-before-stale: 0
16+
days-before-close: 0
17+
ignore-updates: true
18+
close-issue-message: >-
19+
This issue has been fixed in the latest release of this extension,
20+
which is available in the VS Code extension marketplace.
21+
stale-issue-label: fixed-pending-release
22+
only-labels: fixed-pending-release

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
7171
| --- | --- |
7272
| `arduino.path` | Path to Arduino, you can use a custom version of Arduino by modifying this setting to include the full path. Example: `C:\\Program Files\\Arduino` for Windows, `/Applications` for Mac, `/home/<username>/Downloads/arduino-1.8.1` for Linux. (Requires a restart after change). The default value is automatically detected from your Arduino IDE installation path. |
7373
| `arduino.commandPath` | Path to an executable (or script) relative to `arduino.path`. The default value is `arduino_debug.exe` for Windows, `Contents/MacOS/Arduino` for Mac and `arduino` for Linux, You also can use a custom launch script to run Arduino by modifying this setting. (Requires a restart after change) Example: `run-arduino.bat` for Windows, `Contents/MacOS/run-arduino.sh` for Mac and `bin/run-arduino.sh` for Linux. |
74-
| `arduino.additionalUrls` | Additional Boards Manager URLs for 3rd party packages. You can have multiple URLs in one string with a comma(`,`) as separator, or have a string array. The default value is empty. |
74+
| `arduino.additionalUrls` | Additional Boards Manager URLs for 3rd party packages as a string array. The default value is empty. |
7575
| `arduino.logLevel` | CLI output log level. Could be info or verbose. The default value is `"info"`. |
7676
| `arduino.clearOutputOnBuild` | Clear the output logs before uploading or verifying. Default value is `false`. |
7777
| `arduino.allowPDEFiletype` | Allow the VSCode Arduino extension to open .pde files from pre-1.0.0 versions of Arduino. Note that this will break Processing code. Default value is `false`. |

azure-pipelines.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,21 @@ steps:
115115
includeRootFolder: false
116116
archiveType: zip
117117
archiveFile: $(Build.StagingDirectory)\vscode-arduino.vsix
118+
- script: python .\build\markExecutableFiles.py
119+
displayName: Make serial monitor executable
118120
- task: MSBuild@1
119121
displayName: Sign VSIX
120122
inputs:
121123
solution: .\build\SignVsix.proj
122124
msbuildArguments: /p:SignType=$(SignType)
123125
# MicroBuild signing will always fail on public PRs.
124-
condition: ne(variables['Build.Reason'], 'PullRequest')
126+
# TODO: Signing the VSIX strips out the "main" executables for
127+
# serial-monitor-cli on Mac and Linux, completely breaking serial
128+
# functionality in the extension on these platforms. For now we disable VSIX
129+
# signing because it's not a strict requirement, but we should investigate
130+
# if we can either add extensions to these files or support extensionless
131+
# files in VSIX signing.
132+
condition: and(false, ne(variables['Build.Reason'], 'PullRequest'))
125133
- publish: $(Build.StagingDirectory)\vscode-arduino.vsix
126134
artifact: VS Code extension VSIX
127135
displayName: Publish extension VSIX as artifact

build/markExecutableFiles.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
import zipfile
3+
4+
staging_directory = os.getenv('BUILD_STAGINGDIRECTORY')
5+
input_archive_path = f"{staging_directory}/vscode-arduino.vsix"
6+
output_archive_path = f"{staging_directory}/vscode-arduino-out.vsix"
7+
8+
filenames = [
9+
"extension/out/serial-monitor-cli/darwin/main",
10+
"extension/out/serial-monitor-cli/linux/main"
11+
]
12+
13+
input_archive = zipfile.ZipFile(input_archive_path, 'r')
14+
output_archive = zipfile.ZipFile(output_archive_path, 'w')
15+
16+
executable_count = 0
17+
for info in input_archive.infolist():
18+
data = input_archive.read(info)
19+
if info.filename in filenames:
20+
# Magic number from from https://stackoverflow.com/a/48435482
21+
info.external_attr = 0o100755 << 16
22+
executable_count += 1
23+
output_archive.writestr(info, data)
24+
25+
if executable_count != len(filenames):
26+
raise Exception(f'Expected to find {len(filenames)} executables but only found {executable_count}')
27+
28+
input_archive.close()
29+
output_archive.close()
30+
31+
os.replace(output_archive_path, input_archive_path)

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,9 @@
482482
"description": "Path to a script relative to 'arduino.path', you can use a custom launch script to run Arduino by modifying this setting. Example: 'run-arduino.bat' for Windows, 'Contents/MacOS/run-arduino.sh' for Mac, 'bin/run-arduino.sh' for Linux. (Requires a restart after change)"
483483
},
484484
"arduino.additionalUrls": {
485-
"type": [
486-
"string",
487-
"array"
488-
],
489-
"description": "Additional URLs for 3-rd party packages. You can have multiple URLs in one string with comma(,) as separator, or have a string array."
485+
"type": "array",
486+
"items": { "type": "string" },
487+
"description": "Additional URLs for 3rd party packages."
490488
},
491489
"arduino.logLevel": {
492490
"type": "string",

src/arduino/arduino.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,15 @@ export class ArduinoApp {
495495
// return VscodeSettings.getInstance().useArduinoCli;
496496
}
497497

498+
/**
499+
* Checks if the line contains memory usage information
500+
* @param line output line to check
501+
* @returns {bool} true if line contains memory usage information
502+
*/
503+
private isMemoryUsageInformation(line: string) {
504+
return line.startsWith("Sketch uses ") || line.startsWith("Global variables use ");
505+
}
506+
498507
/**
499508
* Private implementation. Not to be called directly. The wrapper build()
500509
* manages the build state.
@@ -596,13 +605,10 @@ export class ArduinoApp {
596605
} else {
597606
args.push("--upload",
598607
"--useprogrammer",
599-
"--pref", `programmer=arduino:${programmer}`);
608+
"--pref", `programmer=${programmer}`);
600609
}
601610

602611
args.push("--port", dc.port);
603-
if (!this.useArduinoCli()) {
604-
args.push("--verify");
605-
}
606612
} else if (buildMode === BuildMode.CliUploadProgrammer) {
607613
const programmer = this.programmerManager.currentProgrammer;
608614
if (!programmer) {
@@ -735,6 +741,11 @@ export class ArduinoApp {
735741
}
736742
if (verbose) {
737743
arduinoChannel.channel.append(line);
744+
} else {
745+
// Output sketch memory usage in non-verbose mode
746+
if (this.isMemoryUsageInformation(line)) {
747+
arduinoChannel.channel.append(line);
748+
}
738749
}
739750
}
740751
const stderrcb = (line: string) => {

src/arduino/arduinoContentProvider.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,19 @@ export class ArduinoContentProvider implements vscode.TextDocumentContentProvide
155155
}
156156
}
157157

158-
public openSettings(req, res) {
159-
vscode.commands.executeCommand("workbench.action.openGlobalSettings");
160-
return res.json({
161-
status: "OK",
162-
});
158+
public async openSettings(req, res) {
159+
if (!req.body.query) {
160+
return res.status(400).send("BAD Request! Missing { query } parameter!");
161+
} else {
162+
try {
163+
await vscode.commands.executeCommand("workbench.action.openGlobalSettings", { query: req.body.query });
164+
return res.json({
165+
status: "OK",
166+
});
167+
} catch (error) {
168+
return res.status(500).send(`Cannot open the setting with error message "${error}"`);
169+
}
170+
}
163171
}
164172

165173
public async getLibraries(req, res) {

src/arduino/boardManager.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -518,26 +518,12 @@ export class BoardManager {
518518
}
519519

520520
private getAdditionalUrls(): string[] {
521-
function formatUrls(urls): string[] {
522-
if (urls) {
523-
let _urls: string[];
524-
525-
if (!Array.isArray(urls) && typeof urls === "string") {
526-
_urls = (<string>urls).split(",");
527-
} else {
528-
_urls = <string[]>urls;
529-
}
530-
531-
return util.trim(_urls);
532-
}
533-
return [];
534-
}
535521
// For better compatibility, merge urls both in user settings and arduino IDE preferences.
536-
const settingsUrls = formatUrls(VscodeSettings.getInstance().additionalUrls);
522+
const settingsUrls = VscodeSettings.getInstance().additionalUrls;
537523
let preferencesUrls = [];
538524
const preferences = this._settings.preferences;
539525
if (preferences && preferences.has("boardsmanager.additional.urls")) {
540-
preferencesUrls = formatUrls(preferences.get("boardsmanager.additional.urls"));
526+
preferencesUrls = util.toStringArray(preferences.get("boardsmanager.additional.urls"));
541527
}
542528
return util.union(settingsUrls, preferencesUrls);
543529
}

src/arduino/vscodeSettings.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license.
33

44
import * as vscode from "vscode";
5+
import { toStringArray } from "../common/util";
56

67
const configKeys = {
78
ARDUINO_PATH: "arduino.path",
@@ -23,7 +24,7 @@ const configKeys = {
2324
export interface IVscodeSettings {
2425
arduinoPath: string;
2526
commandPath: string;
26-
additionalUrls: string | string[];
27+
additionalUrls: string[];
2728
logLevel: string;
2829
clearOutputOnBuild: boolean;
2930
allowPDEFiletype: boolean;
@@ -34,7 +35,7 @@ export interface IVscodeSettings {
3435
defaultBaudRate: number;
3536
useArduinoCli: boolean;
3637
disableIntelliSenseAutoGen: boolean;
37-
updateAdditionalUrls(urls: string | string[]): void;
38+
updateAdditionalUrls(urls: string[]): void;
3839
}
3940

4041
export class VscodeSettings implements IVscodeSettings {
@@ -57,8 +58,20 @@ export class VscodeSettings implements IVscodeSettings {
5758
return this.getConfigValue<string>(configKeys.ARDUINO_COMMAND_PATH);
5859
}
5960

60-
public get additionalUrls(): string | string[] {
61-
return this.getConfigValue<string | string[]>(configKeys.ADDITIONAL_URLS);
61+
public get additionalUrls(): string[] {
62+
const value = this.getConfigValue<string | string[]>(configKeys.ADDITIONAL_URLS);
63+
64+
// Even though the schema says value must be a string array, version
65+
// 0.4.9 and earlier also allowed a single comma delimeted string. We
66+
// continue to unofficially support that format to avoid breaking
67+
// existing settings, but we immediately write back the correctly
68+
// formatted version.
69+
const split = toStringArray(value);
70+
if (typeof value === "string") {
71+
this.updateAdditionalUrls(split);
72+
}
73+
74+
return split;
6275
}
6376

6477
public get logLevel(): string {

src/common/util.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,16 @@ export function spawn(
207207

208208
let codepage = "65001";
209209
if (os.platform() === "win32") {
210-
try {
211-
const chcp = child_process.execSync("chcp.com");
212-
codepage = chcp.toString().split(":").pop().trim();
213-
} catch (error) {
214-
arduinoChannel.warning(`Defaulting to code page 850 because chcp.com failed.\
215-
\rEnsure your path includes %SystemRoot%\\system32\r${error.message}`);
216-
codepage = "850";
210+
codepage = getArduinoL4jCodepage(command.replace(/.exe$/i, ".l4j.ini"));
211+
if (!codepage) {
212+
try {
213+
const chcp = child_process.execSync("chcp.com");
214+
codepage = chcp.toString().split(":").pop().trim();
215+
} catch (error) {
216+
arduinoChannel.warning(`Defaulting to code page 850 because chcp.com failed.\
217+
\rEnsure your path includes %SystemRoot%\\system32\r${error.message}`);
218+
codepage = "850";
219+
}
217220
}
218221
}
219222

@@ -253,6 +256,16 @@ export function spawn(
253256
});
254257
}
255258

259+
export function getArduinoL4jCodepage(filePath: string): string | undefined {
260+
const encoding = parseConfigFile(filePath).get("-Dfile.encoding");
261+
if (encoding === "UTF8") {
262+
return "65001";
263+
}
264+
return Object.keys(encodingMapping).reduce((r, key) => {
265+
return encodingMapping[key] === encoding ? key : r;
266+
}, undefined);
267+
}
268+
256269
export function decodeData(data: Buffer, codepage: string): string {
257270
if (Object.prototype.hasOwnProperty.call(encodingMapping, codepage)) {
258271
return iconv.decode(data, encodingMapping[codepage]);
@@ -433,3 +446,25 @@ export function resolveMacArduinoAppPath(arduinoPath: string, useArduinoCli = fa
433446
return path.join(arduinoPath, "Arduino.app");
434447
}
435448
}
449+
450+
/**
451+
* If given an string, splits the string on commas. If given an array, returns
452+
* the array. All strings in the output are trimmed.
453+
* @param value String or string array to convert.
454+
* @returns Array of strings split from the input.
455+
*/
456+
export function toStringArray(value: string | string[]): string[] {
457+
if (value) {
458+
let result: string[];
459+
460+
if (typeof value === "string") {
461+
result = value.split(",");
462+
} else {
463+
result = <string[]>value;
464+
}
465+
466+
return trim(result);
467+
}
468+
469+
return [];
470+
}

0 commit comments

Comments
 (0)