|
4 | 4 | // - https://downloads.arduino.cc/arduino-language-server/clangd/clangd_${VERSION}_${SUFFIX}
|
5 | 5 |
|
6 | 6 | (() => {
|
| 7 | + const DEFAULT_ALS_VERSION = '0.5.0-rc2'; |
| 8 | + const DEFAULT_CLANGD_VERSION = 'snapshot_20210124'; |
7 | 9 |
|
8 |
| - const DEFAULT_ALS_VERSION = 'nightly'; |
9 |
| - const DEFAULT_CLANGD_VERSION = 'snapshot_20210124'; |
| 10 | + const path = require('path'); |
| 11 | + const shell = require('shelljs'); |
| 12 | + const downloader = require('./downloader'); |
10 | 13 |
|
11 |
| - const path = require('path'); |
12 |
| - const shell = require('shelljs'); |
13 |
| - const downloader = require('./downloader'); |
| 14 | + const yargs = require('yargs') |
| 15 | + .option('ls-version', { |
| 16 | + alias: 'lv', |
| 17 | + default: DEFAULT_ALS_VERSION, |
| 18 | + describe: `The version of the 'arduino-language-server' to download. Defaults to ${DEFAULT_ALS_VERSION}.`, |
| 19 | + }) |
| 20 | + .option('clangd-version', { |
| 21 | + alias: 'cv', |
| 22 | + default: DEFAULT_CLANGD_VERSION, |
| 23 | + choices: ['snapshot_20210124'], |
| 24 | + describe: `The version of 'clangd' to download. Defaults to ${DEFAULT_CLANGD_VERSION}.`, |
| 25 | + }) |
| 26 | + .option('force-download', { |
| 27 | + alias: 'fd', |
| 28 | + default: false, |
| 29 | + describe: `If set, this script force downloads the 'arduino-language-server' even if it already exists on the file system.`, |
| 30 | + }) |
| 31 | + .version(false) |
| 32 | + .parse(); |
14 | 33 |
|
15 |
| - const yargs = require('yargs') |
16 |
| - .option('ls-version', { |
17 |
| - alias: 'lv', |
18 |
| - default: DEFAULT_ALS_VERSION, |
19 |
| - choices: ['nightly'], |
20 |
| - describe: `The version of the 'arduino-language-server' to download. Defaults to ${DEFAULT_ALS_VERSION}.` |
21 |
| - }) |
22 |
| - .option('clangd-version', { |
23 |
| - alias: 'cv', |
24 |
| - default: DEFAULT_CLANGD_VERSION, |
25 |
| - choices: ['snapshot_20210124'], |
26 |
| - describe: `The version of 'clangd' to download. Defaults to ${DEFAULT_CLANGD_VERSION}.` |
27 |
| - }) |
28 |
| - .option('force-download', { |
29 |
| - alias: 'fd', |
30 |
| - default: false, |
31 |
| - describe: `If set, this script force downloads the 'arduino-language-server' even if it already exists on the file system.` |
32 |
| - }) |
33 |
| - .version(false).parse(); |
| 34 | + const alsVersion = yargs['ls-version']; |
| 35 | + const clangdVersion = yargs['clangd-version']; |
| 36 | + const force = yargs['force-download']; |
| 37 | + const { platform, arch } = process; |
34 | 38 |
|
35 |
| - const alsVersion = yargs['ls-version']; |
36 |
| - const clangdVersion = yargs['clangd-version'] |
37 |
| - const force = yargs['force-download']; |
38 |
| - const { platform, arch } = process; |
| 39 | + const build = path.join(__dirname, '..', 'build'); |
| 40 | + const lsExecutablePath = path.join( |
| 41 | + build, |
| 42 | + `arduino-language-server${platform === 'win32' ? '.exe' : ''}` |
| 43 | + ); |
39 | 44 |
|
40 |
| - const build = path.join(__dirname, '..', 'build'); |
41 |
| - const lsExecutablePath = path.join(build, `arduino-language-server${platform === 'win32' ? '.exe' : ''}`); |
| 45 | + let clangdExecutablePath, lsSuffix, clangdPrefix; |
| 46 | + switch (platform) { |
| 47 | + case 'darwin': |
| 48 | + clangdExecutablePath = path.join(build, 'bin', 'clangd'); |
| 49 | + lsSuffix = 'macOS_64bit.tar.gz'; |
| 50 | + clangdPrefix = 'mac'; |
| 51 | + break; |
| 52 | + case 'linux': |
| 53 | + clangdExecutablePath = path.join(build, 'bin', 'clangd'); |
| 54 | + lsSuffix = 'Linux_64bit.tar.gz'; |
| 55 | + clangdPrefix = 'linux'; |
| 56 | + break; |
| 57 | + case 'win32': |
| 58 | + clangdExecutablePath = path.join(build, 'bin', 'clangd.exe'); |
| 59 | + lsSuffix = 'Windows_64bit.zip'; |
| 60 | + clangdPrefix = 'windows'; |
| 61 | + break; |
| 62 | + } |
| 63 | + if (!lsSuffix) { |
| 64 | + shell.echo( |
| 65 | + `The arduino-language-server is not available for ${platform} ${arch}.` |
| 66 | + ); |
| 67 | + shell.exit(1); |
| 68 | + } |
42 | 69 |
|
43 |
| - let clangdExecutablePath, lsSuffix, clangdPrefix; |
44 |
| - switch (platform) { |
45 |
| - case 'darwin': |
46 |
| - clangdExecutablePath = path.join(build, 'bin', 'clangd') |
47 |
| - lsSuffix = 'macOS_amd64.zip'; |
48 |
| - clangdPrefix = 'mac'; |
49 |
| - break; |
50 |
| - case 'linux': |
51 |
| - clangdExecutablePath = path.join(build, 'bin', 'clangd') |
52 |
| - lsSuffix = 'Linux_amd64.zip'; |
53 |
| - clangdPrefix = 'linux' |
54 |
| - break; |
55 |
| - case 'win32': |
56 |
| - clangdExecutablePath = path.join(build, 'bin', 'clangd.exe') |
57 |
| - lsSuffix = 'Windows_amd64.zip'; |
58 |
| - clangdPrefix = 'windows'; |
59 |
| - break; |
60 |
| - } |
61 |
| - if (!lsSuffix) { |
62 |
| - shell.echo(`The arduino-language-server is not available for ${platform} ${arch}.`); |
63 |
| - shell.exit(1); |
64 |
| - } |
65 |
| - |
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); |
68 |
| - |
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. |
| 70 | + const alsUrl = `https://downloads.arduino.cc/arduino-language-server/${ |
| 71 | + alsVersion === 'nightly' |
| 72 | + ? 'nightly/arduino-language-server' |
| 73 | + : 'arduino-language-server_' + alsVersion |
| 74 | + }_${lsSuffix}`; |
| 75 | + downloader.downloadUnzipAll(alsUrl, build, lsExecutablePath, force); |
71 | 76 |
|
| 77 | + const clangdUrl = `https://downloads.arduino.cc/arduino-language-server/clangd/clangd-${clangdPrefix}-${clangdVersion}.zip`; |
| 78 | + downloader.downloadUnzipAll(clangdUrl, build, clangdExecutablePath, force, { |
| 79 | + strip: 1, |
| 80 | + }); // `strip`: the new clangd (12.x) is zipped into a folder, so we have to strip the outmost folder. |
72 | 81 | })();
|
0 commit comments