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

Commit dd58157

Browse files
Merge branch 'main' of https://github.com/microsoft/vscode-arduino into dev/gcampbell/UpdateSerialMonitor2.0
2 parents 322cad4 + 2ec8a74 commit dd58157

31 files changed

+462
-65
lines changed

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ jobs:
7272
- name: Check for linting errors
7373
run: gulp tslint
7474
- name: Build and pack extension
75-
run: vsce package --out vscode-arduino.vsix
75+
run: node build/package.js
7676
- name: Publish extension VSIX as artifact
7777
uses: actions/upload-artifact@v2
7878
with:
79-
name: VS Code extension VSIX (${{ matrix.os }})
80-
path: vscode-arduino.vsix
79+
name: VS Code extension VSIXes (${{ matrix.os }})
80+
path: out/vsix
8181

8282
- name: Run tests
8383
uses: GabrielBB/xvfb-action@v1

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules
66
src/views/app/sprites-generated
77
test/**/c_cpp_properties.json
88
*.vsix
9+
assets/platform/*/arduino-cli

.vscodeignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ webpack.config.js
1717
node_modules/**
1818
vendor/**
1919
azure-pipelines.yml
20-
build/**
20+
build/**
21+
assets/platform/**
22+
23+
# A platform-specific directory in assets/platform/ will be added to the end of
24+
# this file by the packaging script.

NOTICE_arduino-cli.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NOTICES AND INFORMATION
2+
Do Not Translate or Localize
3+
4+
Microsoft makes the arduino-cli open source code available at
5+
https://3rdpartysource.microsoft.com, or you may send a check or money order for
6+
US $5.00, including the product name, the open source component name, platform,
7+
and version number, to:
8+
9+
Source Code Compliance Team
10+
Microsoft Corporation
11+
One Microsoft Way
12+
Redmond, WA 98052
13+
USA
14+
15+
Notwithstanding any other terms, you may reverse engineer this software to the extent
16+
required to debug changes to any libraries licensed under the GNU Lesser General Public License.

README.md

+26-16
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,31 @@ Welcome to the Visual Studio Code extension for **Arduino** <sup>preview</sup> !
1515
* Integrated Arduino Debugging <sup>New</sup>
1616

1717
## Prerequisites
18-
Either the Arduino IDE or Arduino CLI are required.
18+
Either the legacy Arduino IDE or Arduino CLI are required. The recommended
19+
approach is to use the version of Arduino CLI that comes bundled with the
20+
extension, which works out of the box. Support for the legacy Arduino IDE will
21+
be removed in a future version of the extension.
1922

20-
### Arduino IDE
21-
The Arduino IDE can be installed the Arduino [download page](https://www.arduino.cc/en/main/software#download).
22-
- The supported Arduino IDE versions are `1.6.x` and up to, but not including, 2.0.0.
23+
### Arduino CLI
24+
To use the bundled version of Arduino CLI, `arduino.useArduinoCli` should be `true`,
25+
and `arduino.path` and `arduino.commandPath` should be empty or unset.
26+
`arduino.useArduinoCli` defaults to `false` while we deprecate support for the
27+
Arduino IDE, but there will be a prompt when the extension first activates to
28+
switch to the Arduino CLI.
29+
30+
If you want to use a custom version of Arduino CLI, it can be downloaded from
31+
the repository's [release page](https://github.com/arduino/arduino-cli/releases/).
32+
For custom versions, `arduino.path` must be set to the directory containing the
33+
Arduino CLI executable.
34+
35+
### Legacy Arduino IDE
36+
Use of the legacy Arduino IDE is not recommended, and support for the legacy
37+
Arduino IDE will be removed in a future version of the extension. The legacy
38+
Arduino IDE can be installed from the Arduino [download page](https://www.arduino.cc/en/main/software#download).
39+
- The supported legacy Arduino IDE versions are `1.6.x` and up to, but not including, `2.0.0`.
2340
- The Windows Store's version of the Arduino IDE is not supported because of the sandbox environment that the application runs in.
2441
- *Note:* Arduino IDE `1.8.7` had some breaking changes, causing board package and library installation failures. These failures were corrected in `1.8.8` and later.
25-
- *Note:* Arduino IDE `2.X.Y` is not supported at this time [issue 1477](https://github.com/microsoft/vscode-arduino/issues/1477)
26-
27-
### Arduino CLI
28-
The Arduino CLI can be downloaded from the repository's [release page](https://github.com/arduino/arduino-cli/releases/tag/0.13.0)
29-
- The extension has only been tested with v0.13.0.
30-
- If you use the CLI you will have to set `arduino.path` since the CLI does not have a default path.
42+
- *Note:* Arduino IDE `2.X.Y` is not supported and there are no plans for support in the future ([issue 1477](https://github.com/microsoft/vscode-arduino/issues/1477)).
3143

3244
## Installation
3345
Open VS Code and press <kbd>F1</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> *or* <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> to open command palette, select **Install Extension** and type `vscode-arduino`.
@@ -69,9 +81,9 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
6981
## Options
7082
| Option | Description |
7183
| --- | --- |
72-
| `arduino.useArduinoCli` | Whether to use the Arduino CLI (`true`) or the Arduino IDE (`false`) -- defaults to `false`. If using `true`, make sure to set the `arduino.path` and `arduino.commandPath` values correctly. |
73-
| `arduino.path` | Path to the Arduino installation. 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. To use the Arduino CLI, use the path that contains the `arduino-cli` executable (e.g. `/usr/local/bin`). |
74-
| `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. To use the Arduino CLI, use `arduino-cli`. |
84+
| `arduino.useArduinoCli` | Whether to use the Arduino CLI (`true`) or the legacy Arduino IDE (`false`) -- defaults to `false`. If using `true`, either leave the `arduino.path` and `arduino.commandPath` values unset to use the bundled version of Arduino CLI, or point them at a custom version of Arduino CLI. Note that a future version of the extension will change this default to `true` and remove support for legacy Arduino IDE. |
85+
| `arduino.path` | Path to the Arduino installation. 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 legacy Arduino IDE installation path. To use the Arduino CLI, use the path that contains the `arduino-cli` executable (e.g. `/usr/local/bin`), or leave it unset to use the bundled version of Arduino CLI. |
86+
| `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. To use the bundled version of Arduino CLI, leave this option unset. To use a custom version of Arduino CLI, use `arduino-cli`. |
7587
| `arduino.additionalUrls` | Additional Boards Manager URLs for 3rd party packages as a string array. The default value is empty. |
7688
| `arduino.logLevel` | CLI output log level. Could be info or verbose. The default value is `"info"`. |
7789
| `arduino.clearOutputOnBuild` | Clear the output logs before uploading or verifying. Default value is `false`. |
@@ -87,8 +99,7 @@ The following Visual Studio Code settings are available for the Arduino extensio
8799

88100
```json
89101
{
90-
"arduino.path": "C:/Program Files (x86)/Arduino",
91-
"arduino.commandPath": "arduino_debug.exe",
102+
"arduino.useArduinoCli": true,
92103
"arduino.logLevel": "info",
93104
"arduino.allowPDEFiletype": false,
94105
"arduino.enableUSBDetection": true,
@@ -100,7 +111,6 @@ The following Visual Studio Code settings are available for the Arduino extensio
100111
],
101112
}
102113
```
103-
*Note:* You only need to set `arduino.path` in Visual Studio Code settings, other options are not required.
104114

105115
The following settings are as per sketch settings of the Arduino extension. You can find them in
106116
`.vscode/arduino.json` under the workspace.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on alpine-arm64.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on alpine-x64.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on darwin-arm64.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on darwin-x64.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on linux-arm64.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on linux-armhf.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on linux-x64.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on win32-arm64.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on win32-ia32.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a placeholder file that should only be installed on win32-x64.

azure-pipelines.yml

+20-18
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ steps:
6666
displayName: Use Node 16.x
6767
inputs:
6868
versionSpec: 16.x
69-
- script: npm install --global gulp node-gyp vsce
69+
- script: npm install --global gulp node-gyp @vscode/vsce
7070
displayName: Install global dependencies
7171
- script: npm install
7272
displayName: Install project dependencies
@@ -87,15 +87,19 @@ steps:
8787
# Pack the extension now even though it's unsigned so that we ignore files
8888
# from .vscodeignore. This will reduce load on the signing server later and
8989
# ensure we only attempt to sign shipping files.
90-
- script: vsce package --out vscode-arduino.vsix
90+
- script: node build/package.js
9191
displayName: Build and pack extension
9292

93-
# Extract the VSIX, sign what we can, then pack it back up and publish it.
94-
- task: ExtractFiles@1
93+
# Extract the VSIXes, sign what we can, then pack it back up and publish it.
94+
- pwsh: |
95+
$path = Join-Path $Env:TEMP "7z-installer.exe"
96+
Invoke-WebRequest https://www.7-zip.org/a/7z2201-x64.exe -OutFile $path
97+
Start-Process -FilePath $path -Args "/S" -Verb RunAs -Wait
98+
Remove-Item $path
99+
Echo "##vso[task.prependpath]$Env:PROGRAMFILES\7-Zip\"
100+
displayName: Install 7zip
101+
- pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z x $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$($_.BaseName) }
95102
displayName: Extract extension for signing
96-
inputs:
97-
archiveFilePatterns: vscode-arduino.vsix
98-
destinationFolder: $(Build.StagingDirectory)\vscode-arduino
99103
- task: NuGetToolInstaller@1
100104
displayName: Install NuGet
101105
- task: NuGetAuthenticate@0
@@ -111,23 +115,21 @@ steps:
111115
msbuildArguments: /p:SignType=$(SignType)
112116
# MicroBuild signing will always fail on public PRs.
113117
condition: ne(variables['Build.Reason'], 'PullRequest')
114-
- task: ArchiveFiles@2
118+
- pwsh: |
119+
Get-ChildItem -Directory $(Build.StagingDirectory)\vscode-arduino | Foreach-Object { 7z a ($_.FullName + ".vsix") ($_.FullName + "\*") -tzip }
120+
New-Item -Path $(Build.StagingDirectory)\vscode-arduino\vsix -ItemType Directory
121+
Get-Item $(Build.StagingDirectory)\vscode-arduino\*.vsix | Move-Item -Destination $(Build.StagingDirectory)\vscode-arduino\vsix
115122
displayName: Pack signed files
116-
inputs:
117-
rootFolderOrFile: $(Build.StagingDirectory)\vscode-arduino
118-
includeRootFolder: false
119-
archiveType: zip
120-
archiveFile: $(Build.StagingDirectory)\vscode-arduino.vsix
121123
- task: MSBuild@1
122-
displayName: Sign VSIX
124+
displayName: Sign VSIXes
123125
inputs:
124126
solution: .\build\SignVsix.proj
125127
msbuildArguments: /p:SignType=$(SignType)
126128
# MicroBuild signing will always fail on public PRs.
127129
condition: ne(variables['Build.Reason'], 'PullRequest')
128-
- publish: $(Build.StagingDirectory)\vscode-arduino.vsix
129-
artifact: VS Code extension VSIX
130-
displayName: Publish extension VSIX as artifact
130+
- publish: $(Build.StagingDirectory)\vscode-arduino\vsix
131+
artifact: VS Code extension VSIXes
132+
displayName: Publish extension VSIXes as artifact
131133

132134
# Install the Arduino IDE and run tests.
133135
- script: curl -LO https://downloads.arduino.cc/arduino-1.8.19-windows.zip
@@ -186,7 +188,7 @@ steps:
186188
action: create
187189
target: $(Build.SourceVersion)
188190
tagSource: auto
189-
assets: $(Build.StagingDirectory)\vscode-arduino.vsix
191+
assets: $(Build.StagingDirectory)\vscode-arduino\vsix\*.vsix
190192
isPreRelease: $[contains(variables['Build.SourceBranch'], '-rc')]
191193
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags'))
192194

build/SignFiles.proj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="packages\Microsoft.VisualStudioEng.MicroBuild.Core.0.4.1\build\Microsoft.VisualStudioEng.MicroBuild.Core.props" />
44

55
<PropertyGroup>
6-
<BaseOutputDirectory>$(BUILD_STAGINGDIRECTORY)\vscode-arduino\extension</BaseOutputDirectory>
6+
<BaseOutputDirectory>$(BUILD_STAGINGDIRECTORY)\vscode-arduino</BaseOutputDirectory>
77
<!-- These properties are required by MicroBuild, which only signs files that are under these paths -->
88
<IntermediateOutputPath>$(BaseOutputDirectory)</IntermediateOutputPath>
99
<OutDir>$(BaseOutputDirectory)</OutDir>

build/SignVsix.proj

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<Import Project="packages\Microsoft.VisualStudioEng.MicroBuild.Core.0.4.1\build\Microsoft.VisualStudioEng.MicroBuild.Core.props" />
44

55
<PropertyGroup>
6-
<BaseOutputDirectory>$(BUILD_STAGINGDIRECTORY)</BaseOutputDirectory>
6+
<BaseOutputDirectory>$(BUILD_STAGINGDIRECTORY)\vscode-arduino\vsix</BaseOutputDirectory>
77
<!-- These properties are required by MicroBuild, which only signs files that are under these paths -->
88
<IntermediateOutputPath>$(BaseOutputDirectory)</IntermediateOutputPath>
99
<OutDir>$(BaseOutputDirectory)</OutDir>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<FilesToSign Include="$(OutDir)\vscode-arduino.vsix">
13+
<FilesToSign Include="$(OutDir)\*.vsix">
1414
<Authenticode>VsixSHA2</Authenticode>
1515
</FilesToSign>
1616
</ItemGroup>

build/assets.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": "0.30.0",
3+
"assets": {
4+
"arduino-cli_0.30.0_Linux_64bit.tar.gz": {
5+
"hash": "f6b1cddf3459b1b6ca9dafe36315c2fa1f6f77386ab3795bbad6a117cbe4230b",
6+
"platforms": ["linux-x64"]
7+
},
8+
"arduino-cli_0.30.0_Linux_ARM64.tar.gz": {
9+
"hash": "20d2d036a5af4586b5a046f65d926ed012f7fd85469b484a5fc57ef9ef72fb4b",
10+
"platforms": ["linux-arm64"]
11+
},
12+
"arduino-cli_0.30.0_Linux_ARMv7.tar.gz": {
13+
"hash": "1d873f3cb2b939b2df5a7d25e998bded9a4f0c8ac1226d1d5f9abc2bd95a66c3",
14+
"platforms": ["linux-armhf"]
15+
},
16+
"arduino-cli_0.30.0_macOS_64bit.tar.gz": {
17+
"hash": "ece83e0bd15813e728d07ce584388a278d62e54529deb84ad07d1521bfe74748",
18+
"platforms": ["darwin-x64"]
19+
},
20+
"arduino-cli_0.30.0_macOS_ARM64.tar.gz": {
21+
"hash": "e6c1a35df995ecb464ffa85fe8a96b82bd06135ea5ae961cb34d9c9e99e6c2fa",
22+
"platforms": ["darwin-arm64"]
23+
},
24+
"arduino-cli_0.30.0_Windows_32bit.zip": {
25+
"hash": "cccd4b90524581783cf78a3e4942a5c6bf7508a2a5ec4e008bb9c43f1cdb5dbe",
26+
"platforms": ["win32-ia32"]
27+
},
28+
"arduino-cli_0.30.0_Windows_64bit.zip": {
29+
"hash": "1808d288382f16594ad73f4797303058b2074b1b375fbb19fca0978033a633af",
30+
"platforms": ["win32-x64"]
31+
}
32+
}
33+
}

build/downloadAssets.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
// This script downloads and verifies platform-specific arduino-cli binaries
5+
// from GitHub releases. The release is specified by the "version" field in
6+
// assets.json.
7+
8+
const { execSync } = require("child_process");
9+
const { createHash } = require("crypto");
10+
const { readFileSync, mkdirSync, rmSync, renameSync } = require("fs");
11+
const { resolve } = require("path");
12+
13+
function run(command) {
14+
console.log(command);
15+
execSync(command);
16+
}
17+
18+
const config = require('./assets.json');
19+
20+
for (const asset in config.assets) {
21+
if (Object.hasOwnProperty.call(config.assets, asset)) {
22+
const platforms = config.assets[asset].platforms;
23+
const hash = config.assets[asset].hash;
24+
for (const platform of platforms) {
25+
const directory = resolve(__dirname, "..", "assets", "platform", platform);
26+
const destination = resolve(directory, asset);
27+
28+
// Download the asset.
29+
run([
30+
"curl",
31+
`https://github.com/arduino/arduino-cli/releases/download/${config.version}/${asset}`,
32+
"--location",
33+
`--output-dir ${directory}`,
34+
`--remote-name`,
35+
"--silent",
36+
"--show-error",
37+
].join(" "));
38+
39+
// Verify the hash.
40+
const actualHash = createHash("sha256")
41+
.update(readFileSync(destination))
42+
.digest("hex");
43+
if (actualHash !== hash) {
44+
throw new Error(
45+
`Hash mismatch for ${asset} on ${platform}. Expected ${hash} but got ${actualHash}.`
46+
);
47+
}
48+
49+
// Extract to an "arduino-cli" directory.
50+
const extractDirectory = resolve(directory, "arduino-cli");
51+
mkdirSync(extractDirectory, { recursive: true });
52+
// tar on Linux doesn't understand zip files.
53+
if (asset.endsWith(".zip") && process.platform === 'linux') {
54+
run(`unzip ${destination} -d ${extractDirectory}`);
55+
} else {
56+
run(`tar -xf ${destination} -C ${extractDirectory}`);
57+
}
58+
59+
// Remove the downloaded archive. We don't need to ship it.
60+
rmSync(destination);
61+
62+
// VSIX signing will silently strip any extensionless files. Artificially
63+
// add a ".app" extension to extensionless executables.
64+
const executable = resolve(extractDirectory, "arduino-cli");
65+
try {
66+
renameSync(executable, `${executable}.app`);
67+
} catch {
68+
// The file might not exist. This is expected for Windows.
69+
}
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)