|
1 | 1 | import { addPath } from "../utils/path/addPath"
|
2 | 2 | import { setupAptPack } from "../utils/setup/setupAptPack"
|
| 3 | +import { PackageInfo, setupBin } from "../utils/setup/setupBin" |
3 | 4 | import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
4 | 5 | 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" |
5 | 9 |
|
| 10 | +/** Get the platform data for cmake */ |
6 | 11 | // 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) { |
8 | 32 | switch (process.platform) {
|
9 | 33 | case "win32": {
|
10 | 34 | 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 | + } |
36 | 40 | const binDir = activateWinDoxygen()
|
37 | 41 | return { binDir }
|
38 | 42 | }
|
39 | 43 | case "darwin": {
|
40 |
| - setupBrewPack("doxygen", version) |
41 |
| - return setupBrewPack("graphviz", version) |
| 44 | + setupBrewPack("doxygen", undefined) |
| 45 | + return setupBrewPack("graphviz", undefined) |
42 | 46 | }
|
43 | 47 | 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) |
46 | 56 | }
|
47 | 57 | default: {
|
48 | 58 | throw new Error(`Unsupported platform`)
|
|
0 commit comments