fix: select the default llvm version based on ubuntu version

This commit is contained in:
Amin Yahyaabadi 2022-05-02 23:32:01 -07:00
parent bd5d402bb9
commit 05d55cbaa6
7 changed files with 100 additions and 2 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,12 +38,14 @@
"@actions/io": "^1.1.2", "@actions/io": "^1.1.2",
"@actions/tool-cache": "^1.7.2", "@actions/tool-cache": "^1.7.2",
"execa": "^5.1.1", "execa": "^5.1.1",
"make-synchronous": "^1.0.0",
"mri": "^1.2.0", "mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1", "msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3", "numerous": "1.0.3",
"semver": "7.3.7", "semver": "7.3.7",
"setup-python": "github:actions/setup-python#v3.1.2", "setup-python": "github:actions/setup-python#v3.1.2",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e", "time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ubuntu-version": "^2.0.0",
"untildify": "^4.0.0", "untildify": "^4.0.0",
"which": "^2.0.2" "which": "^2.0.2"
}, },

View File

@ -28,6 +28,7 @@ specifiers:
execa: ^5.1.1 execa: ^5.1.1
jest: ^27.5.1 jest: ^27.5.1
loose-ts-check: ^1.2.0 loose-ts-check: ^1.2.0
make-synchronous: ^1.0.0
mri: ^1.2.0 mri: ^1.2.0
msvc-dev-cmd: github:aminya/msvc-dev-cmd#9f672c1 msvc-dev-cmd: github:aminya/msvc-dev-cmd#9f672c1
npm-check-updates: ^12.5.9 npm-check-updates: ^12.5.9
@ -43,6 +44,7 @@ specifiers:
time-delta: github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e time-delta: github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e
ts-jest: ^27.1.4 ts-jest: ^27.1.4
typescript: ^4.6.3 typescript: ^4.6.3
ubuntu-version: ^2.0.0
untildify: ^4.0.0 untildify: ^4.0.0
which: ^2.0.2 which: ^2.0.2
@ -52,12 +54,14 @@ dependencies:
'@actions/io': 1.1.2 '@actions/io': 1.1.2
'@actions/tool-cache': 1.7.2 '@actions/tool-cache': 1.7.2
execa: 5.1.1 execa: 5.1.1
make-synchronous: 1.0.0
mri: 1.2.0 mri: 1.2.0
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1 msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
numerous: 1.0.3 numerous: 1.0.3
semver: 7.3.7 semver: 7.3.7
setup-python: github.com/actions/setup-python/98f2ad02fd48d057ee3b4d4f66525b231c3e52b6 setup-python: github.com/actions/setup-python/98f2ad02fd48d057ee3b4d4f66525b231c3e52b6
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
ubuntu-version: 2.0.0
untildify: 4.0.0 untildify: 4.0.0
which: 2.0.2 which: 2.0.2
@ -3118,6 +3122,13 @@ packages:
type-fest: 0.8.1 type-fest: 0.8.1
dev: true dev: true
/crypto-random-string/4.0.0:
resolution: {integrity: sha512-x8dy3RnvYdlUcPOjkEHqozhiwzKNSq7GcPuXFbnyMOCHxX8V3OgIg/pYuabl2sbUPfIJaeAQB7PMOK8DFIdoRA==}
engines: {node: '>=12'}
dependencies:
type-fest: 1.4.0
dev: false
/cspell-gitignore/5.19.7: /cspell-gitignore/5.19.7:
resolution: {integrity: sha512-rEqlN6wigNj4P/4Z3QCI1P56KhKkPtXNBpGMXC5CbxIK/NTtn3cLaqHKIZp92pypEnU077lxSCSqRRYCPbg/6A==} resolution: {integrity: sha512-rEqlN6wigNj4P/4Z3QCI1P56KhKkPtXNBpGMXC5CbxIK/NTtn3cLaqHKIZp92pypEnU077lxSCSqRRYCPbg/6A==}
engines: {node: '>=12.13.0'} engines: {node: '>=12.13.0'}
@ -3598,6 +3609,11 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dev: true dev: true
/escape-string-regexp/5.0.0:
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
engines: {node: '>=12'}
dev: false
/escodegen/2.0.0: /escodegen/2.0.0:
resolution: {integrity: sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==} resolution: {integrity: sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==}
engines: {node: '>=6.0'} engines: {node: '>=6.0'}
@ -5837,6 +5853,14 @@ packages:
- supports-color - supports-color
dev: true dev: true
/make-synchronous/1.0.0:
resolution: {integrity: sha512-IgPLsc2Pf6c7qiIGRQiE8ns0GaCdHmwfz1dJBqJAOwMN2naVp9+JlirSqNPYlGsDSrNRCgVqEiPOieaNqWxeqA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dependencies:
subsume: 4.0.0
type-fest: 2.12.2
dev: false
/makeerror/1.0.12: /makeerror/1.0.12:
resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==}
dependencies: dependencies:
@ -7566,6 +7590,14 @@ packages:
engines: {node: '>=8'} engines: {node: '>=8'}
dev: true dev: true
/subsume/4.0.0:
resolution: {integrity: sha512-BWnYJElmHbYZ/zKevy+TG+SsyoFCmRPDHJbR1MzLxkPOv1Jp/4hGhVUtP98s+wZBsBsHwCXvPTP0x287/WMjGg==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dependencies:
escape-string-regexp: 5.0.0
unique-string: 3.0.0
dev: false
/supports-color/5.5.0: /supports-color/5.5.0:
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
engines: {node: '>=4'} engines: {node: '>=4'}
@ -7843,6 +7875,16 @@ packages:
engines: {node: '>=8'} engines: {node: '>=8'}
dev: true dev: true
/type-fest/1.4.0:
resolution: {integrity: sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==}
engines: {node: '>=10'}
dev: false
/type-fest/2.12.2:
resolution: {integrity: sha512-qt6ylCGpLjZ7AaODxbpyBZSs9fCI9SkL3Z9q2oxMBQhs/uyY+VD8jHA8ULCGmWQJlBgqvO3EJeAngOHD8zQCrQ==}
engines: {node: '>=12.20'}
dev: false
/typedarray-to-buffer/3.1.5: /typedarray-to-buffer/3.1.5:
resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==}
dependencies: dependencies:
@ -7855,6 +7897,10 @@ packages:
hasBin: true hasBin: true
dev: true dev: true
/ubuntu-version/2.0.0:
resolution: {integrity: sha512-/IZMqVoMJ0Wl+vRJBlsIhbkpFlXnO9GdOk6zAiy0s4CyDJqpB/qp5T/ah4eoH1OL7ctNJN65nITtRIcbPCoU/w==}
dev: false
/unbox-primitive/1.0.1: /unbox-primitive/1.0.1:
resolution: {integrity: sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==} resolution: {integrity: sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==}
dependencies: dependencies:
@ -7883,6 +7929,13 @@ packages:
crypto-random-string: 2.0.0 crypto-random-string: 2.0.0
dev: true dev: true
/unique-string/3.0.0:
resolution: {integrity: sha512-VGXBUVwxKMBUznyffQweQABPRRW1vHZAbadFZud4pLFAqRGvv/96vafgjWFqzourzr8YonlQiPgH0YCJfawoGQ==}
engines: {node: '>=12'}
dependencies:
crypto-random-string: 4.0.0
dev: false
/unist-util-stringify-position/3.0.2: /unist-util-stringify-position/3.0.2:
resolution: {integrity: sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==} resolution: {integrity: sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==}
dependencies: dependencies:

View File

@ -1,3 +1,6 @@
import { warning } from "./utils/io/io"
import { ubuntuVersion } from "./utils/env/ubuntu_version"
const DefaultVersions: Record<string, string> = { const DefaultVersions: Record<string, string> = {
llvm: "13.0.0", // https://github.com/llvm/llvm-project/releases llvm: "13.0.0", // https://github.com/llvm/llvm-project/releases
clangtidy: "13.0.0", clangtidy: "13.0.0",
@ -14,6 +17,8 @@ const DefaultVersions: Record<string, string> = {
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11", // https://community.chocolatey.org/packages/mingw#versionhistory and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc gcc: process.platform === "win32" ? "11.2.0.07112021" : "11", // https://community.chocolatey.org/packages/mingw#versionhistory and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
} }
let ubuntuVersionCached: number[] | null = null
/** Get the default version if passed true or undefined, otherwise return the version itself */ /** Get the default version if passed true or undefined, otherwise return the version itself */
export function getVersion(name: string, version: string | undefined) { export function getVersion(name: string, version: string | undefined) {
if (version === "true" || (version === undefined && name in DefaultVersions)) { if (version === "true" || (version === undefined && name in DefaultVersions)) {
@ -22,3 +27,24 @@ export function getVersion(name: string, version: string | undefined) {
return version ?? "" return version ?? ""
} }
} }
export function defaultLLVMVersion(name: string) {
if (["llvm", "clangtidy", "clangformat"].includes(name)) {
if (process.platform === "linux") {
try {
// get the version if not already done
ubuntuVersionCached = ubuntuVersionCached ?? ubuntuVersion()
} catch (err) {
warning((err as Error).toString())
return DefaultVersions[name]
}
// choose the default version for llvm based on ubuntu
if (ubuntuVersionCached !== null) {
if ([20, 18, 16].includes(ubuntuVersionCached[0]) && ubuntuVersionCached[1] === 4) {
return `-13.0.0-x86_64-linux-gnu-ubuntu-${ubuntuVersionCached[0]}.0${ubuntuVersionCached[1]}`
}
}
}
}
return DefaultVersions[name]
}

View File

@ -124,6 +124,7 @@ const UBUNTU_RC: Map<string, string> = new Map()
* *
* https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.1 or https://releases.llvm.org/14.0.1 * https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.1 or https://releases.llvm.org/14.0.1
*/ */
// TODO change based on ubuntu version
const UBUNTU_SUFFIX_MAP: { [key: string]: string } = { const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
"3.5.0": "-ubuntu-14.04", "3.5.0": "-ubuntu-14.04",
"3.5.1": "", "3.5.1": "",

16
src/utils/env/ubuntu_version.ts vendored Normal file
View File

@ -0,0 +1,16 @@
import { getUbuntuVersion } from "ubuntu-version"
import makeSynchronous from "make-synchronous"
export function ubuntuVersion(): number[] | null {
if (process.platform === "linux") {
const versionSplitted = makeSynchronous(getUbuntuVersion)()
if (versionSplitted.length === 0) {
throw new Error("Failed to get the ubuntu major version.")
}
return versionSplitted
} else {
return null
}
}