2024-08-16 17:52:11 +08:00
|
|
|
import { addPath } from "envosman"
|
2025-03-23 17:55:38 +08:00
|
|
|
import { hasApk, installApkPack } from "setup-alpine"
|
2025-05-20 17:23:12 +08:00
|
|
|
import { hasAptGet, installAptPack } from "setup-apt"
|
2024-08-24 06:20:37 +08:00
|
|
|
import { installBrewPack } from "setup-brew"
|
2025-04-07 12:30:53 +08:00
|
|
|
import { rcOptions } from "../options.js"
|
2024-08-16 06:22:07 +08:00
|
|
|
import { hasDnf } from "../utils/env/hasDnf.js"
|
|
|
|
|
import { isArch } from "../utils/env/isArch.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
|
|
|
|
2021-09-16 19:57:37 +08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2021-11-22 02:46:34 +08:00
|
|
|
export async function setupCppcheck(version: string | undefined, _setupDir: string, _arch: string) {
|
2021-09-16 16:30:47 +08:00
|
|
|
switch (process.platform) {
|
|
|
|
|
case "win32": {
|
2021-09-16 22:19:56 +08:00
|
|
|
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()) {
|
2022-06-30 00:06:35 +08:00
|
|
|
return setupPacmanPack("cppcheck", version)
|
2022-07-11 07:34:56 +08:00
|
|
|
} else if (hasDnf()) {
|
2023-07-16 18:12:24 +08:00
|
|
|
return setupDnfPack([{ name: "ccache", version }])
|
2025-05-20 16:43:24 +08:00
|
|
|
} else if (hasAptGet()) {
|
2024-08-16 16:50:32 +08:00
|
|
|
return installAptPack([{ name: "cppcheck", version }])
|
2025-03-23 16:18:33 +08:00
|
|
|
} else if (await hasApk()) {
|
2025-03-23 17:55:38 +08:00
|
|
|
return installApkPack([{ name: "cppcheck", version }])
|
2022-06-30 00:06:35 +08:00
|
|
|
}
|
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"
|
2024-08-15 09:43:53 +08:00
|
|
|
await addPath(binDir, rcOptions)
|
2021-09-20 20:31:05 +08:00
|
|
|
return binDir
|
|
|
|
|
}
|