mirror of
https://github.com/threeal/cmake-action.git
synced 2026-02-02 03:50:55 +00:00
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:
15
src/main.mts
15
src/main.mts
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user