Merge pull request #129 from aminya/llvm-15 [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-10-18 15:09:13 -07:00 committed by GitHub
commit 86617ca741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 12 deletions

View File

@ -36,6 +36,7 @@ words:
- gcovr - gcovr
- ghes - ghes
- Graphviz - Graphviz
- inja
- isci - isci
- isroot - isroot
- kcov - kcov
@ -58,6 +59,7 @@ words:
- npmrc - npmrc
- Opencppcoverage - Opencppcoverage
- OSSDK - OSSDK
- papm
- patha - patha
- pnpm - pnpm
- pwsh - pwsh

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

@ -54,6 +54,7 @@ describe("setup-llvm", () => {
it("Finds valid LLVM URLs", async () => { it("Finds valid LLVM URLs", async () => {
await Promise.all( await Promise.all(
[ [
"15.0.2",
// "14.0.1", // "14.0.1",
"14.0.0", "14.0.0",
"13.0.0", "13.0.0",
@ -121,6 +122,26 @@ describe("setup-llvm", () => {
await testBin("clang-format", ["--version"], binDir) await testBin("clang-format", ["--version"], binDir)
}) })
it("should setup LLVM 15.0.2", async () => {
await cleanupTmpDir("llvm")
await cleanupTmpDir("/Users/runner/hostedtoolcache/llvm")
const { binDir } = await setupLLVM("15.0.2", directory, process.arch)
await testBin("clang++", ["--version"], binDir)
expect(process.env.CC?.includes("clang")).toBeTruthy()
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
// test compilation
const file = path.join(__dirname, "main.cpp")
const main_exe = path.join(__dirname, addExeExt("main"))
execa.sync("clang++", [file, "-o", main_exe], { cwd: __dirname })
if (process.platform !== "win32") {
chmodSync(main_exe, "755")
}
execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
})
afterAll(async () => { afterAll(async () => {
await cleanupTmpDir("llvm") await cleanupTmpDir("llvm")
}, 100000) }, 100000)

View File

@ -71,6 +71,9 @@ export const VERSIONS: Set<string> = getVersions([
"14.0.4", "14.0.4",
"14.0.5", "14.0.5",
"14.0.6", "14.0.6",
"15.0.0",
"15.0.1",
"15.0.2",
]) ])
//================================================ //================================================
@ -174,10 +177,11 @@ const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
"13.0.1-ubuntu-18.04": "-ubuntu-18.04", "13.0.1-ubuntu-18.04": "-ubuntu-18.04",
"14.0.0": "-ubuntu-18.04", "14.0.0": "-ubuntu-18.04",
// "14.0.1": "-ubuntu-18.04", // only available for powerpc64le // "14.0.1": "-ubuntu-18.04", // only available for powerpc64le
"15.0.2": "-rhel86",
} }
/** The latest supported LLVM version for the Linux (Ubuntu) platform. */ /** The latest supported LLVM version for the Linux (Ubuntu) platform. */
const MAX_UBUNTU: string = "14.0.0" const MAX_UBUNTU: string = "15.0.2"
/** Gets an LLVM download URL for the Linux (Ubuntu) platform. */ /** Gets an LLVM download URL for the Linux (Ubuntu) platform. */
export function getLinuxUrl(versionGiven: string): string { export function getLinuxUrl(versionGiven: string): string {
@ -188,25 +192,34 @@ export function getLinuxUrl(versionGiven: string): string {
version = rc version = rc
} }
let ubuntu: string let linuxVersion: string
// ubuntu-version is specified // ubuntu-version is specified
if (version.includes("ubuntu")) { if (version.includes("ubuntu")) {
const givenUbuntuVersion = version.replace(/-ubuntu-.*/, "") const givenUbuntuVersion = version.replace(/-ubuntu-.*/, "")
if (!VERSIONS.has(givenUbuntuVersion)) { if (!VERSIONS.has(givenUbuntuVersion)) {
throw new Error(`Unsupported Ubuntu version: ${givenUbuntuVersion}`) throw new Error(`Unsupported Ubuntu version: ${givenUbuntuVersion}`)
} }
ubuntu = version.replace(givenUbuntuVersion, "") linuxVersion = version.replace(givenUbuntuVersion, "")
version = getSpecificVersions(VERSIONS, givenUbuntuVersion)[0] version = getSpecificVersions(VERSIONS, givenUbuntuVersion)[0]
} else if (version !== "" && version in UBUNTU_SUFFIX_MAP) { } else if (version !== "" && version in UBUNTU_SUFFIX_MAP) {
ubuntu = UBUNTU_SUFFIX_MAP[version] linuxVersion = UBUNTU_SUFFIX_MAP[version]
} else { } else {
// default to the maximum version // default to the maximum version
ubuntu = UBUNTU_SUFFIX_MAP[MAX_UBUNTU] linuxVersion = UBUNTU_SUFFIX_MAP[MAX_UBUNTU]
warning(`Falling back to LLVM version ${MAX_UBUNTU} ${ubuntu} for the Ubuntu.`) warning(`Falling back to LLVM version ${MAX_UBUNTU} ${linuxVersion} for the Ubuntu.`)
} }
const prefix = "clang+llvm-" const prefix = "clang+llvm-"
const suffix = version === "5.0.0" ? `-linux-x86_64${ubuntu}.tar.xz` : `-x86_64-linux-gnu${ubuntu}.tar.xz`
let suffix: string
if (version === "5.0.0") {
suffix = `-linux-x86_64${linuxVersion}.tar.xz`
} else if (linuxVersion.includes("-rhel86")) {
suffix = `-x86_64-unknown-linux-gnu${linuxVersion}.tar.xz`
} else {
suffix = `-x86_64-linux-gnu${linuxVersion}.tar.xz`
}
if (semverLte(version, "9.0.1")) { if (semverLte(version, "9.0.1")) {
return getReleaseUrl(version, prefix, suffix) return getReleaseUrl(version, prefix, suffix)
} else { } else {

View File

@ -47,20 +47,31 @@ export async function getSpecificVersionAndUrl(
} }
} }
// if the given set doesn't include the version, throw an error
if (!versions.has(version)) { if (!versions.has(version)) {
throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`) throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`)
} }
const offlineUrls: string[] = []
for (const specificVersion of getSpecificVersions(versions, version)) { for (const specificVersion of getSpecificVersions(versions, version)) {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
const url = await getUrl(platform, specificVersion) const url = await getUrl(platform, specificVersion)
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
if (url !== null && (await isUrlOnline(url))) { if (url !== null) {
if (await isUrlOnline(url)) {
return [specificVersion, url] return [specificVersion, url]
} else {
offlineUrls.push(url)
}
} }
} }
throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`) throw new Error(
`Unsupported target! (platform='${platform}', version='${version}'). The offline urls tested:\n${offlineUrls.join(
"\n"
)}`
)
} }
export const defaultVersionRegex = /v?(\d\S*)/ export const defaultVersionRegex = /v?(\d\S*)/