Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Ninja if It Was Not Available #82

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions main/index.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1"
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
Expand Down
15 changes: 15 additions & 0 deletions src/main.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import core from "@actions/core";
import exec from "@actions/exec";
import io from "@actions/io";

async function main() {
const sourceDir = core.getInput("source-dir");
Expand All @@ -10,6 +11,20 @@ async function main() {
const generator = core.getInput("generator");
if (generator) configureArgs.push(...["-G", generator]);

if (generator.match(/ninja/gi) && !(await io.which("ninja"))) {
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);

Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ __metadata:
languageName: node
linkType: hard

"@actions/io@npm:^1.0.1":
"@actions/io@npm:^1.0.1, @actions/io@npm:^1.1.3":
version: 1.1.3
resolution: "@actions/io@npm:1.1.3"
checksum: 5b8751918e5bf0bebd923ba917fb1c0e294401e7ff0037f32c92a4efa4215550df1f6633c63fd4efb2bdaae8711e69b9e36925857db1f38935ff62a5c92ec29e
Expand Down Expand Up @@ -1617,6 +1617,7 @@ __metadata:
dependencies:
"@actions/core": "npm:^1.10.1"
"@actions/exec": "npm:^1.1.1"
"@actions/io": "npm:^1.1.3"
"@jest/globals": "npm:^29.7.0"
"@types/jest": "npm:^29.5.8"
"@types/node": "npm:^20.9.0"
Expand Down
Loading