mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-20 10:41:21 +00:00
build: build distribution files directly from TypeScript files (#221)
* build: build dist directly from TypeScript sources * build(ts): adjust options in `tsconfig.json` * fix: import all instead of default in @actions modules
This commit is contained in:
parent
e0f6aeea02
commit
d37829ef6a
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,5 +4,3 @@
|
|||||||
|
|
||||||
build/
|
build/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
src/**/*.js
|
|
||||||
|
46
dist/index.js
generated
vendored
46
dist/index.js
generated
vendored
@ -27685,6 +27685,35 @@ module.exports = parseParams
|
|||||||
/******/ }
|
/******/ }
|
||||||
/******/
|
/******/
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
/******/ /* 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 */
|
/******/ /* 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) + "/";
|
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
|
||||||
@ -27694,8 +27723,11 @@ var __webpack_exports__ = {};
|
|||||||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
||||||
(() => {
|
(() => {
|
||||||
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(2340);
|
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(2340);
|
||||||
|
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
/* harmony import */ var _actions_exec__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(4926);
|
/* harmony import */ var _actions_exec__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(4926);
|
||||||
|
/* harmony import */ var _actions_exec__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(_actions_exec__WEBPACK_IMPORTED_MODULE_1__);
|
||||||
/* harmony import */ var _actions_io__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(1793);
|
/* harmony import */ var _actions_io__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(1793);
|
||||||
|
/* harmony import */ var _actions_io__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__nccwpck_require__.n(_actions_io__WEBPACK_IMPORTED_MODULE_2__);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -27706,16 +27738,16 @@ async function main() {
|
|||||||
const generator = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("generator");
|
const generator = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("generator");
|
||||||
if (generator)
|
if (generator)
|
||||||
configureArgs.push(...["-G", generator]);
|
configureArgs.push(...["-G", generator]);
|
||||||
if (generator.match(/ninja/gi) && !(await _actions_io__WEBPACK_IMPORTED_MODULE_2__.which("ninja"))) {
|
if (generator.match(/ninja/gi) && !(await (0,_actions_io__WEBPACK_IMPORTED_MODULE_2__.which)("ninja"))) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "linux":
|
case "linux":
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("sudo", ["apt", "install", "-y", "ninja-build"]);
|
await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec)("sudo", ["apt", "install", "-y", "ninja-build"]);
|
||||||
break;
|
break;
|
||||||
case "darwin":
|
case "darwin":
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("brew", ["install", "ninja"]);
|
await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec)("brew", ["install", "ninja"]);
|
||||||
break;
|
break;
|
||||||
case "win32":
|
case "win32":
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("choco", ["install", "ninja"]);
|
await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec)("choco", ["install", "ninja"]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27738,19 +27770,19 @@ async function main() {
|
|||||||
const args = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("args")
|
const args = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("args")
|
||||||
.flatMap((args) => args.split(" "));
|
.flatMap((args) => args.split(" "));
|
||||||
configureArgs.push(...args);
|
configureArgs.push(...args);
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("cmake", configureArgs);
|
await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec)("cmake", configureArgs);
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput("build-dir", buildDir || "build");
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput("build-dir", buildDir || "build");
|
||||||
const runBuild = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput("run-build");
|
const runBuild = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput("run-build");
|
||||||
const runTest = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput("run-test");
|
const runTest = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput("run-test");
|
||||||
if (runBuild || runTest) {
|
if (runBuild || runTest) {
|
||||||
const buildArgs = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("build-args")
|
const buildArgs = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("build-args")
|
||||||
.flatMap((args) => args.split(" "));
|
.flatMap((args) => args.split(" "));
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("cmake", ["--build", buildDir || "build", ...buildArgs]);
|
await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec)("cmake", ["--build", buildDir || "build", ...buildArgs]);
|
||||||
}
|
}
|
||||||
if (runTest) {
|
if (runTest) {
|
||||||
const testArgs = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("test-args")
|
const testArgs = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getMultilineInput("test-args")
|
||||||
.flatMap((args) => args.split(" "));
|
.flatMap((args) => args.split(" "));
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec("ctest", [
|
await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec)("ctest", [
|
||||||
"--test-dir",
|
"--test-dir",
|
||||||
buildDir || "build",
|
buildDir || "build",
|
||||||
"--output-on-failure",
|
"--output-on-failure",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && ncc build src/index.js -o dist",
|
"build": "ncc build src/index.ts -o dist",
|
||||||
"format": "prettier --write --cache . !dist !README.md",
|
"format": "prettier --write --cache . !dist !README.md",
|
||||||
"lint": "eslint --ignore-path .gitignore ."
|
"lint": "eslint --ignore-path .gitignore ."
|
||||||
},
|
},
|
||||||
|
20
src/index.ts
20
src/index.ts
@ -1,6 +1,6 @@
|
|||||||
import core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import exec from "@actions/exec";
|
import { exec } from "@actions/exec";
|
||||||
import io from "@actions/io";
|
import { which } from "@actions/io";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const sourceDir = core.getInput("source-dir");
|
const sourceDir = core.getInput("source-dir");
|
||||||
@ -11,16 +11,16 @@ async function main() {
|
|||||||
const generator = core.getInput("generator");
|
const generator = core.getInput("generator");
|
||||||
if (generator) configureArgs.push(...["-G", generator]);
|
if (generator) configureArgs.push(...["-G", generator]);
|
||||||
|
|
||||||
if (generator.match(/ninja/gi) && !(await io.which("ninja"))) {
|
if (generator.match(/ninja/gi) && !(await which("ninja"))) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "linux":
|
case "linux":
|
||||||
await exec.exec("sudo", ["apt", "install", "-y", "ninja-build"]);
|
await exec("sudo", ["apt", "install", "-y", "ninja-build"]);
|
||||||
break;
|
break;
|
||||||
case "darwin":
|
case "darwin":
|
||||||
await exec.exec("brew", ["install", "ninja"]);
|
await exec("brew", ["install", "ninja"]);
|
||||||
break;
|
break;
|
||||||
case "win32":
|
case "win32":
|
||||||
await exec.exec("choco", ["install", "ninja"]);
|
await exec("choco", ["install", "ninja"]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ async function main() {
|
|||||||
.flatMap((args) => args.split(" "));
|
.flatMap((args) => args.split(" "));
|
||||||
configureArgs.push(...args);
|
configureArgs.push(...args);
|
||||||
|
|
||||||
await exec.exec("cmake", configureArgs);
|
await exec("cmake", configureArgs);
|
||||||
core.setOutput("build-dir", buildDir || "build");
|
core.setOutput("build-dir", buildDir || "build");
|
||||||
|
|
||||||
const runBuild = core.getBooleanInput("run-build");
|
const runBuild = core.getBooleanInput("run-build");
|
||||||
@ -58,14 +58,14 @@ async function main() {
|
|||||||
const buildArgs = core
|
const buildArgs = core
|
||||||
.getMultilineInput("build-args")
|
.getMultilineInput("build-args")
|
||||||
.flatMap((args) => args.split(" "));
|
.flatMap((args) => args.split(" "));
|
||||||
await exec.exec("cmake", ["--build", buildDir || "build", ...buildArgs]);
|
await exec("cmake", ["--build", buildDir || "build", ...buildArgs]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runTest) {
|
if (runTest) {
|
||||||
const testArgs = core
|
const testArgs = core
|
||||||
.getMultilineInput("test-args")
|
.getMultilineInput("test-args")
|
||||||
.flatMap((args) => args.split(" "));
|
.flatMap((args) => args.split(" "));
|
||||||
await exec.exec("ctest", [
|
await exec("ctest", [
|
||||||
"--test-dir",
|
"--test-dir",
|
||||||
buildDir || "build",
|
buildDir || "build",
|
||||||
"--output-on-failure",
|
"--output-on-failure",
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"exactOptionalPropertyTypes": true,
|
|
||||||
"strict": true,
|
|
||||||
"module": "node16",
|
"module": "node16",
|
||||||
"target": "es2022",
|
"moduleResolution": "node16",
|
||||||
"skipLibCheck": true
|
"esModuleInterop": true,
|
||||||
},
|
"target": "es2022"
|
||||||
"include": ["src"]
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user