fix: default to LLVM 18.1.8 on most platforms

This commit is contained in:
Amin Yahyaabadi 2024-09-08 02:35:06 -07:00
parent e003dfdeac
commit e1217a3287
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
8 changed files with 34 additions and 61 deletions

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

View File

@ -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":

View File

@ -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)) {

View File

@ -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
@ -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)
@ -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
@ -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

View File

@ -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/
@ -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> = {
@ -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",