setup-cpp/src/main.ts

124 lines
3.3 KiB
TypeScript
Raw Normal View History

2021-09-14 15:03:59 +08:00
import * as core from "@actions/core"
2021-09-16 16:26:53 +08:00
import { setupBrew } from "./brew/brew"
2021-09-16 16:41:47 +08:00
import { setupCcache } from "./ccache/ccache"
2021-09-15 05:01:08 +08:00
import { setupChocolatey } from "./chocolatey/chocolatey"
import { setupCmake } from "./cmake/cmake"
2021-09-15 01:06:20 +08:00
import { setupConan } from "./conan/conan"
2021-09-16 16:47:47 +08:00
import { setupCppcheck } from "./cppcheck/cppcheck"
import { setupDoxygen } from "./doxygen/doxygen"
2021-09-15 01:42:08 +08:00
import { setupGcovr } from "./gcovr/gcovr"
import { setupLLVM } from "./llvm/llvm"
2021-09-15 01:09:58 +08:00
import { setupMeson } from "./meson/meson"
2021-09-15 18:25:02 +08:00
import { setupMSVC } from "./msvc/msvc"
import { setupNinja } from "./ninja/ninja"
import { setupPython } from "./python/python"
function maybeGetInput(key: string) {
const value = core.getInput(key)
if (value !== "false" && value !== "") {
return value
}
return undefined
}
2021-09-14 15:03:59 +08:00
export async function main(): Promise<number> {
const arch = core.getInput("architecture") || process.arch
const setupCppDir = process.env.SETUP_CPP_DIR ?? "~/setup_cpp"
2021-09-14 15:03:59 +08:00
try {
// setup cmake
const cmakeVersion = maybeGetInput("cmake")
if (cmakeVersion !== undefined) {
await setupCmake(cmakeVersion, setupCppDir)
}
// setup ninja
const ninjaVersion = maybeGetInput("ninja")
if (ninjaVersion !== undefined) {
await setupNinja(ninjaVersion, setupCppDir)
}
2021-09-14 20:02:59 +08:00
// setup python (required for conan, meson, gcovr, etc.)
const pythonVersion = maybeGetInput("python")
if (pythonVersion !== undefined) {
await setupPython(pythonVersion, arch)
}
2021-09-15 01:06:20 +08:00
// setup conan
const conanVersion = maybeGetInput("conan")
if (conanVersion !== undefined) {
await setupConan(conanVersion)
}
2021-09-15 01:09:58 +08:00
// setup meson
const mesonVersion = maybeGetInput("meson")
if (mesonVersion !== undefined) {
await setupMeson(mesonVersion)
}
2021-09-15 01:42:08 +08:00
// setup gcovr
const gcovrVersion = maybeGetInput("gcovr")
if (gcovrVersion !== undefined) {
await setupGcovr(gcovrVersion)
}
2021-09-14 20:02:59 +08:00
// setup llvm
const llvmVersion = maybeGetInput("llvm")
if (llvmVersion !== undefined) {
await setupLLVM(llvmVersion, setupCppDir)
}
2021-09-15 05:01:08 +08:00
// setup chocolatey (required for installing msvc)
const chocoVersion = maybeGetInput("choco")
if (chocoVersion !== undefined) {
await setupChocolatey()
}
2021-09-15 18:25:02 +08:00
2021-09-16 16:26:53 +08:00
// setup brew
const brewVersion = maybeGetInput("brew")
if (brewVersion !== undefined) {
await setupBrew()
}
2021-09-16 16:41:47 +08:00
// setup ccache
const ccacheVersion = maybeGetInput("ccache")
if (ccacheVersion !== undefined) {
await setupCcache(ccacheVersion)
}
2021-09-16 16:47:47 +08:00
// setup doxygen
const doxygenVersion = maybeGetInput("doxygen")
if (doxygenVersion !== undefined) {
await setupDoxygen(doxygenVersion)
}
// setup cppCheck
const cppCheckVersion = maybeGetInput("cppcheck")
if (cppCheckVersion !== undefined) {
await setupCppcheck(cppCheckVersion)
}
2021-09-15 18:25:02 +08:00
// setup msvc
const msvcVersion = maybeGetInput("msvc")
if (msvcVersion !== undefined) {
await setupMSVC(msvcVersion)
}
2021-09-14 15:03:59 +08:00
} catch (err) {
core.error(err as string | Error)
core.setFailed("install-cpp failed")
return 1
}
core.info("install-cpp succeeded")
return 0
}
main()
.then((ret) => {
process.exitCode = ret
})
.catch((error) => {
core.error("main() failed!")
core.error(error as string | Error)
2021-09-14 15:03:59 +08:00
process.exitCode = 1
})