Merge pull request #84 from aminya/ubuntu-18 [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-05-20 20:13:56 -07:00 committed by GitHub
commit 28abb73509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 82 additions and 19 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import { syncVersions } from "../default_versions"
import { syncVersions, getVersion } from "../default_versions"
import { getCompilerInfo, Inputs, parseArgs } from "../main"
jest.setTimeout(300000)
@ -34,3 +34,22 @@ describe("syncVersion", () => {
expect(opts.llvm).toBe(opts.clangtidy)
})
})
describe("getVersion", () => {
it("gcovr", () => {
expect(getVersion("gcovr", "5.0")).toBe("5.0")
if (process.platform === "linux") {
expect(getVersion("gcovr", "true", [20, 4])).toBe("5.1")
expect(getVersion("gcovr", "true", [18, 4])).toBe("5.0")
}
})
it("llvm", () => {
expect(getVersion("llvm", "13.0.0")).toBe("13.0.0")
if (process.platform === "linux") {
expect(getVersion("llvm", "true", [20, 4])).toBe("13.0.0-ubuntu-20.04")
expect(getVersion("llvm", "true", [18, 4])).toBe("13.0.1-ubuntu-18.04")
expect(getVersion("llvm", "true", [16, 4])).toBe("13.0.0-ubuntu-16.04")
}
})
})

View File

@ -16,16 +16,49 @@ const DefaultVersions: Record<string, string> = {
gcc: "11", // https://github.com/brechtsanders/winlibs_mingw/releases and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
}
/// If an ubuntu versions is not in this map:
// - the newer ubuntu versions use the first entry (e.g. v20),
// - the older ones use ""
const DefaultUbuntuVersion: Record<string, Record<number, string>> = {
llvm: {
20: "13.0.0-ubuntu-20.04",
18: "13.0.1-ubuntu-18.04",
16: "13.0.0-ubuntu-16.04",
},
clangtidy: {
20: "13.0.0-ubuntu-20.04",
18: "13.0.1-ubuntu-18.04",
16: "13.0.0-ubuntu-16.04",
},
clangformat: {
20: "13.0.0-ubuntu-20.04",
18: "13.0.1-ubuntu-18.04",
16: "13.0.0-ubuntu-16.04",
},
gcovr: {
20: "5.1",
18: "5.0",
},
meson: {
20: "0.62.1",
18: "0.61.4",
},
doxygen: {
20: "1.9.4",
},
}
/** Get the default version if passed true or undefined, otherwise return the version itself */
export function getVersion(name: string, version: string | undefined, osVersion: number[] | null = null) {
if (useDefault(version, name)) {
// llvm on linux
if (process.platform === "linux" && ["llvm", "clangtidy", "clangformat"].includes(name)) {
// choose the default version for llvm based on ubuntu
if (osVersion !== null) {
if ([20, 18, 16].includes(osVersion[0]) && osVersion[1] === 4) {
return `${osVersion[0] === 18 ? "13.0.1" : "13.0.0"}-ubuntu-${osVersion[0]}.0${osVersion[1]}`
}
// choose the default linux version based on ubuntu version
if (process.platform === "linux" && osVersion !== null && name in DefaultUbuntuVersion) {
const osVersionMaj = osVersion[0]
const newest = parseInt(Object.keys(DefaultUbuntuVersion[name])[0], 10) // newest version with the default
if (osVersionMaj >= newest) {
return DefaultUbuntuVersion[name][osVersionMaj]
} else {
return ""
}
}
// anything else

View File

@ -3,6 +3,7 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
import { InstallationInfo } from "../../utils/setup/setupBin"
import { getVersion } from "../../default_versions"
import which from "which"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
jest.setTimeout(300000)
describe("setup-doxygen", () => {
@ -12,7 +13,11 @@ describe("setup-doxygen", () => {
})
it("should setup doxygen and dot", async () => {
const installInfo = await setupDoxygen(getVersion("doxygen", undefined), directory, process.arch)
const installInfo = await setupDoxygen(
getVersion("doxygen", undefined, await ubuntuVersion()),
directory,
process.arch
)
await testBin("doxygen", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)

View File

@ -56,13 +56,17 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
}
case "linux": {
let installationInfo: InstallationInfo
try {
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
setupAptPack("libclang-cpp9")
} catch (err) {
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
if (version === "") {
installationInfo = setupAptPack("doxygen", undefined)
} else {
try {
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
setupAptPack("libclang-cpp9")
} catch (err) {
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
installationInfo = setupAptPack("doxygen", undefined)
}
}
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
return installationInfo

View File

@ -1,11 +1,12 @@
import { setupGcovr } from "../gcovr"
import { testBin } from "../../utils/tests/test-helpers"
import { getVersion } from "../../default_versions"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
jest.setTimeout(300000)
describe("setup-gcovr", () => {
it("should setup gcovr", async () => {
const installInfo = await setupGcovr(getVersion("gcovr", "true"), "", process.arch)
const installInfo = await setupGcovr(getVersion("gcovr", "true", await ubuntuVersion()), "", process.arch)
await testBin("gcovr", ["--version"], installInfo.binDir)
})
})

View File

@ -1,11 +1,12 @@
import { setupMeson } from "../meson"
import { testBin } from "../../utils/tests/test-helpers"
import { getVersion } from "../../default_versions"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
jest.setTimeout(300000)
describe("setup-meson", () => {
it("should setup meson", async () => {
const installInfo = await setupMeson(getVersion("meson", "true"), "", process.arch)
const installInfo = await setupMeson(getVersion("meson", "true", await ubuntuVersion()), "", process.arch)
await testBin("meson", ["--version"], installInfo.binDir)
})