mirror of
https://github.com/threeal/cmake-action.git
synced 2025-06-09 18:51:21 +00:00
refactor: add configureProject
function from lines in main
function
This commit is contained in:
parent
2643c67bac
commit
866c471b81
50
dist/index.js
generated
vendored
50
dist/index.js
generated
vendored
@ -27698,6 +27698,35 @@ var __webpack_exports__ = {};
|
|||||||
var core = __nccwpck_require__(2340);
|
var core = __nccwpck_require__(2340);
|
||||||
// EXTERNAL MODULE: ../../../.yarn/berry/cache/@actions-exec-npm-1.1.1-90973d2f96-10c0.zip/node_modules/@actions/exec/lib/exec.js
|
// EXTERNAL MODULE: ../../../.yarn/berry/cache/@actions-exec-npm-1.1.1-90973d2f96-10c0.zip/node_modules/@actions/exec/lib/exec.js
|
||||||
var exec = __nccwpck_require__(4926);
|
var exec = __nccwpck_require__(4926);
|
||||||
|
;// CONCATENATED MODULE: ./src/cmake.ts
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the build system of a CMake project.
|
||||||
|
*
|
||||||
|
* @param inputs - The action inputs.
|
||||||
|
*/
|
||||||
|
async function configureProject(inputs) {
|
||||||
|
const configureArgs = [inputs.sourceDir, "-B", inputs.buildDir];
|
||||||
|
if (inputs.generator) {
|
||||||
|
configureArgs.push(...["-G", inputs.generator]);
|
||||||
|
}
|
||||||
|
if (inputs.cCompiler) {
|
||||||
|
configureArgs.push("-DCMAKE_C_COMPILER=" + inputs.cCompiler);
|
||||||
|
}
|
||||||
|
if (inputs.cxxCompiler) {
|
||||||
|
configureArgs.push("-DCMAKE_CXX_COMPILER=" + inputs.cxxCompiler);
|
||||||
|
}
|
||||||
|
if (inputs.cFlags) {
|
||||||
|
configureArgs.push("-DCMAKE_C_FLAGS=" + inputs.cFlags);
|
||||||
|
}
|
||||||
|
if (inputs.cxxFlags) {
|
||||||
|
configureArgs.push("-DCMAKE_CXX_FLAGS=" + inputs.cxxFlags);
|
||||||
|
}
|
||||||
|
configureArgs.push(...inputs.options.map((opt) => "-D" + opt));
|
||||||
|
configureArgs.push(...inputs.args);
|
||||||
|
await (0,exec.exec)("cmake", configureArgs);
|
||||||
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./src/inputs.ts
|
;// CONCATENATED MODULE: ./src/inputs.ts
|
||||||
|
|
||||||
function getInputs() {
|
function getInputs() {
|
||||||
@ -27720,27 +27749,10 @@ function getInputs() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const inputs = getInputs();
|
const inputs = getInputs();
|
||||||
const configureArgs = [inputs.sourceDir, "-B", inputs.buildDir];
|
await configureProject(inputs);
|
||||||
if (inputs.generator) {
|
|
||||||
configureArgs.push(...["-G", inputs.generator]);
|
|
||||||
}
|
|
||||||
if (inputs.cCompiler) {
|
|
||||||
configureArgs.push("-DCMAKE_C_COMPILER=" + inputs.cCompiler);
|
|
||||||
}
|
|
||||||
if (inputs.cxxCompiler) {
|
|
||||||
configureArgs.push("-DCMAKE_CXX_COMPILER=" + inputs.cxxCompiler);
|
|
||||||
}
|
|
||||||
if (inputs.cFlags) {
|
|
||||||
configureArgs.push("-DCMAKE_C_FLAGS=" + inputs.cFlags);
|
|
||||||
}
|
|
||||||
if (inputs.cxxFlags) {
|
|
||||||
configureArgs.push("-DCMAKE_CXX_FLAGS=" + inputs.cxxFlags);
|
|
||||||
}
|
|
||||||
configureArgs.push(...inputs.options.map((opt) => "-D" + opt));
|
|
||||||
configureArgs.push(...inputs.args);
|
|
||||||
await (0,exec.exec)("cmake", configureArgs);
|
|
||||||
core.setOutput("build-dir", inputs.buildDir);
|
core.setOutput("build-dir", inputs.buildDir);
|
||||||
if (inputs.runBuild) {
|
if (inputs.runBuild) {
|
||||||
await (0,exec.exec)("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
|
await (0,exec.exec)("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
|
||||||
|
36
src/cmake.ts
Normal file
36
src/cmake.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { exec } from "@actions/exec";
|
||||||
|
import type { Inputs } from "./inputs.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the build system of a CMake project.
|
||||||
|
*
|
||||||
|
* @param inputs - The action inputs.
|
||||||
|
*/
|
||||||
|
export async function configureProject(inputs: Inputs): Promise<void> {
|
||||||
|
const configureArgs = [inputs.sourceDir, "-B", inputs.buildDir];
|
||||||
|
|
||||||
|
if (inputs.generator) {
|
||||||
|
configureArgs.push(...["-G", inputs.generator]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputs.cCompiler) {
|
||||||
|
configureArgs.push("-DCMAKE_C_COMPILER=" + inputs.cCompiler);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputs.cxxCompiler) {
|
||||||
|
configureArgs.push("-DCMAKE_CXX_COMPILER=" + inputs.cxxCompiler);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputs.cFlags) {
|
||||||
|
configureArgs.push("-DCMAKE_C_FLAGS=" + inputs.cFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputs.cxxFlags) {
|
||||||
|
configureArgs.push("-DCMAKE_CXX_FLAGS=" + inputs.cxxFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
configureArgs.push(...inputs.options.map((opt) => "-D" + opt));
|
||||||
|
configureArgs.push(...inputs.args);
|
||||||
|
|
||||||
|
await exec("cmake", configureArgs);
|
||||||
|
}
|
27
src/index.ts
27
src/index.ts
@ -1,36 +1,13 @@
|
|||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import { exec } from "@actions/exec";
|
import { exec } from "@actions/exec";
|
||||||
|
import { configureProject } from "./cmake.js";
|
||||||
import { getInputs } from "./inputs.js";
|
import { getInputs } from "./inputs.js";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const inputs = getInputs();
|
const inputs = getInputs();
|
||||||
|
|
||||||
const configureArgs = [inputs.sourceDir, "-B", inputs.buildDir];
|
await configureProject(inputs);
|
||||||
|
|
||||||
if (inputs.generator) {
|
|
||||||
configureArgs.push(...["-G", inputs.generator]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputs.cCompiler) {
|
|
||||||
configureArgs.push("-DCMAKE_C_COMPILER=" + inputs.cCompiler);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputs.cxxCompiler) {
|
|
||||||
configureArgs.push("-DCMAKE_CXX_COMPILER=" + inputs.cxxCompiler);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputs.cFlags) {
|
|
||||||
configureArgs.push("-DCMAKE_C_FLAGS=" + inputs.cFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputs.cxxFlags) {
|
|
||||||
configureArgs.push("-DCMAKE_CXX_FLAGS=" + inputs.cxxFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
configureArgs.push(...inputs.options.map((opt) => "-D" + opt));
|
|
||||||
configureArgs.push(...inputs.args);
|
|
||||||
|
|
||||||
await exec("cmake", configureArgs);
|
|
||||||
core.setOutput("build-dir", inputs.buildDir);
|
core.setOutput("build-dir", inputs.buildDir);
|
||||||
|
|
||||||
if (inputs.runBuild) {
|
if (inputs.runBuild) {
|
||||||
|
Loading…
Reference in New Issue
Block a user