2021-09-18 10:17:21 +08:00
|
|
|
import { addPath } from "../utils/path/addPath"
|
2021-09-16 16:47:47 +08:00
|
|
|
import { setupAptPack } from "../utils/setup/setupAptPack"
|
2022-02-04 13:38:59 +08:00
|
|
|
import { PackageInfo, setupBin } from "../utils/setup/setupBin"
|
2021-09-16 16:47:47 +08:00
|
|
|
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
|
|
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
2022-02-04 13:38:59 +08:00
|
|
|
import { addBinExtension } from "../utils/extension/extension"
|
|
|
|
import { extractTarByExe } from "../utils/setup/extract"
|
|
|
|
import { warning } from "../utils/io/io"
|
2021-09-16 16:47:47 +08:00
|
|
|
|
2022-02-04 13:38:59 +08:00
|
|
|
/** Get the platform data for cmake */
|
2021-09-16 19:57:37 +08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2022-02-04 13:38:59 +08:00
|
|
|
function getDoxygenPackageInfo(version: string, platform: NodeJS.Platform, _arch: string): PackageInfo {
|
|
|
|
switch (platform) {
|
|
|
|
case "linux": {
|
|
|
|
const folderName = `doxygen-${version}`
|
|
|
|
return {
|
|
|
|
binRelativeDir: "bin/",
|
|
|
|
binFileName: addBinExtension("doxygen"),
|
|
|
|
extractedFolderName: folderName,
|
|
|
|
extractFunction: (file: string, dest: string) => {
|
|
|
|
return extractTarByExe(file, dest, ["--strip-components=1"])
|
|
|
|
},
|
|
|
|
url: `https://downloads.sourceforge.net/project/doxygen/doxygen-binaries/rel-${version}/${folderName}.linux.bin.tar.gz`,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
throw new Error(`Unsupported platform '${platform}'`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function setupDoxygen(version: string, setupDir: string, arch: string) {
|
2021-09-16 16:47:47 +08:00
|
|
|
switch (process.platform) {
|
|
|
|
case "win32": {
|
2021-09-16 22:19:56 +08:00
|
|
|
await setupChocoPack("doxygen.install", version)
|
2022-02-04 13:38:59 +08:00
|
|
|
await setupChocoPack("graphviz", undefined)
|
2021-09-20 20:31:40 +08:00
|
|
|
const binDir = activateWinDoxygen()
|
2021-09-17 02:49:24 +08:00
|
|
|
return { binDir }
|
2021-09-16 16:47:47 +08:00
|
|
|
}
|
|
|
|
case "darwin": {
|
2021-09-17 18:17:21 +08:00
|
|
|
setupBrewPack("doxygen", version)
|
2022-02-04 13:38:59 +08:00
|
|
|
return setupBrewPack("graphviz", undefined)
|
2021-09-16 16:47:47 +08:00
|
|
|
}
|
|
|
|
case "linux": {
|
2022-02-04 13:38:59 +08:00
|
|
|
try {
|
|
|
|
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from sourceforge.
|
|
|
|
await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
|
|
|
|
} catch (err) {
|
|
|
|
warning(`Failed to download doxygen from sourceforge. ${err}. Falling back to apt-get.`)
|
|
|
|
await setupAptPack("doxygen", undefined)
|
|
|
|
}
|
|
|
|
return setupAptPack("graphviz", undefined)
|
2021-09-16 16:47:47 +08:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
throw new Error(`Unsupported platform`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-20 20:31:40 +08:00
|
|
|
|
|
|
|
function activateWinDoxygen() {
|
|
|
|
addPath("C:/Program Files/Graphviz/bin")
|
|
|
|
const binDir = "C:/Program Files/doxygen/bin"
|
|
|
|
addPath(binDir)
|
|
|
|
return binDir
|
|
|
|
}
|