Skip to content

Commit

Permalink
fix: default to LLVM 18.1.8 on most platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 8, 2024
1 parent e003dfd commit e1217a3
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 61 deletions.
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.

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.

2 changes: 1 addition & 1 deletion src/llvm/llvm_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async function getAssetKeywords(platform: string, arch: string) {
break
}
case "darwin": {
keywords.push("darwin")
keywords.push("apple")

switch (arch) {
case "x86_64":
Expand Down
3 changes: 1 addition & 2 deletions src/utils/asset/fetch-github-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ async function fetchGitHubAssetList(
if (!(release.tag_name in assets)) {
assets[release.tag_name] = []
}

const assets_ref = assets[release.tag_name]
const assets_ref = assets[release.tag_name]!

for (const asset of release.assets) {
if (filterAssets !== undefined && !filterAssets(asset.name)) {
Expand Down
24 changes: 16 additions & 8 deletions src/utils/asset/load-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { readFile } from "fs/promises"
* @key tag The tag of the release
* @value assets The names of the assets of the release
*/
export type Assets = Record<string, string[]>
export type Assets = Record<string, string[] | undefined>

/**
* Load the list of assets from a json file
Expand Down Expand Up @@ -39,13 +39,21 @@ export function matchAsset(
const { tag, assetNames } = assetVersion

// if no keywords are given, return the first asset
if (!opts.keywords?.length && !opts.optionalKeywords?.length) {
if (
(opts.keywords === undefined
|| opts.keywords.length === 0)
&& (opts.optionalKeywords === undefined
|| opts.optionalKeywords.length === 0)
) {
return { tag, name: assetNames[0] }
}

// check if the asset contains all the keywords
let candidates: string[] = []
if (opts.keywords?.length) {
if (
opts.keywords !== undefined
&& opts.keywords.length !== 0
) {
for (const name of assetNames) {
if (opts.keywords!.every((keyword) => name.includes(keyword))) {
candidates.push(name)
Expand All @@ -61,7 +69,10 @@ export function matchAsset(
}

// prefer the candidates that contain more optional keywords
if (opts.optionalKeywords?.length) {
if (
opts.optionalKeywords !== undefined
&& opts.optionalKeywords.length !== 0
) {
// rate the candidates based on the number of optional keywords they contain
const candidateScores = candidates.map((name) => {
let score = 0
Expand Down Expand Up @@ -112,10 +123,7 @@ function matchAssetVersion(assets: Assets, opts: MatchAssetOpts) {
let foundVersion: string | undefined
let foundOrigTag: string | undefined
for (const [version, origTag] of versionMap.entries()) {
if (
version === opts.version
|| version.startsWith(opts.version)
) {
if (version.startsWith(opts.version)) {
foundVersion = version
foundOrigTag = origTag
break
Expand Down
58 changes: 12 additions & 46 deletions src/versions/default_versions.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import { isArch } from "../utils/env/isArch.js"

// passing "" to a tool installed by a package manager (apt, brew, choco) will result in the default version of that package manager.
// the directly downloaded tools require a given version ("" doesn't work).

function getNonUbuntuLLVMDefault() {
switch (process.platform) {
case "win32":
return "17.0.6"
case "linux":
// used for non-ubuntu (Fedora, Arch)
// the suffixes relate to the suffix in the llvm releases
return "17.0.6-ubuntu-22.04"
case "darwin":
return "15.0.3"
default:
return "17.0.6"
}
}
const defaultLLVM = process.platform === "darwin" && process.arch === "x64"
? "15.0.7"
: "18.1.8"

/**
* Default versions for the tools
* DefaultUbuntuVersion overrides the default version for the tools on Ubuntu
*/
export const DefaultVersions: Record<string, string | undefined> = {
llvm: getNonUbuntuLLVMDefault(), // https://github.com/llvm/llvm-project/releases
clangtidy: getNonUbuntuLLVMDefault(),
clangformat: getNonUbuntuLLVMDefault(),
// https://github.com/llvm/llvm-project/releases
llvm: defaultLLVM,
clangtidy: defaultLLVM,
clangformat: defaultLLVM,
ninja: "1.12.1", // https://github.com/ninja-build/ninja/releases
cmake: "3.30.2", // https://github.com/Kitware/CMake/releases
gcovr: "5.2", // "6.0", // https://pypi.org/project/gcovr/
Expand All @@ -34,7 +25,7 @@ export const DefaultVersions: Record<string, string | undefined> = {
? "14.2.0posix-18.1.8-12.0.0-ucrt-r1"
: "", // use the default version on Ubuntu, Fedora, Arch, macOS, etc.
// mingw: isArch() ? "12.2.0-1" : "8", // https://archlinux.org/packages/extra/x86_64/mingw-w64-gcc/
powershell: "7.4.5", // https://github.com/PowerShell/PowerShell/releases/tag/v7.4.5
powershell: "7.4.5",
}

export const MinVersions: Record<string, string | undefined> = {
Expand All @@ -52,31 +43,6 @@ export const DefaultUbuntuVersion: Record<string, Record<number, string> | undef
22: "8.0.0-1",
20: "7.0.0-2",
},
// the suffixes relate to the suffix in the llvm releases
llvm: {
24: "17.0.6",
22: "17.0.6",
20: "17.0.6",
18: "15.0.6",
16: "15.0.6",
14: "13.0.0",
},
clangtidy: {
24: "17.0.6",
22: "17.0.6",
20: "17.0.6",
18: "15.0.6",
16: "15.0.6",
14: "13.0.0",
},
clangformat: {
24: "17.0.6",
22: "17.0.6",
20: "17.0.6",
18: "15.0.6",
16: "15.0.6",
14: "13.0.0",
},
gcovr: {
24: "6.0",
22: "6.0",
Expand Down

0 comments on commit e1217a3

Please sign in to comment.