Skip to content

feat: support Windows ARM #693

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

Merged
merged 12 commits into from
Apr 13, 2025
Merged
71 changes: 32 additions & 39 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,78 +10,76 @@ jobs:
if: ${{ !contains(github.event.head_commit.message, '[skip build]') }}
runs-on: ${{ matrix.os }}
# prettier-ignore
name: ${{ matrix.os }}-${{ matrix.node_arch }}-${{ matrix.distro }}-${{ matrix.platform }}
name: ${{ matrix.os }} ${{ matrix.target_arch }} ${{ matrix.distro }} ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
- windows-2019
- macos-13
node_arch:
- x64
cpp_arch:
- x64
target_arch:
- x64
distro:
- ""
native:
- true

include:
# Windows x86
- os: windows-2019
node_arch: ia32
node_arch: x64
target_arch: ia32
cpp_arch: amd64_x86
native: true

# - os: windows-2022
# node_arch: x64
# arch: arm64
# cpp_arch: amd64_arm64

- os: macos-13
# Windows Arm64
- os: windows-2022
node_arch: x64
cpp_arch: x64
native: true
target_arch: arm64
cpp_arch: amd64_arm64

# MacOS Arm64
- os: macos-14
node_arch: arm64
target_arch: arm64
cpp_arch: amd64_arm64
native: true

# Ubuntu x64
# Ubuntu 20.04 x64
- os: ubuntu-24.04
distro: ubuntu
platform: linux/amd64
node_arch: x64
target_arch: x64
cpp_arch: x64
native: false

# Ubuntu Arm
# Ubuntu 20.04 Arm64
- os: ubuntu-24.04-arm
distro: ubuntu
platform: linux/arm64
node_arch: arm64
target_arch: arm64
cpp_arch: arm64
native: false

# Musl Alpine
- os: ubuntu-24.04
distro: alpine
platform: linux/amd64
node_arch: x64
target_arch: x64
cpp_arch: x64
native: false

# Musl Alpine Arm
- os: ubuntu-24.04-arm
distro: alpine
platform: linux/arm64
node_arch: arm64
target_arch: arm64
cpp_arch: arm64
native: false

env:
npm_config_arch: ${{ matrix.node_arch }}
npm_config_target_arch: ${{ matrix.node_arch }}
npm_config_target_arch: ${{ matrix.target_arch }}
setup_node_arch: ${{ matrix.node_arch }}
steps:
- uses: actions/checkout@v4
Expand All @@ -105,7 +103,7 @@ jobs:
shell: bash

- name: Setup Cpp
if: ${{ matrix.native }}
if: ${{ ! matrix.distro }}
uses: aminya/setup-cpp@v1
with:
vcvarsall: ${{ contains(matrix.os, 'windows') }}
Expand All @@ -121,41 +119,36 @@ jobs:
brew install gnutls autoconf automake libtool

- uses: pnpm/action-setup@v4
if: ${{ matrix.native }}
if: ${{ ! matrix.distro }}

- name: Install Node 20
if: ${{ matrix.native }}
if: ${{ ! matrix.distro }}
uses: actions/setup-node@v4
with:
node-version: 20
architecture: ${{ env.setup_node_arch }}

- name: Install and Build Native
if: ${{ matrix.native }}
if: ${{ ! matrix.distro }}
run: pnpm install

- name: Build JavaScript
if: ${{ matrix.native }}
if: ${{ ! matrix.distro }}
run: pnpm run build.js

- name: Install Node 12
if: ${{ matrix.native && matrix.os != 'macos-14' }}
if: ${{ !matrix.distro && matrix.os != 'macos-14' && !(matrix.os == 'windows-2022' && matrix.target_arch == 'arm64') }}
uses: actions/setup-node@v4
with:
node-version: 12
architecture: ${{ env.setup_node_arch }}

- name: Build Native
if: ${{ matrix.native && matrix.node_arch != 'ia32' }}
if: ${{ ! matrix.distro }}
run: npm run build.native

- name: Build Native Windows 32
if: ${{ matrix.os == 'windows-2019' && matrix.node_arch == 'ia32' }}
run:
node --enable-source-maps ./node_modules/cmake-ts/build/main.js build --config win32-ia32-release

- name: Use Node 20
if: ${{ matrix.native }}
if: ${{ ! matrix.distro }}
uses: actions/setup-node@v4
with:
node-version: 20
Expand Down Expand Up @@ -190,11 +183,11 @@ jobs:
overwrite: true

- name: Lint
if: "${{ contains(matrix.os, 'ubuntu') && matrix.native }}"
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.distro }}"
run: pnpm run lint-test

- name: Test
if: ${{ matrix.native }}
if: ${{ ! matrix.distro && !(matrix.os == 'windows-2022' && matrix.target_arch == 'arm64') }}
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
Expand All @@ -205,7 +198,7 @@ jobs:
rm -rf ./tmp && mkdir -p ./tmp

- name: Test Electron Windows/MacOS
if: "${{ !contains(matrix.os, 'ubuntu') && matrix.native }}"
if: "${{ !contains(matrix.os, 'ubuntu') && !matrix.distro && !(matrix.os == 'windows-2022' && matrix.target_arch == 'arm64') }}"
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
Expand All @@ -215,7 +208,7 @@ jobs:
continue-on-error: true

- name: Test Electron Linux
if: "${{ contains(matrix.os, 'ubuntu') && matrix.native }}"
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.distro }}"
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
Expand Down
25 changes: 18 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,26 @@ endif()

# target system on Windows (for cross-compiling x86) and static linking runtimes
if(WIN32)
if("$ENV{Platform}" STREQUAL "x86")
set(CMAKE_SYSTEM_PROCESSOR "x86")
set(VCPKG_TARGET_TRIPLET "x86-windows-static")
elseif(NOT "$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "")
set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITEW6432}")
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "")
if("$ENV{Platform}" STREQUAL "x86")
set(CMAKE_SYSTEM_PROCESSOR "x86")
elseif(NOT "$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "")
set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITEW6432}")
else()
set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
endif()
endif()

string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR_LOWER)

if("${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "amd64" OR "${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "x64")
set(VCPKG_TARGET_TRIPLET "x64-windows-static")
elseif("${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "arm64" OR "${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "aarch64")
set(VCPKG_TARGET_TRIPLET "arm64-windows-static")
elseif("${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "x86")
set(VCPKG_TARGET_TRIPLET "x86-windows-static")
else()
set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
set(VCPKG_TARGET_TRIPLET "x64-windows-static")
message(STATUS "Not setting VCPKG_TARGET_TRIPLET for ${CMAKE_SYSTEM_PROCESSOR}")
endif()

# Avoid loading of project_optinos/WindowsToolchain
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
},
"homepage": "http://zeromq.github.io/zeromq.js/",
"dependencies": {
"cmake-ts": "1.0.0",
"node-addon-api": "^8.3.0"
"cmake-ts": "1.0.2",
"node-addon-api": "^8.3.1"
},
"devDependencies": {
"@types/benchmark": "~2.1.5",
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion script/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
}

cp.execFileSync(process.execPath, [cmakeTsPath, "nativeonly"], {
cp.execFileSync(process.execPath, [cmakeTsPath, "build"], {
stdio: "inherit",
})
}
Expand Down Expand Up @@ -48,7 +48,7 @@
cmakeTs()
} else {
try {
require("../lib/load-addon.js")

Check warning on line 51 in script/install.js

View workflow job for this annotation

GitHub Actions / ubuntu-24.04 x64

Imported module should be assigned
} catch (error) {
devWarn(error)
cmakeTs()
Expand Down
Loading