mirror of https://github.com/aminya/setup-cpp
Merge pull request #84 from aminya/ubuntu-18 [skip ci]
This commit is contained in:
commit
28abb73509
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -56,6 +56,9 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
|
|||
}
|
||||
case "linux": {
|
||||
let installationInfo: InstallationInfo
|
||||
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)
|
||||
|
@ -64,6 +67,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
|
|||
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
|
||||
installationInfo = setupAptPack("doxygen", undefined)
|
||||
}
|
||||
}
|
||||
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
|
||||
return installationInfo
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue