Skip to content

Commit f0f45da

Browse files
authored
Merge pull request #66 from aminya/llvm-14-0-1 [skip ci]
2 parents 49248d2 + d2eafaa commit f0f45da

File tree

8 files changed

+82
-12
lines changed

8 files changed

+82
-12
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build": "shx rm -rf dist/ && shx mkdir ./dist && run-p test.tsc build.parcel copy.matchers",
1616
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .",
1717
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report",
18-
"bump": "ncu -u -x execa && pnpm update",
18+
"bump": "ncu -u -x execa,make-synchronous && pnpm update",
1919
"clean": "shx rm -rf .parcel-cache dist exe",
2020
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/ && shx cp ./src/llvm/llvm_matcher.json ./dist/ ",
2121
"dev": "cross-env NODE_ENV=development parcel watch",
@@ -38,12 +38,14 @@
3838
"@actions/io": "^1.1.2",
3939
"@actions/tool-cache": "^1.7.2",
4040
"execa": "^5.1.1",
41+
"make-synchronous": "^0.1.1",
4142
"mri": "^1.2.0",
4243
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
4344
"numerous": "1.0.3",
4445
"semver": "7.3.7",
4546
"setup-python": "github:actions/setup-python#v3.1.2",
4647
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
48+
"ubuntu-version": "^2.0.0",
4749
"untildify": "^4.0.0",
4850
"which": "^2.0.2"
4951
},

pnpm-lock.yaml

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/default_versions.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { warning } from "./utils/io/io"
2+
import { ubuntuVersion } from "./utils/env/ubuntu_version"
3+
14
const DefaultVersions: Record<string, string> = {
25
llvm: "13.0.0", // https://github.com/llvm/llvm-project/releases
36
clangtidy: "13.0.0",
@@ -14,9 +17,28 @@ const DefaultVersions: Record<string, string> = {
1417
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11", // https://community.chocolatey.org/packages/mingw#versionhistory and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
1518
}
1619

20+
let ubuntuVersionCached: number[] | null = null
21+
1722
/** Get the default version if passed true or undefined, otherwise return the version itself */
1823
export function getVersion(name: string, version: string | undefined) {
1924
if (version === "true" || (version === undefined && name in DefaultVersions)) {
25+
// llvm on linux
26+
if (process.platform === "linux" && ["llvm", "clangtidy", "clangformat"].includes(name)) {
27+
try {
28+
// get the version if not already done
29+
ubuntuVersionCached = ubuntuVersionCached ?? ubuntuVersion()
30+
} catch (err) {
31+
warning((err as Error).toString())
32+
return DefaultVersions[name]
33+
}
34+
// choose the default version for llvm based on ubuntu
35+
if (ubuntuVersionCached !== null) {
36+
if ([20, 18, 16].includes(ubuntuVersionCached[0]) && ubuntuVersionCached[1] === 4) {
37+
return `-13.0.0-x86_64-linux-gnu-ubuntu-${ubuntuVersionCached[0]}.0${ubuntuVersionCached[1]}`
38+
}
39+
}
40+
}
41+
// anything else
2042
return DefaultVersions[name]
2143
} else {
2244
return version ?? ""

src/llvm/__tests__/llvm.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("setup-llvm", () => {
2727
it("Finds valid LLVM URLs", async () => {
2828
await Promise.all(
2929
[
30-
// "14.0.1", fails on ubuntu
30+
// "14.0.1",
3131
"14.0.0",
3232
"13.0.0",
3333
"12.0.0",

src/llvm/llvm.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export const VERSIONS: Set<string> = getVersions([
5959
"13.0.1",
6060
"14.0.0",
6161
"14.0.1",
62+
"14.0.2",
63+
"14.0.3",
6264
])
6365

6466
//================================================
@@ -122,7 +124,8 @@ const UBUNTU_RC: Map<string, string> = new Map()
122124
*
123125
* https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.1 or https://releases.llvm.org/14.0.1
124126
*/
125-
const UBUNTU: { [key: string]: string } = {
127+
// TODO change based on ubuntu version
128+
const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
126129
"3.5.0": "-ubuntu-14.04",
127130
"3.5.1": "",
128131
"3.5.2": "-ubuntu-14.04",
@@ -157,7 +160,7 @@ const UBUNTU: { [key: string]: string } = {
157160
"13.0.0": "-ubuntu-20.04",
158161
"13.0.1": "-ubuntu-18.04",
159162
"14.0.0": "-ubuntu-18.04",
160-
// "14.0.1": "-ubuntu-18.04",
163+
// "14.0.1": "-ubuntu-18.04", // only available for powerpc64le
161164
}
162165

163166
/** The latest supported LLVM version for the Linux (Ubuntu) platform. */
@@ -176,11 +179,12 @@ function getLinuxUrl(versionGiven: string): string {
176179
// ubuntu-version is specified
177180
if (version.includes("ubuntu")) {
178181
ubuntu = version
179-
} else if (version !== "" && version in UBUNTU) {
180-
ubuntu = UBUNTU[version]
182+
} else if (version !== "" && version in UBUNTU_SUFFIX_MAP) {
183+
ubuntu = UBUNTU_SUFFIX_MAP[version]
181184
} else {
182185
// default to the maximum version
183-
ubuntu = UBUNTU[MAX_UBUNTU]
186+
ubuntu = UBUNTU_SUFFIX_MAP[MAX_UBUNTU]
187+
warning(`Falling back to LLVM version ${MAX_UBUNTU} ${ubuntu} for the Ubuntu.`)
184188
}
185189

186190
const prefix = "clang+llvm-"

src/utils/env/ubuntu_version.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { getUbuntuVersion } from "ubuntu-version"
2+
import makeSynchronous from "make-synchronous"
3+
4+
export function ubuntuVersion(): number[] | null {
5+
if (process.platform === "linux") {
6+
const versionSplitted = makeSynchronous(getUbuntuVersion)()
7+
8+
if (versionSplitted.length === 0) {
9+
throw new Error("Failed to get the ubuntu major version.")
10+
}
11+
12+
return versionSplitted
13+
} else {
14+
return null
15+
}
16+
}

0 commit comments

Comments
 (0)