fix: download doxygen binary on linux instead of using apt

This commit is contained in:
Amin Yahyaabadi 2022-02-03 21:38:59 -08:00
parent 9bc7fbc388
commit 9ce8af143f
5 changed files with 40 additions and 32 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,7 @@ const DefaultVersions: Record<string, string> = {
python: "3.8.10",
kcov: "v39",
task: "3.10.0",
doxygen: process.platform === "win32" ? "1.9.3.20220106" : "1.9.3",
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11",
}

View File

@ -1,11 +1,12 @@
import { setupDoxygen } from "../doxygen"
import { testBin } from "../../utils/tests/test-helpers"
import { InstallationInfo } from "../../utils/setup/setupBin"
import { getVersion } from "../../default_versions"
jest.setTimeout(300000)
describe("setup-doxygen", () => {
it("should setup doxygen", async () => {
const installInfo = await setupDoxygen("", "", process.arch)
const installInfo = await setupDoxygen(getVersion("doxygen", undefined), "", process.arch)
await testBin("doxygen", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
})

View File

@ -1,48 +1,54 @@
import { addPath } from "../utils/path/addPath"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { PackageInfo, setupBin } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { addBinExtension } from "../utils/extension/extension"
import { extractTarByExe } from "../utils/setup/extract"
import { warning } from "../utils/io/io"
/** Get the platform data for cmake */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupDoxygen(version: string | undefined, _setupDir: string, _arch: string) {
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) {
switch (process.platform) {
case "win32": {
await setupChocoPack("doxygen.install", version)
// TODO fails on windows?
// await setupChocoPack("graphviz", version)
/**
* Graphviz v2.49.0 [Approved] graphviz package files install completed. Performing other installation steps.
* graphviz not installed. An error occurred during installation: Item has already been added. Key in dictionary:
* 'Path' Key being added: 'PATH'
*
* Chocolatey installed 0/0 packages.
* See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
* The process cannot access the file 'C:\ProgramData\chocolatey\lib\Graphviz\.chocolateyPending' because it is being used by another process.
*
* 18 | execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args])
* 19 | } else {
* > 20 | execa.sync("choco", ["install", "-y", name, ...args])
* | ^
* 21 | }
* 22 |
* 23 | const binDir = "C:/ProgramData/Chocolatey/bin/"
*
* at makeError (node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js:60:11)
* at Function.Object.<anonymous>.module.exports.sync (node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js:194:17)
* at setupChocoPack (src/utils/setup/setupChocoPack.ts:20:11)
* at setupDoxygen (src/doxygen/doxygen.ts:11:27)
* at Object.<anonymous> (src/doxygen/__tests__/doxygen.test.ts:8:25)
*/
await setupChocoPack("graphviz", undefined)
const binDir = activateWinDoxygen()
return { binDir }
}
case "darwin": {
setupBrewPack("doxygen", version)
return setupBrewPack("graphviz", version)
return setupBrewPack("graphviz", undefined)
}
case "linux": {
await setupAptPack("doxygen", version)
return setupAptPack("graphviz", version)
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)
}
default: {
throw new Error(`Unsupported platform`)