Merge pull request #66 from aminya/llvm-14-0-1 [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-05-03 01:14:17 -07:00 committed by GitHub
commit f0f45dad3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 82 additions and 12 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

@ -15,7 +15,7 @@
"build": "shx rm -rf dist/ && shx mkdir ./dist && run-p test.tsc build.parcel copy.matchers",
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .",
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report",
"bump": "ncu -u -x execa && pnpm update",
"bump": "ncu -u -x execa,make-synchronous && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe",
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/ && shx cp ./src/llvm/llvm_matcher.json ./dist/ ",
"dev": "cross-env NODE_ENV=development parcel watch",
@ -38,12 +38,14 @@
"@actions/io": "^1.1.2",
"@actions/tool-cache": "^1.7.2",
"execa": "^5.1.1",
"make-synchronous": "^0.1.1",
"mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3",
"semver": "7.3.7",
"setup-python": "github:actions/setup-python#v3.1.2",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ubuntu-version": "^2.0.0",
"untildify": "^4.0.0",
"which": "^2.0.2"
},

View File

@ -28,6 +28,7 @@ specifiers:
execa: ^5.1.1
jest: ^27.5.1
loose-ts-check: ^1.2.0
make-synchronous: ^0.1.1
mri: ^1.2.0
msvc-dev-cmd: github:aminya/msvc-dev-cmd#9f672c1
npm-check-updates: ^12.5.9
@ -43,6 +44,7 @@ specifiers:
time-delta: github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e
ts-jest: ^27.1.4
typescript: ^4.6.3
ubuntu-version: ^2.0.0
untildify: ^4.0.0
which: ^2.0.2
@ -52,12 +54,14 @@ dependencies:
'@actions/io': 1.1.2
'@actions/tool-cache': 1.7.2
execa: 5.1.1
make-synchronous: 0.1.1
mri: 1.2.0
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
numerous: 1.0.3
semver: 7.3.7
setup-python: github.com/actions/setup-python/98f2ad02fd48d057ee3b4d4f66525b231c3e52b6
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
ubuntu-version: 2.0.0
untildify: 4.0.0
which: 2.0.2
@ -3109,7 +3113,6 @@ packages:
/crypto-random-string/2.0.0:
resolution: {integrity: sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==}
engines: {node: '>=8'}
dev: true
/crypto-random-string/3.3.1:
resolution: {integrity: sha512-5j88ECEn6h17UePrLi6pn1JcLtAiANa3KExyr9y9Z5vo2mv56Gh3I4Aja/B9P9uyMwyxNHAHWv+nE72f30T5Dg==}
@ -3591,7 +3594,6 @@ packages:
/escape-string-regexp/2.0.0:
resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==}
engines: {node: '>=8'}
dev: true
/escape-string-regexp/4.0.0:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
@ -5837,6 +5839,14 @@ packages:
- supports-color
dev: true
/make-synchronous/0.1.1:
resolution: {integrity: sha512-Y4SxxqhaoyMDokJQ0AZz0E+bLhRkOSR7Z/IQoTKPdS6HYi3aobal2kMHoHHoqBadPWjf07P4K1FQLXOx3wf9Yw==}
engines: {node: '>=12'}
dependencies:
subsume: 3.0.0
type-fest: 0.16.0
dev: false
/makeerror/1.0.12:
resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==}
dependencies:
@ -7566,6 +7576,14 @@ packages:
engines: {node: '>=8'}
dev: true
/subsume/3.0.0:
resolution: {integrity: sha512-6n/UfV8UWKwJNO8OAOiKntwEMihuBeeoJfzpL542C+OuvT4iWG9SwjrXkOmsxjb4SteHUsos9SvrdqZ9+ICwTQ==}
engines: {node: '>=8'}
dependencies:
escape-string-regexp: 2.0.0
unique-string: 2.0.0
dev: false
/supports-color/5.5.0:
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
engines: {node: '>=4'}
@ -7823,6 +7841,11 @@ packages:
engines: {node: '>=4'}
dev: true
/type-fest/0.16.0:
resolution: {integrity: sha512-eaBzG6MxNzEn9kiwvtre90cXaNLkmadMWa1zQMs3XORCXNbsH/OewwbxC5ia9dCxIxnTAsSxXJaa/p5y8DlvJg==}
engines: {node: '>=10'}
dev: false
/type-fest/0.20.2:
resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==}
engines: {node: '>=10'}
@ -7855,6 +7878,10 @@ packages:
hasBin: true
dev: true
/ubuntu-version/2.0.0:
resolution: {integrity: sha512-/IZMqVoMJ0Wl+vRJBlsIhbkpFlXnO9GdOk6zAiy0s4CyDJqpB/qp5T/ah4eoH1OL7ctNJN65nITtRIcbPCoU/w==}
dev: false
/unbox-primitive/1.0.1:
resolution: {integrity: sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==}
dependencies:
@ -7881,7 +7908,6 @@ packages:
engines: {node: '>=8'}
dependencies:
crypto-random-string: 2.0.0
dev: true
/unist-util-stringify-position/3.0.2:
resolution: {integrity: sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==}

View File

@ -1,3 +1,6 @@
import { warning } from "./utils/io/io"
import { ubuntuVersion } from "./utils/env/ubuntu_version"
const DefaultVersions: Record<string, string> = {
llvm: "13.0.0", // https://github.com/llvm/llvm-project/releases
clangtidy: "13.0.0",
@ -14,9 +17,28 @@ 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
}
let ubuntuVersionCached: number[] | null = null
/** Get the default version if passed true or undefined, otherwise return the version itself */
export function getVersion(name: string, version: string | undefined) {
if (version === "true" || (version === undefined && name in DefaultVersions)) {
// llvm on linux
if (process.platform === "linux" && ["llvm", "clangtidy", "clangformat"].includes(name)) {
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]}`
}
}
}
// anything else
return DefaultVersions[name]
} else {
return version ?? ""

View File

@ -27,7 +27,7 @@ describe("setup-llvm", () => {
it("Finds valid LLVM URLs", async () => {
await Promise.all(
[
// "14.0.1", fails on ubuntu
// "14.0.1",
"14.0.0",
"13.0.0",
"12.0.0",

View File

@ -59,6 +59,8 @@ export const VERSIONS: Set<string> = getVersions([
"13.0.1",
"14.0.0",
"14.0.1",
"14.0.2",
"14.0.3",
])
//================================================
@ -122,7 +124,8 @@ 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
*/
const UBUNTU: { [key: string]: string } = {
// TODO change based on ubuntu version
const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
"3.5.0": "-ubuntu-14.04",
"3.5.1": "",
"3.5.2": "-ubuntu-14.04",
@ -157,7 +160,7 @@ const UBUNTU: { [key: string]: string } = {
"13.0.0": "-ubuntu-20.04",
"13.0.1": "-ubuntu-18.04",
"14.0.0": "-ubuntu-18.04",
// "14.0.1": "-ubuntu-18.04",
// "14.0.1": "-ubuntu-18.04", // only available for powerpc64le
}
/** The latest supported LLVM version for the Linux (Ubuntu) platform. */
@ -176,11 +179,12 @@ function getLinuxUrl(versionGiven: string): string {
// ubuntu-version is specified
if (version.includes("ubuntu")) {
ubuntu = version
} else if (version !== "" && version in UBUNTU) {
ubuntu = UBUNTU[version]
} else if (version !== "" && version in UBUNTU_SUFFIX_MAP) {
ubuntu = UBUNTU_SUFFIX_MAP[version]
} else {
// default to the maximum version
ubuntu = UBUNTU[MAX_UBUNTU]
ubuntu = UBUNTU_SUFFIX_MAP[MAX_UBUNTU]
warning(`Falling back to LLVM version ${MAX_UBUNTU} ${ubuntu} for the Ubuntu.`)
}
const prefix = "clang+llvm-"

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
}
}