mirror of
https://github.com/threeal/cmake-action.git
synced 2026-02-01 19:40:49 +00:00
build: utilize Rollup to bundle action file (#404)
* build: utilize Rollup to bundle file * build: bundle file with `.mjs` extension
This commit is contained in:
152
dist/index.js
generated
vendored
152
dist/index.js
generated
vendored
@@ -1,152 +0,0 @@
|
||||
import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module";
|
||||
/******/ // The require scope
|
||||
/******/ var __nccwpck_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __nccwpck_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __nccwpck_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __nccwpck_require__.d = (exports, definition) => {
|
||||
/******/ for(var key in definition) {
|
||||
/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
|
||||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||
/******/ (() => {
|
||||
/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/compat */
|
||||
/******/
|
||||
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
|
||||
;// CONCATENATED MODULE: ../../../.yarn/berry/cache/catched-error-message-npm-0.0.1-9126a73d25-10c0.zip/node_modules/catched-error-message/dist/index.esm.js
|
||||
function r(r){return function(r){if("object"==typeof(e=r)&&null!==e&&"message"in e&&"string"==typeof e.message)return r;var e;try{return new Error(JSON.stringify(r))}catch(e){return new Error(String(r))}}(r).message}
|
||||
//# sourceMappingURL=index.esm.js.map
|
||||
|
||||
;// CONCATENATED MODULE: external "node:fs"
|
||||
const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
|
||||
var external_node_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_node_fs_namespaceObject);
|
||||
;// CONCATENATED MODULE: external "node:os"
|
||||
const external_node_os_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:os");
|
||||
var external_node_os_default = /*#__PURE__*/__nccwpck_require__.n(external_node_os_namespaceObject);
|
||||
;// CONCATENATED MODULE: external "node:child_process"
|
||||
const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process");
|
||||
;// CONCATENATED MODULE: ./src/cmake.ts
|
||||
|
||||
/**
|
||||
* Configures the build system of a CMake project.
|
||||
*
|
||||
* @param inputs - The action inputs.
|
||||
*/
|
||||
function configureProject(inputs) {
|
||||
const configureArgs = [];
|
||||
if (inputs.sourceDir) {
|
||||
configureArgs.push(inputs.sourceDir);
|
||||
}
|
||||
configureArgs.push("-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);
|
||||
(0,external_node_child_process_namespaceObject.execFileSync)("cmake", configureArgs, { stdio: "inherit" });
|
||||
}
|
||||
/**
|
||||
* Build a CMake project.
|
||||
*
|
||||
* @param inputs - The action inputs.
|
||||
*/
|
||||
function buildProject(inputs) {
|
||||
(0,external_node_child_process_namespaceObject.execFileSync)("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external "node:path"
|
||||
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
|
||||
var external_node_path_default = /*#__PURE__*/__nccwpck_require__.n(external_node_path_namespaceObject);
|
||||
;// CONCATENATED MODULE: ./src/inputs.ts
|
||||
|
||||
/**
|
||||
* Retrieves an action input.
|
||||
* @param key - The key of the action input.
|
||||
* @returns The action input value as a string.
|
||||
*/
|
||||
function getInput(key) {
|
||||
const value = process.env[`INPUT_${key.toUpperCase()}`] || "";
|
||||
return value.trim();
|
||||
}
|
||||
function getInputs() {
|
||||
const sourceDir = getInput("source-dir");
|
||||
return {
|
||||
sourceDir,
|
||||
buildDir: getInput("build-dir") || external_node_path_default().join(sourceDir, "build"),
|
||||
generator: getInput("generator"),
|
||||
cCompiler: getInput("c-compiler"),
|
||||
cxxCompiler: getInput("cxx-compiler"),
|
||||
cFlags: getInput("c-flags").replaceAll(/\s+/g, " "),
|
||||
cxxFlags: getInput("cxx-flags").replaceAll(/\s+/g, " "),
|
||||
options: getInput("options")
|
||||
.split(/\s+/)
|
||||
.filter((arg) => arg != ""),
|
||||
args: getInput("args")
|
||||
.split(/\s+/)
|
||||
.filter((arg) => arg != ""),
|
||||
runBuild: getInput("run-build") == "true",
|
||||
buildArgs: getInput("build-args")
|
||||
.split(/\s+/)
|
||||
.filter((arg) => arg != ""),
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/index.ts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
const inputs = getInputs();
|
||||
configureProject(inputs);
|
||||
external_node_fs_default().appendFileSync(process.env["GITHUB_OUTPUT"], `build-dir=${inputs.buildDir}${(external_node_os_default()).EOL}`);
|
||||
if (inputs.runBuild) {
|
||||
buildProject(inputs);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
process.exitCode = 1;
|
||||
process.stdout.write(`::error::${r(err)}${(external_node_os_default()).EOL}`);
|
||||
}
|
||||
|
||||
92
dist/index.mjs
generated
vendored
Normal file
92
dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
function r(r){return function(r){if("object"==typeof(e=r)&&null!==e&&"message"in e&&"string"==typeof e.message)return r;var e;try{return new Error(JSON.stringify(r))}catch(e){return new Error(String(r))}}(r).message}
|
||||
|
||||
/**
|
||||
* Configures the build system of a CMake project.
|
||||
*
|
||||
* @param inputs - The action inputs.
|
||||
*/
|
||||
function configureProject(inputs) {
|
||||
const configureArgs = [];
|
||||
if (inputs.sourceDir) {
|
||||
configureArgs.push(inputs.sourceDir);
|
||||
}
|
||||
configureArgs.push("-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);
|
||||
execFileSync("cmake", configureArgs, { stdio: "inherit" });
|
||||
}
|
||||
/**
|
||||
* Build a CMake project.
|
||||
*
|
||||
* @param inputs - The action inputs.
|
||||
*/
|
||||
function buildProject(inputs) {
|
||||
execFileSync("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an action input.
|
||||
* @param key - The key of the action input.
|
||||
* @returns The action input value as a string.
|
||||
*/
|
||||
function getInput(key) {
|
||||
const value = process.env[`INPUT_${key.toUpperCase()}`] || "";
|
||||
return value.trim();
|
||||
}
|
||||
function getInputs() {
|
||||
const sourceDir = getInput("source-dir");
|
||||
return {
|
||||
sourceDir,
|
||||
buildDir: getInput("build-dir") || path.join(sourceDir, "build"),
|
||||
generator: getInput("generator"),
|
||||
cCompiler: getInput("c-compiler"),
|
||||
cxxCompiler: getInput("cxx-compiler"),
|
||||
cFlags: getInput("c-flags").replaceAll(/\s+/g, " "),
|
||||
cxxFlags: getInput("cxx-flags").replaceAll(/\s+/g, " "),
|
||||
options: getInput("options")
|
||||
.split(/\s+/)
|
||||
.filter((arg) => arg != ""),
|
||||
args: getInput("args")
|
||||
.split(/\s+/)
|
||||
.filter((arg) => arg != ""),
|
||||
runBuild: getInput("run-build") == "true",
|
||||
buildArgs: getInput("build-args")
|
||||
.split(/\s+/)
|
||||
.filter((arg) => arg != ""),
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const inputs = getInputs();
|
||||
configureProject(inputs);
|
||||
fs.appendFileSync(process.env["GITHUB_OUTPUT"], `build-dir=${inputs.buildDir}${os.EOL}`);
|
||||
if (inputs.runBuild) {
|
||||
buildProject(inputs);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
process.exitCode = 1;
|
||||
process.stdout.write(`::error::${r(err)}${os.EOL}`);
|
||||
}
|
||||
3
dist/package.json
generated
vendored
3
dist/package.json
generated
vendored
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
Reference in New Issue
Block a user