feat: install Ninja if it was not available (#82)

* feat: install Ninja if generator is Ninja

* feat: only install ninja if it was not installed
This commit is contained in:
Alfi Maulana
2023-11-21 20:45:38 +07:00
committed by GitHub
parent ded3a0b2a3
commit dd1c44061d
4 changed files with 34 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import core from "@actions/core";
import exec from "@actions/exec";
import io from "@actions/io";
async function main() {
const sourceDir = core.getInput("source-dir");
@@ -10,6 +11,20 @@ async function main() {
const generator = core.getInput("generator");
if (generator) configureArgs.push(...["-G", generator]);
if (generator.match(/ninja/gi) && !(await io.which("ninja"))) {
switch (process.platform) {
case "linux":
await exec.exec("sudo", ["apt", "install", "-y", "ninja-build"]);
break;
case "darwin":
await exec.exec("brew", ["install", "ninja"]);
break;
case "win32":
await exec.exec("choco", ["install", "ninja"]);
break;
}
}
const cCompiler = core.getInput("c-compiler");
if (cCompiler) configureArgs.push("-DCMAKE_C_COMPILER=" + cCompiler);