mirror of https://github.com/aminya/setup-cpp
Merge pull request #296 from aminya/llvm-urls [skip ci]
fix: avoid old LLVM release HTTP redirects + fix libtinfo5 installation on Ubuntu 24
This commit is contained in:
commit
1f6f8322f8
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -82,6 +82,23 @@ describe("setup-llvm", () => {
|
||||||
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
|
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should setup LLVM 5 from llvm.org", async () => {
|
||||||
|
const { binDir } = await setupLLVM("5", 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 = join(dirname, "main.cpp")
|
||||||
|
const main_exe = join(dirname, addExeExt("main"))
|
||||||
|
execaSync("clang++", ["-std=c++17", file, "-o", main_exe], { cwd: dirname })
|
||||||
|
if (process.platform !== "win32") {
|
||||||
|
await chmod(main_exe, "755")
|
||||||
|
}
|
||||||
|
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
|
||||||
|
})
|
||||||
|
|
||||||
it("should setup clang-format", async () => {
|
it("should setup clang-format", async () => {
|
||||||
const osVersion = await ubuntuVersion()
|
const osVersion = await ubuntuVersion()
|
||||||
const { binDir } = await setupClangFormat(getVersion("llvm", "true", osVersion), directory, process.arch)
|
const { binDir } = await setupClangFormat(getVersion("llvm", "true", osVersion), directory, process.arch)
|
||||||
|
|
|
@ -21,7 +21,9 @@ async function main() {
|
||||||
for (let major = 1; major <= 9; major++) {
|
for (let major = 1; major <= 9; major++) {
|
||||||
for (let minor = 0; minor <= 9; minor++) {
|
for (let minor = 0; minor <= 9; minor++) {
|
||||||
for (let patch = 0; patch <= 9; patch++) {
|
for (let patch = 0; patch <= 9; patch++) {
|
||||||
const version = `${major}.${minor}.${patch}`
|
const version = (major >= 3 && minor >= 4 && patch >= 1)
|
||||||
|
? `${major}.${minor}`
|
||||||
|
: `${major}.${minor}.${patch}`
|
||||||
yield [version, `https://releases.llvm.org/${version}`] as [string, string]
|
yield [version, `https://releases.llvm.org/${version}`] as [string, string]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
|
import { tmpdir } from "os"
|
||||||
import path, { delimiter, join } from "path"
|
import path, { delimiter, join } from "path"
|
||||||
import { fileURLToPath } from "url"
|
import { fileURLToPath } from "url"
|
||||||
|
import { execRootSync } from "admina"
|
||||||
import { GITHUB_ACTIONS } from "ci-info"
|
import { GITHUB_ACTIONS } from "ci-info"
|
||||||
import { info, warning } from "ci-log"
|
import { info, warning } from "ci-log"
|
||||||
import { addEnv } from "envosman"
|
import { addEnv } from "envosman"
|
||||||
import memoize from "memoizee"
|
import memoize from "memoizee"
|
||||||
|
import { DownloaderHelper } from "node-downloader-helper"
|
||||||
import { pathExists } from "path-exists"
|
import { pathExists } from "path-exists"
|
||||||
import { addExeExt } from "patha"
|
import { addExeExt } from "patha"
|
||||||
import { addUpdateAlternativesToRc, installAptPack } from "setup-apt"
|
import { addUpdateAlternativesToRc, installAptPack } from "setup-apt"
|
||||||
import { rcOptions } from "../cli-options.js"
|
import { rcOptions } from "../cli-options.js"
|
||||||
import { setupGcc } from "../gcc/gcc.js"
|
import { setupGcc } from "../gcc/gcc.js"
|
||||||
import { setupMacOSSDK } from "../macos-sdk/macos-sdk.js"
|
import { setupMacOSSDK } from "../macos-sdk/macos-sdk.js"
|
||||||
|
import { arm64, x86_64 } from "../utils/env/arch.js"
|
||||||
import { hasDnf } from "../utils/env/hasDnf.js"
|
import { hasDnf } from "../utils/env/hasDnf.js"
|
||||||
import { isArch } from "../utils/env/isArch.js"
|
import { isArch } from "../utils/env/isArch.js"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu.js"
|
import { isUbuntu } from "../utils/env/isUbuntu.js"
|
||||||
|
@ -87,7 +91,27 @@ function majorLLVMVersion(version: string) {
|
||||||
async function llvmBinaryDeps_(majorVersion: number) {
|
async function llvmBinaryDeps_(majorVersion: number) {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
if (majorVersion <= 10) {
|
if (majorVersion <= 10) {
|
||||||
await installAptPack([{ name: "libtinfo5" }])
|
try {
|
||||||
|
await installAptPack([{ name: "libtinfo5" }])
|
||||||
|
} catch (err) {
|
||||||
|
// Manually install libtinfo5 if the package is not available
|
||||||
|
info(`Failed to install libtinfo5 ${err}\nManually installing the package`)
|
||||||
|
const arch = x86_64.includes(process.arch)
|
||||||
|
? "amd64"
|
||||||
|
: arm64.includes(process.arch)
|
||||||
|
? "arm64"
|
||||||
|
: process.arch
|
||||||
|
|
||||||
|
const fileName = `libtinfo5_6.3-2ubuntu0.1_${arch}.deb`
|
||||||
|
const url = `http://launchpadlibrarian.net/666971015/${fileName}`
|
||||||
|
const dl = new DownloaderHelper(url, tmpdir(), { fileName })
|
||||||
|
dl.on("error", (dlErr) => {
|
||||||
|
throw new Error(`Failed to download ${url}: ${dlErr}`)
|
||||||
|
})
|
||||||
|
await dl.start()
|
||||||
|
// Install the downloaded package via dpkg
|
||||||
|
execRootSync("dpkg", ["-i", join(tmpdir(), fileName)])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await installAptPack([{ name: "libtinfo-dev" }])
|
await installAptPack([{ name: "libtinfo-dev" }])
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ export async function getLLVMAssetURL(platform: string, arch: string, version: s
|
||||||
)
|
)
|
||||||
|
|
||||||
if (websiteAsset !== undefined) {
|
if (websiteAsset !== undefined) {
|
||||||
return `https://llvm.org/releases/${websiteAsset.tag}/${websiteAsset.name}`
|
return `https://releases.llvm.org/${websiteAsset.tag}/${websiteAsset.name}`
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`No asset found for version ${version} matching ${keywords} and ${optionalKeywords}`)
|
throw new Error(`No asset found for version ${version} matching ${keywords} and ${optionalKeywords}`)
|
||||||
|
|
Loading…
Reference in New Issue