setup-cpp/src/cppcheck/cppcheck.ts

44 lines
1.5 KiB
TypeScript
Raw Normal View History

import { addPath } from "envosman"
import { installAptPack } from "setup-apt"
2024-08-24 06:20:37 +08:00
import { installBrewPack } from "setup-brew"
import { rcOptions } from "../cli-options.js"
import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
2021-09-16 16:30:47 +08:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupCppcheck(version: string | undefined, _setupDir: string, _arch: string) {
2021-09-16 16:30:47 +08:00
switch (process.platform) {
case "win32": {
await setupChocoPack("cppcheck", version)
2022-05-13 03:55:00 +08:00
const binDir = await activateWinCppcheck()
2021-09-17 02:48:13 +08:00
return { binDir }
2021-09-16 16:30:47 +08:00
}
case "darwin": {
2024-08-24 06:20:37 +08:00
return installBrewPack("cppcheck", version)
2021-09-16 16:30:47 +08:00
}
case "linux": {
2022-06-30 10:06:33 +08:00
if (isArch()) {
return setupPacmanPack("cppcheck", version)
} else if (hasDnf()) {
return setupDnfPack([{ name: "ccache", version }])
} else if (isUbuntu()) {
return installAptPack([{ name: "cppcheck", version }])
}
2024-08-07 14:44:32 +08:00
throw new Error("Unsupported linux distribution")
2021-09-16 16:30:47 +08:00
}
default: {
2024-08-07 14:44:32 +08:00
throw new Error("Unsupported platform")
2021-09-16 16:30:47 +08:00
}
}
}
2021-09-20 20:31:05 +08:00
2022-05-13 03:55:00 +08:00
async function activateWinCppcheck() {
2021-09-20 20:31:05 +08:00
const binDir = "C:/Program Files/Cppcheck"
await addPath(binDir, rcOptions)
2021-09-20 20:31:05 +08:00
return binDir
}