2021-09-14 15:03:59 +08:00
|
|
|
import * as core from "@actions/core"
|
2021-09-14 15:33:49 +08:00
|
|
|
import { setupCmake } from "./cmake/cmake"
|
2021-09-15 01:06:20 +08:00
|
|
|
import { setupConan } from "./conan/conan"
|
2021-09-15 01:42:08 +08:00
|
|
|
import { setupGcovr } from "./gcovr/gcovr"
|
2021-09-14 20:02:34 +08:00
|
|
|
import { setupLLVM } from "./llvm/llvm"
|
2021-09-15 01:09:58 +08:00
|
|
|
import { setupMeson } from "./meson/meson"
|
2021-09-14 15:42:17 +08:00
|
|
|
import { setupNinja } from "./ninja/ninja"
|
|
|
|
|
|
|
|
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> {
|
2021-09-14 20:02:34 +08:00
|
|
|
const setupCppDir = process.env.SETUP_CPP_DIR ?? "~/setup_cpp"
|
2021-09-14 15:03:59 +08:00
|
|
|
try {
|
2021-09-14 15:33:49 +08:00
|
|
|
// setup cmake
|
2021-09-14 15:42:17 +08:00
|
|
|
const cmakeVersion = maybeGetInput("cmake")
|
|
|
|
if (cmakeVersion !== undefined) {
|
2021-09-14 20:02:34 +08:00
|
|
|
await setupCmake(cmakeVersion, setupCppDir)
|
2021-09-14 15:33:49 +08:00
|
|
|
}
|
2021-09-14 15:42:17 +08:00
|
|
|
|
|
|
|
// setup ninja
|
|
|
|
const ninjaVersion = maybeGetInput("ninja")
|
|
|
|
if (ninjaVersion !== undefined) {
|
2021-09-14 20:02:34 +08:00
|
|
|
await setupNinja(ninjaVersion, setupCppDir)
|
2021-09-14 15:42:17 +08:00
|
|
|
}
|
2021-09-14 20:02:59 +08:00
|
|
|
|
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-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) => {
|
2021-09-14 15:33:49 +08:00
|
|
|
core.error("main() failed!")
|
|
|
|
core.error(error as string | Error)
|
2021-09-14 15:03:59 +08:00
|
|
|
process.exitCode = 1
|
|
|
|
})
|