From 1275ae37d24fd7f0cc5a4e59a3711026eb4e7458 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 21 Nov 2023 20:32:39 +0700 Subject: [PATCH] feat: install Ninja if generator is Ninja --- main/index.mjs | 13 +++++++++++++ src/main.mts | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/main/index.mjs b/main/index.mjs index 631c236..e9ec13c 100644 --- a/main/index.mjs +++ b/main/index.mjs @@ -27247,6 +27247,19 @@ async function main() { const generator = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("generator"); if (generator) configureArgs.push(...["-G", generator]); + if (generator.match(/ninja/gi)) { + switch (process.platform) { + case "linux": + await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("sudo", ["apt", "install", "-y", "ninja-build"]); + break; + case "darwin": + await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("brew", ["install", "ninja"]); + break; + case "win32": + await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("choco", ["install", "ninja"]); + break; + } + } const cCompiler = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("c-compiler"); if (cCompiler) configureArgs.push("-DCMAKE_C_COMPILER=" + cCompiler); diff --git a/src/main.mts b/src/main.mts index 7a9b3c5..299a005 100644 --- a/src/main.mts +++ b/src/main.mts @@ -10,6 +10,20 @@ async function main() { const generator = core.getInput("generator"); if (generator) configureArgs.push(...["-G", generator]); + if (generator.match(/ninja/gi)) { + 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);