Skip to content

Commit 28abb73

Browse files
authored
Merge pull request #84 from aminya/ubuntu-18 [skip ci]
2 parents af7a395 + 5d3ac21 commit 28abb73

File tree

8 files changed

+82
-19
lines changed

8 files changed

+82
-19
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/main.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { syncVersions } from "../default_versions"
1+
import { syncVersions, getVersion } from "../default_versions"
22
import { getCompilerInfo, Inputs, parseArgs } from "../main"
33

44
jest.setTimeout(300000)
@@ -34,3 +34,22 @@ describe("syncVersion", () => {
3434
expect(opts.llvm).toBe(opts.clangtidy)
3535
})
3636
})
37+
38+
describe("getVersion", () => {
39+
it("gcovr", () => {
40+
expect(getVersion("gcovr", "5.0")).toBe("5.0")
41+
if (process.platform === "linux") {
42+
expect(getVersion("gcovr", "true", [20, 4])).toBe("5.1")
43+
expect(getVersion("gcovr", "true", [18, 4])).toBe("5.0")
44+
}
45+
})
46+
47+
it("llvm", () => {
48+
expect(getVersion("llvm", "13.0.0")).toBe("13.0.0")
49+
if (process.platform === "linux") {
50+
expect(getVersion("llvm", "true", [20, 4])).toBe("13.0.0-ubuntu-20.04")
51+
expect(getVersion("llvm", "true", [18, 4])).toBe("13.0.1-ubuntu-18.04")
52+
expect(getVersion("llvm", "true", [16, 4])).toBe("13.0.0-ubuntu-16.04")
53+
}
54+
})
55+
})

src/default_versions.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,49 @@ const DefaultVersions: Record<string, string> = {
1616
gcc: "11", // https://github.com/brechtsanders/winlibs_mingw/releases and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
1717
}
1818

19+
/// If an ubuntu versions is not in this map:
20+
// - the newer ubuntu versions use the first entry (e.g. v20),
21+
// - the older ones use ""
22+
const DefaultUbuntuVersion: Record<string, Record<number, string>> = {
23+
llvm: {
24+
20: "13.0.0-ubuntu-20.04",
25+
18: "13.0.1-ubuntu-18.04",
26+
16: "13.0.0-ubuntu-16.04",
27+
},
28+
clangtidy: {
29+
20: "13.0.0-ubuntu-20.04",
30+
18: "13.0.1-ubuntu-18.04",
31+
16: "13.0.0-ubuntu-16.04",
32+
},
33+
clangformat: {
34+
20: "13.0.0-ubuntu-20.04",
35+
18: "13.0.1-ubuntu-18.04",
36+
16: "13.0.0-ubuntu-16.04",
37+
},
38+
gcovr: {
39+
20: "5.1",
40+
18: "5.0",
41+
},
42+
meson: {
43+
20: "0.62.1",
44+
18: "0.61.4",
45+
},
46+
doxygen: {
47+
20: "1.9.4",
48+
},
49+
}
50+
1951
/** Get the default version if passed true or undefined, otherwise return the version itself */
2052
export function getVersion(name: string, version: string | undefined, osVersion: number[] | null = null) {
2153
if (useDefault(version, name)) {
22-
// llvm on linux
23-
if (process.platform === "linux" && ["llvm", "clangtidy", "clangformat"].includes(name)) {
24-
// choose the default version for llvm based on ubuntu
25-
if (osVersion !== null) {
26-
if ([20, 18, 16].includes(osVersion[0]) && osVersion[1] === 4) {
27-
return `${osVersion[0] === 18 ? "13.0.1" : "13.0.0"}-ubuntu-${osVersion[0]}.0${osVersion[1]}`
28-
}
54+
// choose the default linux version based on ubuntu version
55+
if (process.platform === "linux" && osVersion !== null && name in DefaultUbuntuVersion) {
56+
const osVersionMaj = osVersion[0]
57+
const newest = parseInt(Object.keys(DefaultUbuntuVersion[name])[0], 10) // newest version with the default
58+
if (osVersionMaj >= newest) {
59+
return DefaultUbuntuVersion[name][osVersionMaj]
60+
} else {
61+
return ""
2962
}
3063
}
3164
// anything else

src/doxygen/__tests__/doxygen.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
33
import { InstallationInfo } from "../../utils/setup/setupBin"
44
import { getVersion } from "../../default_versions"
55
import which from "which"
6+
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
67

78
jest.setTimeout(300000)
89
describe("setup-doxygen", () => {
@@ -12,7 +13,11 @@ describe("setup-doxygen", () => {
1213
})
1314

1415
it("should setup doxygen and dot", async () => {
15-
const installInfo = await setupDoxygen(getVersion("doxygen", undefined), directory, process.arch)
16+
const installInfo = await setupDoxygen(
17+
getVersion("doxygen", undefined, await ubuntuVersion()),
18+
directory,
19+
process.arch
20+
)
1621

1722
await testBin("doxygen", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
1823

src/doxygen/doxygen.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
5656
}
5757
case "linux": {
5858
let installationInfo: InstallationInfo
59-
try {
60-
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
61-
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
62-
setupAptPack("libclang-cpp9")
63-
} catch (err) {
64-
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
59+
if (version === "") {
6560
installationInfo = setupAptPack("doxygen", undefined)
61+
} else {
62+
try {
63+
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
64+
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
65+
setupAptPack("libclang-cpp9")
66+
} catch (err) {
67+
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
68+
installationInfo = setupAptPack("doxygen", undefined)
69+
}
6670
}
6771
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
6872
return installationInfo

src/gcovr/__tests__/gcovr.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { setupGcovr } from "../gcovr"
22
import { testBin } from "../../utils/tests/test-helpers"
33
import { getVersion } from "../../default_versions"
4+
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
45

56
jest.setTimeout(300000)
67
describe("setup-gcovr", () => {
78
it("should setup gcovr", async () => {
8-
const installInfo = await setupGcovr(getVersion("gcovr", "true"), "", process.arch)
9+
const installInfo = await setupGcovr(getVersion("gcovr", "true", await ubuntuVersion()), "", process.arch)
910
await testBin("gcovr", ["--version"], installInfo.binDir)
1011
})
1112
})

src/meson/__tests__/meson.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { setupMeson } from "../meson"
22
import { testBin } from "../../utils/tests/test-helpers"
33
import { getVersion } from "../../default_versions"
4+
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
45

56
jest.setTimeout(300000)
67
describe("setup-meson", () => {
78
it("should setup meson", async () => {
8-
const installInfo = await setupMeson(getVersion("meson", "true"), "", process.arch)
9+
const installInfo = await setupMeson(getVersion("meson", "true", await ubuntuVersion()), "", process.arch)
910

1011
await testBin("meson", ["--version"], installInfo.binDir)
1112
})

0 commit comments

Comments
 (0)