Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support exclusive asset matching keywords+ Fix clang 15/16 on Ubuntu 24 #334

Merged
merged 9 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ words:
- bazel
- bazelisk
- biome
- mkdirp
- biomejs
- buildtools
- caxa
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs.map

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"@types/cross-spawn": "^6.0.6",
"@types/escape-quotes": "~1.0.0",
"@types/eslint": "^9.6.1",
"@types/fs-extra": "^11.0.4",
"@types/iarna__toml": "~2.0.5",
"@types/jest": "^29.5.14",
"@types/memoizee": "^0.4.11",
Expand All @@ -107,6 +108,7 @@
"eslint-config-atomic": "^1.22.1",
"exec-powershell": "workspace:*",
"execa": "^7",
"fs-extra": "^11.3.0",
"is-url-online": "^1.5.0",
"jest": "^29.7.0",
"lefthook": "^1.10.3",
Expand Down Expand Up @@ -186,13 +188,14 @@
"untildify-user",
"util.types",
"web-streams-polyfill",
"timers-browserify"
"timers-browserify",
"fs-extra"
],
"engines": {
"node": ">=12.x",
"pnpm": "^9"
"pnpm": "^10"
},
"packageManager": "pnpm@9.15.4",
"packageManager": "pnpm@10.2.0",
"workspaces": [
"packages/*"
],
Expand Down
52 changes: 43 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/llvm/__tests__/llvm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,22 @@ describe("setup-llvm", () => {

await io.rmRF(directory)
})

// test installation of LLVM 10 to 19 on Linux
for (let version = 10; version <= 19; version++) {
if (process.platform !== "linux") {
continue
}
it(`should setup LLVM ${version} on Linux`, async () => {
const directory = await setupTmpDir("llvm")

const { binDir } = await setupLLVM(`${version}`, directory, process.arch)
await testBin("clang++", ["--version"], binDir)

expect(process.env.CC?.includes("clang")).toBeTruthy()
expect(process.env.CXX?.includes("clang++")).toBeTruthy()

await io.rmRF(directory)
})
}
})
15 changes: 8 additions & 7 deletions src/llvm/llvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ async function llvmBinaryDeps_(_majorVersion: number) {
for (const dep of ["libtinfo5", "libtinfo6"]) {
/* eslint-disable no-await-in-loop */
try {
await installAptPack([{ name: dep }])
} catch (_err) {
try {
await installAptPack([{ name: dep }])
} catch (err) {
if (dep === "libtinfo5") {
// Manually install libtinfo5 if the package is not available
info(`Failed to install ${dep} ${err}\nManually installing the package`)
info(`Failed to install ${dep}\nManually installing the package`)
const arch = x86_64.includes(process.arch)
? "amd64"
: arm64.includes(process.arch)
Expand All @@ -114,16 +114,17 @@ async function llvmBinaryDeps_(_majorVersion: number) {
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}`)
dl.on("error", async (dlErr) => {
info(`Failed to download ${url}: ${dlErr}`)
await dl.stop()
})
await dl.start()
// Install the downloaded package via dpkg
execRootSync("dpkg", ["-i", join(tmpdir(), fileName)])
}
} catch (_errFallback) {
info(`Failed to install ${dep}. Ignoring`)
}
} catch (err) {
info(`Failed to install ${dep}. Ignoring`)
}
/* eslint-enable no-await-in-loop */
}
Expand Down
36 changes: 20 additions & 16 deletions src/llvm/llvm_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { arm64, armv7, powerpc64le, sparc64, sparcv9, x86, x86_64 } from "../uti
import { hasDnf } from "../utils/env/hasDnf.js"
import { isUbuntu } from "../utils/env/isUbuntu.js"
import { ubuntuVersion } from "../utils/env/ubuntu_version.js"
import { extractExe, extractTarByExe } from "../utils/setup/extract.js"
import { extractExe, extractTarByExe, getArchiveType, getExtractFunction } from "../utils/setup/extract.js"
import type { PackageInfo } from "../utils/setup/setupBin.js"

const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
Expand All @@ -26,7 +26,7 @@ export async function getLLVMPackageInfo(
binRelativeDir: "bin",
binFileName: addExeExt("clang"),
extractFunction: platform === "win32"
? extractExe
? getExtractFunction(getArchiveType(url))
: (file: string, dest: string) => {
return extractTarByExe(file, dest, 1)
},
Expand Down Expand Up @@ -78,28 +78,32 @@ export async function getLLVMAssetURL(platform: string, arch: string, version: s
}

async function getAssetKeywords(platform: string, arch: string) {
const keywords: string[] = []
const optionalKeywords: string[] = []
const keywords: (string | string[])[] = []
const optionalKeywords: (string | string[])[] = []

switch (platform) {
case "win32": {
optionalKeywords.push("windows", "Windows")
// prefer exe over tar.xz for windows
optionalKeywords.push(".exe", ".exe")
const osKeywordsChoice: string[] = []
if (x86_64.includes(arch)) {
// prefer win64 keyword over x86_64 or x64
optionalKeywords.push("win64", "win64", "win64", "x86_64", "X64")
osKeywordsChoice.push("win64")
optionalKeywords.push(["x86_64", "X64"])
// TODO fallback to win32 if win64 is not available (e.g. for LLVM 3.6.2 and older)
} else if (x86.includes(arch)) {
keywords.push("win32")
osKeywordsChoice.push("win32")
} else if (arm64.includes(arch)) {
keywords.push("woa64")
osKeywordsChoice.push("woa64")
} else {
info(`Using arch ${arch} for LLVM`)
keywords.push(arch)
osKeywordsChoice.push(arch)
}
osKeywordsChoice.push("windows", "Windows")
keywords.push(osKeywordsChoice)
break
}
case "linux": {
optionalKeywords.push("linux", "Linux")
const osKeywordsChoice = ["linux", "Linux"]

if (isUbuntu()) {
optionalKeywords.push("ubuntu")
Expand All @@ -117,7 +121,7 @@ async function getAssetKeywords(platform: string, arch: string) {
}

if (x86_64.includes(arch)) {
optionalKeywords.push("x86_64", "X64")
keywords.push(["x86_64", "X64"])
} else if (x86.includes(arch)) {
keywords.push("x86")
} else if (arm64.includes(arch)) {
Expand All @@ -132,17 +136,17 @@ async function getAssetKeywords(platform: string, arch: string) {
info(`Using arch ${arch} for LLVM`)
keywords.push(arch)
}

keywords.push(osKeywordsChoice)
break
}
case "darwin": {
optionalKeywords.push("apple", "macos", "macOS")
keywords.push(["apple", "macos", "macOS"])

if (x86_64.includes(arch)) {
optionalKeywords.push("x86_64", "X64")
optionalKeywords.push(["x86_64", "X64"])
} else if (arm64.includes(arch)) {
// allow falling back to x86_64 if arm64 is not available
optionalKeywords.push("arm64", "ARM64")
optionalKeywords.push(["arm64", "ARM64"])
} else {
info(`Using arch ${arch} for LLVM`)
keywords.push(arch)
Expand Down
Loading