Skip to content

Commit e4916a0

Browse files
committed
Add Macos support
1 parent f2d1671 commit e4916a0

File tree

4 files changed

+61
-13
lines changed

4 files changed

+61
-13
lines changed

.github/workflows/linux-daily-check.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ jobs:
1313
matrix:
1414
arch: [amd64, arm64]
1515
steps:
16-
- if: matrix.arch == 'arm64'
17-
uses: pguyot/arm-runner-action@v2
18-
1916
- name: Update system
2017
run: sudo apt-get update && sudo apt-get --yes upgrade
2118

@@ -35,6 +32,7 @@ jobs:
3532
env:
3633
CC: "sccache gcc"
3734
CXX: "sccache g++"
35+
ARCH: ${{ matrix.arch }}
3836
SCCACHE_GHA_ENABLED: "true"
3937
run: cd libnode-distributable && node index.js
4038

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Macos daily check
2+
3+
on:
4+
schedule:
5+
- cron: "0 8 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
update:
10+
name: Macos daily check
11+
runs-on: macos-latest
12+
strategy:
13+
matrix:
14+
arch: [amd64, arm64]
15+
steps:
16+
- name: Install building tools
17+
run: brew install node python ninja nasm git
18+
19+
- name: Clone the repo
20+
run: git clone https://github.com/devraymondsh/libnode-distributable
21+
22+
- name: Run sccache-cache
23+
uses: mozilla-actions/[email protected]
24+
25+
- name: Run the script
26+
env:
27+
CC: "sccache cc"
28+
CXX: "sccache c++"
29+
ARCH: ${{ matrix.arch }}
30+
SCCACHE_GHA_ENABLED: "true"
31+
run: cd libnode-distributable && node index.js
32+
33+
- name: Find the shared library
34+
run: find libnode-distributable/node -name libnode.so\* -not -name '*.TOC' -not -name '*.toc' -exec ls {} \;

.github/workflows/windows-daily-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
run: cd libnode-distributable ; node index.js
4141

4242
- name: Find the shared library
43-
run: dir /s libnode-distributable\node\out\Release\libnode.dll
43+
run: dir libnode-distributable\node\out\Release\libnode.dll

index.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
import os from "node:os";
21
import syncFs from "node:fs";
2+
import { cpus } from "node:os";
33
import fs from "node:fs/promises";
44
import { spawn } from "node:child_process";
55

6-
const coreCount = os.cpus().length;
7-
const threadCount = coreCount * 2;
8-
96
let CC = process.env.CC;
107
let CXX = process.env.CXX;
118
let ARCH = process.env.ARCH;
129
if (!CC) CC = "gcc";
1310
if (!CXX) CXX = "g++";
1411
if (!ARCH) ARCH = "amd64";
1512

13+
const coreCount = cpus().length;
14+
const threadCount = coreCount * 2;
15+
const arch = ARCH == "amd64" ? "x64" : "arm64";
16+
let os;
17+
switch (process.platform) {
18+
case "darwin":
19+
os = "mac";
20+
break;
21+
case "win32":
22+
os = "win";
23+
break;
24+
default:
25+
os = "linux";
26+
break;
27+
}
28+
1629
const nodejsGithubRepo = "https://github.com/nodejs/node";
1730
const removeTheVCharacter = (str) => str.replace("v", "");
1831

@@ -76,10 +89,13 @@ if (!syncFs.existsSync("node")) {
7689
);
7790
}
7891

79-
if (process.platform == "linux") {
80-
await spawnAsync("./configure", ["--ninja", "--shared"], "node");
81-
await spawnAsync("make", [`-j${threadCount}`], "node");
82-
} else if (process.platform == "win32") {
83-
const arch = ARCH == "amd64" ? "x64" : "arm64";
92+
if (process.platform == "win32") {
8493
await spawnAsync("vcbuild.bat", [arch, "dll"], "node");
94+
} else {
95+
await spawnAsync(
96+
"./configure",
97+
["--ninja", "--shared", "--dest-cpu", arch, "--dest-os", os],
98+
"node"
99+
);
100+
await spawnAsync("make", [`-j${threadCount}`], "node");
85101
}

0 commit comments

Comments
 (0)