Skip to content

Commit a990936

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Updated to 0.15.0-rc1 CLI and 12.x snapshot clangd.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 1f544b2 commit a990936

File tree

6 files changed

+61
-37
lines changed

6 files changed

+61
-37
lines changed

arduino-ide-extension/package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@
120120
],
121121
"arduino": {
122122
"cli": {
123-
"version": {
124-
"owner": "arduino",
125-
"repo": "arduino-cli"
126-
}
123+
"version": "0.15.0-rc1"
127124
}
128125
}
129126
}

arduino-ide-extension/scripts/download-ls.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(() => {
77

88
const DEFAULT_ALS_VERSION = 'nightly';
9-
const DEFAULT_CLANGD_VERSION = '9.0.0';
9+
const DEFAULT_CLANGD_VERSION = 'snapshot_20210124';
1010

1111
const path = require('path');
1212
const shell = require('shelljs');
@@ -22,7 +22,7 @@
2222
.option('clangd-version', {
2323
alias: 'cv',
2424
default: DEFAULT_CLANGD_VERSION,
25-
choices: ['8.0.1', '9.0.0'],
25+
choices: ['snapshot_20210124'],
2626
describe: `The version of 'clangd' to download. Defaults to ${DEFAULT_CLANGD_VERSION}.`
2727
})
2828
.option('force-download', {
@@ -38,35 +38,35 @@
3838
const { platform, arch } = process;
3939

4040
const build = path.join(__dirname, '..', 'build');
41-
const alsTarget = path.join(build, `arduino-language-server${platform === 'win32' ? '.exe' : ''}`);
41+
const lsExecutablePath = path.join(build, `arduino-language-server${platform === 'win32' ? '.exe' : ''}`);
4242

43-
let clangdTarget, alsSuffix, clangdSuffix;
43+
let clangdExecutablePath, lsSuffix, clangdPrefix;
4444
switch (platform) {
4545
case 'darwin':
46-
clangdTarget = path.join(build, 'bin', 'clangd')
47-
alsSuffix = 'Darwin_amd64.zip';
48-
clangdSuffix = 'macos.zip';
46+
clangdExecutablePath = path.join(build, 'bin', 'clangd')
47+
lsSuffix = 'macOS_amd64.zip';
48+
clangdPrefix = 'mac';
4949
break;
5050
case 'linux':
51-
clangdTarget = path.join(build, 'bin', 'clangd')
52-
alsSuffix = 'Linux_amd64.zip';
53-
clangdSuffix = 'linux.zip'
51+
clangdExecutablePath = path.join(build, 'bin', 'clangd')
52+
lsSuffix = 'Linux_amd64.zip';
53+
clangdPrefix = 'linux'
5454
break;
5555
case 'win32':
56-
clangdTarget = path.join(build, 'clangd.exe')
57-
alsSuffix = 'Windows_NT_amd64.zip';
58-
clangdSuffix = 'windows.zip';
56+
clangdExecutablePath = path.join(build, 'bin', 'clangd.exe')
57+
lsSuffix = 'Windows_amd64.zip';
58+
clangdPrefix = 'windows';
5959
break;
6060
}
61-
if (!alsSuffix) {
61+
if (!lsSuffix) {
6262
shell.echo(`The arduino-language-server is not available for ${platform} ${arch}.`);
6363
shell.exit(1);
6464
}
6565

66-
const alsUrl = `https://downloads.arduino.cc/arduino-language-server/${alsVersion === 'nightly' ? 'nightly/arduino-language-server' : 'arduino-language-server_' + alsVersion}_${alsSuffix}`;
67-
downloader.downloadUnzipAll(alsUrl, build, alsTarget, force);
66+
const alsUrl = `https://downloads.arduino.cc/arduino-language-server/${alsVersion === 'nightly' ? 'nightly/arduino-language-server' : 'arduino-language-server_' + alsVersion}_${lsSuffix}`;
67+
downloader.downloadUnzipAll(alsUrl, build, lsExecutablePath, force);
6868

69-
const clangdUrl = `https://downloads.arduino.cc/arduino-language-server/clangd/clangd_${clangdVersion}_${clangdSuffix}`;
70-
downloader.downloadUnzipAll(clangdUrl, build, clangdTarget, force);
69+
const clangdUrl = `https://downloads.arduino.cc/arduino-language-server/clangd/clangd-${clangdPrefix}-${clangdVersion}.zip`;
70+
downloader.downloadUnzipAll(clangdUrl, build, clangdExecutablePath, force, { strip: 1 }); // `strip`: the new clangd (12.x) is zipped into a folder, so we have to strip the outmost folder.
7171

7272
})();

arduino-ide-extension/scripts/downloader.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ exports.downloadUnzipFile = async (url, targetFile, filePrefix, force = false) =
7979
* @param targetFile {string} Path to the main file expected after decompressing
8080
* @param force {boolean} Whether to download even if the target file exists
8181
*/
82-
exports.downloadUnzipAll = async (url, targetDir, targetFile, force) => {
82+
exports.downloadUnzipAll = async (url, targetDir, targetFile, force, decompressOptions = undefined) => {
8383
if (fs.existsSync(targetFile) && !force) {
8484
shell.echo(`Skipping download because file already exists: ${targetFile}`);
8585
return;
@@ -96,12 +96,16 @@ exports.downloadUnzipAll = async (url, targetDir, targetFile, force) => {
9696
shell.echo(`<<< Download succeeded.`);
9797

9898
shell.echo('>>> Decompressing...');
99-
const files = await decompress(data, targetDir, {
99+
let options = {
100100
plugins: [
101101
unzip(),
102102
untargz()
103103
]
104-
});
104+
};
105+
if (decompressOptions) {
106+
options = Object.assign(options, decompressOptions)
107+
}
108+
const files = await decompress(data, targetDir, options);
105109
if (files.length === 0) {
106110
shell.echo('Error ocurred while decompressing the archive.');
107111
shell.exit(1);

arduino-ide-extension/scripts/generate-protocol.js

+33-9
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,48 @@
6666
const { platform } = process;
6767
const build = path.join(__dirname, '..', 'build');
6868
const cli = path.join(build, `arduino-cli${platform === 'win32' ? '.exe' : ''}`);
69-
const jsonVersion = shell.exec(`${cli} version --format json`).trim();
70-
if (!jsonVersion) {
69+
const versionJson = shell.exec(`${cli} version --format json`).trim();
70+
if (!versionJson) {
7171
shell.echo(`Could not retrieve the CLI version from ${cli}.`);
7272
shell.exit(1);
7373
}
74-
const version = JSON.parse(jsonVersion).VersionString;
75-
if (version && version !== '0.0.0-git') { // 0.0.0-git is the version of the CLI when built manually and not downloaded as a releases/nightly.
76-
shell.echo(`>>> Checking out version: ${version}...`);
77-
if (shell.exec(`git -C ${repository} checkout ${version} -b ${version}`).code !== 0) {
74+
// As of today (28.01.2021), the `VersionString` can be one of the followings:
75+
// - `nightly-YYYYMMDD` stands for the nightly build, we use the , the `commitish` from the `package.json` to check out the code.
76+
// - `0.0.0-git` for local builds, we use the `commitish` from the `package.json` to check out the code and generate the APIs.
77+
// - `git-snapshot` for local build executed via `task build`. We do not do this.
78+
// - rest, we assume it is a valid semver and has the corresponding tagged code, we use the tag to generate the APIs from the `proto` files.
79+
/*
80+
{
81+
"Application": "arduino-cli",
82+
"VersionString": "nightly-20210126",
83+
"Commit": "079bb6c6",
84+
"Status": "alpha",
85+
"Date": "2021-01-26T01:46:31Z"
86+
}
87+
*/
88+
const versionObject = JSON.parse(versionJson);
89+
const version = versionObject.VersionString;
90+
if (version && !version.startsWith('nightly-') && version !== '0.0.0-git' && version !== 'git-snapshot') {
91+
shell.echo(`>>> Checking out tagged version: '${version}'...`);
92+
shell.exec(`git -C ${repository} fetch --all --tags`);
93+
if (shell.exec(`git -C ${repository} checkout tags/${version} -b ${version}`).code !== 0) {
7894
shell.exit(1);
7995
}
80-
shell.echo(`<<< Checked out version: ${commitish}.`);
96+
shell.echo(`<<< Checked out tagged version: '${commitish}'.`);
8197
} else if (commitish) {
82-
shell.echo(`>>> Checking out commitish: ${commitish}...`);
98+
shell.echo(`>>> Checking out commitish from 'package.json': '${commitish}'...`);
8399
if (shell.exec(`git -C ${repository} checkout ${commitish}`).code !== 0) {
84100
shell.exit(1);
85101
}
86-
shell.echo(`<<< Checked out commitish: ${commitish}.`);
102+
shell.echo(`<<< Checked out commitish from 'package.json': '${commitish}'.`);
103+
} else if (versionObject.Commit) {
104+
shell.echo(`>>> Checking out commitish from the CLI: '${versionObject.Commit}'...`);
105+
if (shell.exec(`git -C ${repository} checkout ${versionObject.Commit}`).code !== 0) {
106+
shell.exit(1);
107+
}
108+
shell.echo(`<<< Checked out commitish from the CLI: '${versionObject.Commit}'.`);
109+
} else {
110+
shell.echo(`WARN: no 'git checkout'. Generating from the HEAD revision.`);
87111
}
88112

89113
shell.echo('>>> Generating TS/JS API from:');

arduino-ide-extension/src/node/executable-service-impl.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as os from 'os';
21
import { injectable, inject } from 'inversify';
32
import { ILogger } from '@theia/core/lib/common/logger';
43
import { FileUri } from '@theia/core/lib/node/file-uri';
@@ -14,7 +13,7 @@ export class ExecutableServiceImpl implements ExecutableService {
1413
async list(): Promise<{ clangdUri: string, cliUri: string, lsUri: string }> {
1514
const [ls, clangd, cli] = await Promise.all([
1615
getExecPath('arduino-language-server', this.onError.bind(this)),
17-
getExecPath('clangd', this.onError.bind(this), undefined, os.platform() !== 'win32'),
16+
getExecPath('clangd', this.onError.bind(this), undefined, true),
1817
getExecPath('arduino-cli', this.onError.bind(this))
1918
]);
2019
return {

arduino-ide-extension/src/test/node/exec-util.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('getExecPath', () => {
1919
});
2020

2121
it('should resolve clangd', async () => {
22-
const actual = await getExecPath('clangd', onError, '--version', os.platform() !== 'win32');
22+
const actual = await getExecPath('clangd', onError, '--version', true);
2323
const expected = os.platform() === 'win32' ? '\\clangd.exe' : '/clangd';
2424
expect(actual).to.endsWith(expected);
2525
});

0 commit comments

Comments
 (0)