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"
|
import { getCompilerInfo, Inputs, parseArgs } from "../main"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
|
@ -34,3 +34,22 @@ describe("syncVersion", () => {
|
||||||
expect(opts.llvm).toBe(opts.clangtidy)
|
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
|
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 */
|
/** 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) {
|
export function getVersion(name: string, version: string | undefined, osVersion: number[] | null = null) {
|
||||||
if (useDefault(version, name)) {
|
if (useDefault(version, name)) {
|
||||||
// llvm on linux
|
// choose the default linux version based on ubuntu version
|
||||||
if (process.platform === "linux" && ["llvm", "clangtidy", "clangformat"].includes(name)) {
|
if (process.platform === "linux" && osVersion !== null && name in DefaultUbuntuVersion) {
|
||||||
// choose the default version for llvm based on ubuntu
|
const osVersionMaj = osVersion[0]
|
||||||
if (osVersion !== null) {
|
const newest = parseInt(Object.keys(DefaultUbuntuVersion[name])[0], 10) // newest version with the default
|
||||||
if ([20, 18, 16].includes(osVersion[0]) && osVersion[1] === 4) {
|
if (osVersionMaj >= newest) {
|
||||||
return `${osVersion[0] === 18 ? "13.0.1" : "13.0.0"}-ubuntu-${osVersion[0]}.0${osVersion[1]}`
|
return DefaultUbuntuVersion[name][osVersionMaj]
|
||||||
}
|
} else {
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// anything else
|
// anything else
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
|
||||||
import { InstallationInfo } from "../../utils/setup/setupBin"
|
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
describe("setup-doxygen", () => {
|
describe("setup-doxygen", () => {
|
||||||
|
@ -12,7 +13,11 @@ describe("setup-doxygen", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup doxygen and dot", async () => {
|
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)
|
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": {
|
case "linux": {
|
||||||
let installationInfo: InstallationInfo
|
let installationInfo: InstallationInfo
|
||||||
|
if (version === "") {
|
||||||
|
installationInfo = setupAptPack("doxygen", undefined)
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
|
// 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)
|
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.`)
|
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
|
||||||
installationInfo = setupAptPack("doxygen", undefined)
|
installationInfo = setupAptPack("doxygen", undefined)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
|
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { setupGcovr } from "../gcovr"
|
import { setupGcovr } from "../gcovr"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
|
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
describe("setup-gcovr", () => {
|
describe("setup-gcovr", () => {
|
||||||
it("should setup gcovr", async () => {
|
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)
|
await testBin("gcovr", ["--version"], installInfo.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { setupMeson } from "../meson"
|
import { setupMeson } from "../meson"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
|
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
describe("setup-meson", () => {
|
describe("setup-meson", () => {
|
||||||
it("should setup meson", async () => {
|
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)
|
await testBin("meson", ["--version"], installInfo.binDir)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue