fix: fix the llvm 15 link for linux + test the installation

This commit is contained in:
Amin Yahyaabadi 2022-10-13 16:42:28 -07:00
parent 41ac067e60
commit f4e3f220db
5 changed files with 37 additions and 7 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

@ -122,6 +122,25 @@ describe("setup-llvm", () => {
await testBin("clang-format", ["--version"], binDir)
})
it("should setup LLVM 15.0.2", async () => {
await cleanupTmpDir("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 () => {
await cleanupTmpDir("llvm")
}, 100000)

View File

@ -214,8 +214,8 @@ export function getLinuxUrl(versionGiven: string): string {
let suffix: string
if (version === "5.0.0") {
suffix = `-linux-x86_64${linuxVersion}.tar.xz`
} else if (version === "15.0.2") {
suffix = `x86_64-unknown-linux-gnu${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`
}

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)) {
throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`)
}
const offlineUrls: string[] = []
for (const specificVersion of getSpecificVersions(versions, version)) {
// eslint-disable-next-line no-await-in-loop
const url = await getUrl(platform, specificVersion)
// eslint-disable-next-line no-await-in-loop
if (url !== null && (await isUrlOnline(url))) {
if (url !== null) {
if (await isUrlOnline(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*)/