2022-05-03 14:32:01 +08:00
|
|
|
import { warning } from "./utils/io/io"
|
|
|
|
import { ubuntuVersion } from "./utils/env/ubuntu_version"
|
|
|
|
|
2021-09-16 19:36:35 +08:00
|
|
|
const DefaultVersions: Record<string, string> = {
|
2022-04-28 03:41:21 +08:00
|
|
|
llvm: "13.0.0", // https://github.com/llvm/llvm-project/releases
|
|
|
|
clangtidy: "13.0.0",
|
|
|
|
clangformat: "13.0.0",
|
2022-03-02 06:01:08 +08:00
|
|
|
ninja: "1.10.2", // https://github.com/ninja-build/ninja/releases
|
2022-04-16 15:49:19 +08:00
|
|
|
cmake: "3.23.1", // https://github.com/Kitware/CMake/releases
|
2022-03-02 06:01:08 +08:00
|
|
|
gcovr: "5.0", // https://pypi.org/project/gcovr/
|
2022-04-16 15:49:19 +08:00
|
|
|
conan: "1.47.0", // https://github.com/conan-io/conan/releases
|
|
|
|
meson: "0.61.4", // https://github.com/mesonbuild/meson/releases
|
2022-01-23 09:17:56 +08:00
|
|
|
python: "3.8.10",
|
2022-04-16 17:25:25 +08:00
|
|
|
kcov: "40", // https://github.com/SimonKagstrom/kcov/releases
|
2022-04-16 15:49:19 +08:00
|
|
|
task: "3.12.0", // https://github.com/go-task/task/releases
|
2022-03-02 06:01:08 +08:00
|
|
|
doxygen: "1.9.1", // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen
|
2022-04-16 15:49:19 +08:00
|
|
|
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
|
2021-09-16 19:36:35 +08:00
|
|
|
}
|
|
|
|
|
2022-05-03 14:32:01 +08:00
|
|
|
let ubuntuVersionCached: number[] | null = null
|
|
|
|
|
2021-09-16 19:36:35 +08:00
|
|
|
/** Get the default version if passed true or undefined, otherwise return the version itself */
|
|
|
|
export function getVersion(name: string, version: string | undefined) {
|
2021-09-16 19:57:37 +08:00
|
|
|
if (version === "true" || (version === undefined && name in DefaultVersions)) {
|
2022-05-03 15:46:03 +08:00
|
|
|
// llvm on linux
|
|
|
|
if (process.platform === "linux" && ["llvm", "clangtidy", "clangformat"].includes(name)) {
|
2022-05-03 14:32:01 +08:00
|
|
|
try {
|
|
|
|
// get the version if not already done
|
|
|
|
ubuntuVersionCached = ubuntuVersionCached ?? ubuntuVersion()
|
|
|
|
} catch (err) {
|
|
|
|
warning((err as Error).toString())
|
|
|
|
return DefaultVersions[name]
|
|
|
|
}
|
|
|
|
// choose the default version for llvm based on ubuntu
|
|
|
|
if (ubuntuVersionCached !== null) {
|
|
|
|
if ([20, 18, 16].includes(ubuntuVersionCached[0]) && ubuntuVersionCached[1] === 4) {
|
|
|
|
return `-13.0.0-x86_64-linux-gnu-ubuntu-${ubuntuVersionCached[0]}.0${ubuntuVersionCached[1]}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-03 15:46:03 +08:00
|
|
|
// anything else
|
|
|
|
return DefaultVersions[name]
|
|
|
|
} else {
|
|
|
|
return version ?? ""
|
2022-05-03 14:32:01 +08:00
|
|
|
}
|
|
|
|
}
|