diff --git a/.github/workflows/linux-daily-check.yml b/.github/workflows/linux-daily-check.yml index 610b789..4465ee0 100644 --- a/.github/workflows/linux-daily-check.yml +++ b/.github/workflows/linux-daily-check.yml @@ -12,7 +12,15 @@ jobs: strategy: matrix: arch: [amd64, arm64] + include: + - arch: arm64 + is_arm: true steps: + - if: ${{ matrix.is_arm }} + uses: pguyot/arm-runner-action@v2 + with: + base_image: raspios_lite_arm64:latest + - name: Update system run: sudo apt-get update && sudo apt-get --yes upgrade @@ -20,7 +28,7 @@ jobs: run: sudo apt-get install --yes ca-certificates curl gnupg && curl -sL https://deb.nodesource.com/setup_21.x | sudo bash - && sudo apt-get update - name: Install building tools - run: sudo apt-get install --yes git python3 python3-pip gcc g++ make ninja-build nodejs sudo + run: sudo apt-get install --yes git python3 python3-pip gcc g++ make build-essential libz-dev linux-libc-dev ninja-build nodejs sudo - name: Clone the repo run: git clone https://github.com/devraymondsh/libnode-distributable @@ -32,6 +40,7 @@ jobs: env: CC: "sccache gcc" CXX: "sccache g++" + CROSS_COMPILE: false ARCH: ${{ matrix.arch }} SCCACHE_GHA_ENABLED: "true" run: cd libnode-distributable && node index.js diff --git a/.github/workflows/macos-daily-check.yml b/.github/workflows/macos-daily-check.yml index 4519324..2fee945 100644 --- a/.github/workflows/macos-daily-check.yml +++ b/.github/workflows/macos-daily-check.yml @@ -12,7 +12,14 @@ jobs: strategy: matrix: arch: [amd64, arm64] + include: + - arch: amd64 + is_arm: false + - arch: arm64 + is_arm: true steps: + - run: sysctl -a | grep machdep.cpu + - name: Install building tools run: brew install node python ninja nasm git @@ -26,8 +33,11 @@ jobs: env: CC: "sccache cc" CXX: "sccache c++" + CC_host: "sccache cc" + CXX_host: "sccache c++" ARCH: ${{ matrix.arch }} SCCACHE_GHA_ENABLED: "true" + CROSS_COMPILE: ${{ matrix.is_arm }} run: cd libnode-distributable && node index.js - name: Find the shared library diff --git a/.github/workflows/windows-daily-check.yml b/.github/workflows/windows-daily-check.yml index 0db1bde..7954414 100644 --- a/.github/workflows/windows-daily-check.yml +++ b/.github/workflows/windows-daily-check.yml @@ -12,6 +12,11 @@ jobs: strategy: matrix: arch: [amd64, amd64_arm64] + include: + - arch: amd64 + is_arm: false + - arch: amd64_arm64 + is_arm: true steps: - uses: ilammy/msvc-dev-cmd@v1 with: @@ -37,6 +42,7 @@ jobs: env: ARCH: ${{ matrix.arch }} SCCACHE_GHA_ENABLED: "true" + CROSS_COMPILE: ${{ matrix.is_arm }} run: cd libnode-distributable ; node index.js - name: Find the shared library diff --git a/index.js b/index.js index 858192f..dd2339c 100644 --- a/index.js +++ b/index.js @@ -6,9 +6,11 @@ import { spawn } from "node:child_process"; let CC = process.env.CC; let CXX = process.env.CXX; let ARCH = process.env.ARCH; +let CROSS_COMPILE = process.env.CROSS_COMPILE; if (!CC) CC = "gcc"; if (!CXX) CXX = "g++"; if (!ARCH) ARCH = "amd64"; +if (!CROSS_COMPILE) CROSS_COMPILE = false; const coreCount = cpus().length; const threadCount = coreCount * 2; @@ -89,12 +91,21 @@ if (!syncFs.existsSync("node")) { ); } +let extraArgs = []; if (process.platform == "win32") { await spawnAsync("vcbuild.bat", [arch, "dll"], "node"); } else { + if (arch === "arm64") { + extraArgs.push("--with-arm-float-abi"); + extraArgs.push("hard"); + extraArgs.push("--with-arm-fpu"); + extraArgs.push("neon"); + } + if (CROSS_COMPILE) extraArgs.push("--cross-compiling"); + await spawnAsync( "./configure", - ["--ninja", "--shared", "--dest-cpu", arch, "--dest-os", os], + ["--shared", "--dest-cpu", arch, "--dest-os", os, ...extraArgs], "node" ); await spawnAsync("make", [`-j${threadCount}`], "node");