feat: pass more arguments during CMake configuration (#78)

* feat: parse and pass `generator` input

* feat: parse and pass `c-compiler` and `cxx-compiler` inputs

* feat: parse and pass `c-flags` and `cxx-flags` inputs

* feat: parse and pass `options` input

* feat: parse and pass `args` input
This commit is contained in:
Alfi Maulana 2023-11-20 21:52:38 +07:00 committed by GitHub
parent 1829bd6347
commit 025d277e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 2 deletions

25
main/index.mjs generated
View File

@ -27243,7 +27243,30 @@ var __webpack_exports__ = {};
async function main() {
const sourceDir = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("source-dir");
const buildDir = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("build-dir");
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("cmake", [sourceDir || ".", "-B", buildDir || "build"]);
const configureArgs = [sourceDir || ".", "-B", buildDir || "build"];
const generator = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("generator");
if (generator)
configureArgs.push(...["-G", generator]);
const cCompiler = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("c-compiler");
if (cCompiler)
configureArgs.push("-DCMAKE_C_COMPILER=" + cCompiler);
const cxxCompiler = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("cxx-compiler");
if (cxxCompiler)
configureArgs.push("-DCMAKE_CXX_COMPILER=" + cxxCompiler);
const cFlags = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("c-flags").join(" ");
if (cFlags)
configureArgs.push("-DCMAKE_C_FLAGS=" + cFlags);
const cxxFlags = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("cxx-flags").join(" ");
if (cxxFlags)
configureArgs.push("-DCMAKE_CXX_FLAGS=" + cxxFlags);
const options = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("options")
.flatMap((opts) => opts.split(" "))
.map((opt) => "-D" + opt);
configureArgs.push(...options);
const args = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("args")
.flatMap((args) => args.split(" "));
configureArgs.push(...args);
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("cmake", configureArgs);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput("build-dir", buildDir || "build");
const runBuild = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput("run-build");
const runTest = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput("run-test");

View File

@ -4,7 +4,36 @@ import exec from "@actions/exec";
async function main() {
const sourceDir = core.getInput("source-dir");
const buildDir = core.getInput("build-dir");
await exec.exec("cmake", [sourceDir || ".", "-B", buildDir || "build"]);
const configureArgs = [sourceDir || ".", "-B", buildDir || "build"];
const generator = core.getInput("generator");
if (generator) configureArgs.push(...["-G", generator]);
const cCompiler = core.getInput("c-compiler");
if (cCompiler) configureArgs.push("-DCMAKE_C_COMPILER=" + cCompiler);
const cxxCompiler = core.getInput("cxx-compiler");
if (cxxCompiler) configureArgs.push("-DCMAKE_CXX_COMPILER=" + cxxCompiler);
const cFlags = core.getMultilineInput("c-flags").join(" ");
if (cFlags) configureArgs.push("-DCMAKE_C_FLAGS=" + cFlags);
const cxxFlags = core.getMultilineInput("cxx-flags").join(" ");
if (cxxFlags) configureArgs.push("-DCMAKE_CXX_FLAGS=" + cxxFlags);
const options = core
.getMultilineInput("options")
.flatMap((opts) => opts.split(" "))
.map((opt) => "-D" + opt);
configureArgs.push(...options);
const args = core
.getMultilineInput("args")
.flatMap((args) => args.split(" "));
configureArgs.push(...args);
await exec.exec("cmake", configureArgs);
core.setOutput("build-dir", buildDir || "build");
const runBuild = core.getBooleanInput("run-build");