mirror of https://github.com/aminya/setup-cpp
feat: support ubuntu specific versions for llvm
This commit is contained in:
parent
3aa347d997
commit
99f8d1aba8
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -24,7 +24,7 @@ export function getVersion(name: string, version: string | undefined, osVersion:
|
|||
// choose the default version for llvm based on ubuntu
|
||||
if (osVersion !== null) {
|
||||
if ([20, 18, 16].includes(osVersion[0]) && osVersion[1] === 4) {
|
||||
return `-13.0.0-x86_64-linux-gnu-ubuntu-${osVersion[0]}.0${osVersion[1]}`
|
||||
return `${osVersion[0] === 18 ? "13.0.1" : "13.0.0"}-ubuntu-${osVersion[0]}.0${osVersion[1]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { setupLLVM, VERSIONS, getUrl, setupClangTools } from "../llvm"
|
||||
import { setupLLVM, VERSIONS, getUrl, setupClangTools, getLinuxUrl } from "../llvm"
|
||||
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
|
||||
import { isValidUrl } from "../../utils/http/validate_url"
|
||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||
|
@ -25,6 +25,33 @@ describe("setup-llvm", () => {
|
|||
directory = await setupTmpDir("llvm")
|
||||
})
|
||||
|
||||
it("Finds URL for ubuntu version", async () => {
|
||||
expect(
|
||||
await getSpecificVersionAndUrl(VERSIONS, "linux", "13.0.0-ubuntu-16.04", (_plantform, version) =>
|
||||
getLinuxUrl(version)
|
||||
)
|
||||
).toStrictEqual([
|
||||
"13.0.0-ubuntu-16.04",
|
||||
"https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz",
|
||||
])
|
||||
expect(
|
||||
await getSpecificVersionAndUrl(VERSIONS, "linux", "13.0.1-ubuntu-18.04", (_plantform, version) =>
|
||||
getLinuxUrl(version)
|
||||
)
|
||||
).toStrictEqual([
|
||||
"13.0.1-ubuntu-18.04",
|
||||
"https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz",
|
||||
])
|
||||
expect(
|
||||
await getSpecificVersionAndUrl(VERSIONS, "linux", "13.0.0-ubuntu-20.04", (_plantform, version) =>
|
||||
getLinuxUrl(version)
|
||||
)
|
||||
).toStrictEqual([
|
||||
"13.0.0-ubuntu-20.04",
|
||||
"https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz",
|
||||
])
|
||||
})
|
||||
|
||||
it("Finds valid LLVM URLs", async () => {
|
||||
await Promise.all(
|
||||
[
|
||||
|
|
|
@ -4,7 +4,12 @@ import semverMajor from "semver/functions/major"
|
|||
import { isValidUrl } from "../utils/http/validate_url"
|
||||
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||
import { extractExe, extractTarByExe } from "../utils/setup/extract"
|
||||
import { getSpecificVersionAndUrl, getVersions, semverCoerceIfInvalid } from "../utils/setup/version"
|
||||
import {
|
||||
getSpecificVersionAndUrl,
|
||||
getSpecificVersions,
|
||||
getVersions,
|
||||
semverCoerceIfInvalid,
|
||||
} from "../utils/setup/version"
|
||||
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
|
||||
import { addBinExtension } from "../utils/extension/extension"
|
||||
import { addEnv } from "../utils/env/addEnv"
|
||||
|
@ -158,7 +163,10 @@ const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
|
|||
"12.0.0": "-ubuntu-20.04",
|
||||
"12.0.1": "-ubuntu-16.04",
|
||||
"13.0.0": "-ubuntu-20.04",
|
||||
"13.0.0-ubuntu-16.04": "-ubuntu-16.04",
|
||||
"13.0.0-ubuntu-20.04": "-ubuntu-20.04",
|
||||
"13.0.1": "-ubuntu-18.04",
|
||||
"13.0.1-ubuntu-18.04": "-ubuntu-18.04",
|
||||
"14.0.0": "-ubuntu-18.04",
|
||||
// "14.0.1": "-ubuntu-18.04", // only available for powerpc64le
|
||||
}
|
||||
|
@ -167,7 +175,7 @@ const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
|
|||
const MAX_UBUNTU: string = "14.0.0"
|
||||
|
||||
/** Gets an LLVM download URL for the Linux (Ubuntu) platform. */
|
||||
function getLinuxUrl(versionGiven: string): string {
|
||||
export function getLinuxUrl(versionGiven: string): string {
|
||||
let version = versionGiven
|
||||
|
||||
const rc = UBUNTU_RC.get(version)
|
||||
|
@ -178,7 +186,12 @@ function getLinuxUrl(versionGiven: string): string {
|
|||
let ubuntu: string
|
||||
// ubuntu-version is specified
|
||||
if (version.includes("ubuntu")) {
|
||||
ubuntu = version
|
||||
const givenUbuntuVersion = version.replace(/-ubuntu-.*/, "")
|
||||
if (!VERSIONS.has(givenUbuntuVersion)) {
|
||||
throw new Error(`Unsupported Ubuntu version: ${givenUbuntuVersion}`)
|
||||
}
|
||||
ubuntu = version.replace(givenUbuntuVersion, "")
|
||||
version = getSpecificVersions(VERSIONS, givenUbuntuVersion)[0]
|
||||
} else if (version !== "" && version in UBUNTU_SUFFIX_MAP) {
|
||||
ubuntu = UBUNTU_SUFFIX_MAP[version]
|
||||
} else {
|
||||
|
|
|
@ -38,6 +38,15 @@ export async function getSpecificVersionAndUrl(
|
|||
version: string,
|
||||
getUrl: (platform: string, version: string) => string | null | Promise<string | null>
|
||||
): Promise<[string, string]> {
|
||||
// specific ubuntu version
|
||||
if (platform === "linux" && version.includes("ubuntu")) {
|
||||
const url = await getUrl(platform, version)
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (url !== null && (await isValidUrl(url))) {
|
||||
return [version, url]
|
||||
}
|
||||
}
|
||||
|
||||
if (!versions.has(version)) {
|
||||
throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue