Skip to content

Commit 3c105b2

Browse files
authored
Merge pull request #26 from aminya/doxygen-linux
2 parents 9bc7fbc + da57a92 commit 3c105b2

File tree

5 files changed

+45
-33
lines changed

5 files changed

+45
-33
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/default_versions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const DefaultVersions: Record<string, string> = {
1010
python: "3.8.10",
1111
kcov: "v39",
1212
task: "3.10.0",
13+
doxygen: process.platform === "win32" ? "1.9.3.20220106" : "1.9.3",
1314
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11",
1415
}
1516

src/doxygen/__tests__/doxygen.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { setupDoxygen } from "../doxygen"
22
import { testBin } from "../../utils/tests/test-helpers"
33
import { InstallationInfo } from "../../utils/setup/setupBin"
4+
import { getVersion } from "../../default_versions"
45

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

1011
await testBin("doxygen", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
1112
})

src/doxygen/doxygen.ts

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,58 @@
11
import { addPath } from "../utils/path/addPath"
22
import { setupAptPack } from "../utils/setup/setupAptPack"
3+
import { PackageInfo, setupBin } from "../utils/setup/setupBin"
34
import { setupBrewPack } from "../utils/setup/setupBrewPack"
45
import { setupChocoPack } from "../utils/setup/setupChocoPack"
6+
import { addBinExtension } from "../utils/extension/extension"
7+
import { extractTarByExe } from "../utils/setup/extract"
8+
import { warning } from "../utils/io/io"
59

10+
/** Get the platform data for cmake */
611
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7-
export async function setupDoxygen(version: string | undefined, _setupDir: string, _arch: string) {
12+
function getDoxygenPackageInfo(version: string, platform: NodeJS.Platform, _arch: string): PackageInfo {
13+
switch (platform) {
14+
case "linux": {
15+
const folderName = `doxygen-${version}`
16+
return {
17+
binRelativeDir: "bin/",
18+
binFileName: addBinExtension("doxygen"),
19+
extractedFolderName: folderName,
20+
extractFunction: (file: string, dest: string) => {
21+
return extractTarByExe(file, dest, ["--strip-components=1"])
22+
},
23+
url: `https://www.doxygen.nl/files/${folderName}.linux.bin.tar.gz`,
24+
}
25+
}
26+
default:
27+
throw new Error(`Unsupported platform '${platform}'`)
28+
}
29+
}
30+
31+
export async function setupDoxygen(version: string, setupDir: string, arch: string) {
832
switch (process.platform) {
933
case "win32": {
1034
await setupChocoPack("doxygen.install", version)
11-
// TODO fails on windows?
12-
// await setupChocoPack("graphviz", version)
13-
/**
14-
* Graphviz v2.49.0 [Approved] graphviz package files install completed. Performing other installation steps.
15-
* graphviz not installed. An error occurred during installation: Item has already been added. Key in dictionary:
16-
* 'Path' Key being added: 'PATH'
17-
*
18-
* Chocolatey installed 0/0 packages.
19-
* See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
20-
* The process cannot access the file 'C:\ProgramData\chocolatey\lib\Graphviz\.chocolateyPending' because it is being used by another process.
21-
*
22-
* 18 | execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args])
23-
* 19 | } else {
24-
* > 20 | execa.sync("choco", ["install", "-y", name, ...args])
25-
* | ^
26-
* 21 | }
27-
* 22 |
28-
* 23 | const binDir = "C:/ProgramData/Chocolatey/bin/"
29-
*
30-
* at makeError (node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js:60:11)
31-
* at Function.Object.<anonymous>.module.exports.sync (node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js:194:17)
32-
* at setupChocoPack (src/utils/setup/setupChocoPack.ts:20:11)
33-
* at setupDoxygen (src/doxygen/doxygen.ts:11:27)
34-
* at Object.<anonymous> (src/doxygen/__tests__/doxygen.test.ts:8:25)
35-
*/
35+
try {
36+
await setupChocoPack("graphviz", undefined)
37+
} catch (err) {
38+
warning(`${err}`)
39+
}
3640
const binDir = activateWinDoxygen()
3741
return { binDir }
3842
}
3943
case "darwin": {
40-
setupBrewPack("doxygen", version)
41-
return setupBrewPack("graphviz", version)
44+
setupBrewPack("doxygen", undefined)
45+
return setupBrewPack("graphviz", undefined)
4246
}
4347
case "linux": {
44-
await setupAptPack("doxygen", version)
45-
return setupAptPack("graphviz", version)
48+
try {
49+
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
50+
await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
51+
} catch (err) {
52+
warning(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
53+
await setupAptPack("doxygen", undefined)
54+
}
55+
return setupAptPack("graphviz", undefined)
4656
}
4757
default: {
4858
throw new Error(`Unsupported platform`)

0 commit comments

Comments
 (0)