Skip to content

Commit 384b3d8

Browse files
authored
Merge pull request #693 from zeromq/windows-arm
feat: support Windows ARM
2 parents 9a327fa + d8f9eff commit 384b3d8

File tree

5 files changed

+63
-59
lines changed

5 files changed

+63
-59
lines changed

Diff for: .github/workflows/CI.yml

+32-39
Original file line numberDiff line numberDiff line change
@@ -10,78 +10,76 @@ jobs:
1010
if: ${{ !contains(github.event.head_commit.message, '[skip build]') }}
1111
runs-on: ${{ matrix.os }}
1212
# prettier-ignore
13-
name: ${{ matrix.os }}-${{ matrix.node_arch }}-${{ matrix.distro }}-${{ matrix.platform }}
13+
name: ${{ matrix.os }} ${{ matrix.target_arch }} ${{ matrix.distro }} ${{ matrix.platform }}
1414
strategy:
1515
fail-fast: false
1616
matrix:
1717
os:
1818
- ubuntu-24.04
1919
- windows-2019
20+
- macos-13
2021
node_arch:
2122
- x64
2223
cpp_arch:
2324
- x64
25+
target_arch:
26+
- x64
2427
distro:
2528
- ""
26-
native:
27-
- true
28-
2929
include:
30+
# Windows x86
3031
- os: windows-2019
31-
node_arch: ia32
32+
node_arch: x64
33+
target_arch: ia32
3234
cpp_arch: amd64_x86
33-
native: true
3435

35-
# - os: windows-2022
36-
# node_arch: x64
37-
# arch: arm64
38-
# cpp_arch: amd64_arm64
39-
40-
- os: macos-13
36+
# Windows Arm64
37+
- os: windows-2022
4138
node_arch: x64
42-
cpp_arch: x64
43-
native: true
39+
target_arch: arm64
40+
cpp_arch: amd64_arm64
4441

42+
# MacOS Arm64
4543
- os: macos-14
4644
node_arch: arm64
45+
target_arch: arm64
4746
cpp_arch: amd64_arm64
48-
native: true
4947

50-
# Ubuntu x64
48+
# Ubuntu 20.04 x64
5149
- os: ubuntu-24.04
5250
distro: ubuntu
5351
platform: linux/amd64
5452
node_arch: x64
53+
target_arch: x64
5554
cpp_arch: x64
56-
native: false
5755

58-
# Ubuntu Arm
56+
# Ubuntu 20.04 Arm64
5957
- os: ubuntu-24.04-arm
6058
distro: ubuntu
6159
platform: linux/arm64
6260
node_arch: arm64
61+
target_arch: arm64
6362
cpp_arch: arm64
64-
native: false
6563

6664
# Musl Alpine
6765
- os: ubuntu-24.04
6866
distro: alpine
6967
platform: linux/amd64
7068
node_arch: x64
69+
target_arch: x64
7170
cpp_arch: x64
72-
native: false
7371

7472
# Musl Alpine Arm
7573
- os: ubuntu-24.04-arm
7674
distro: alpine
7775
platform: linux/arm64
7876
node_arch: arm64
77+
target_arch: arm64
7978
cpp_arch: arm64
80-
native: false
8179

8280
env:
8381
npm_config_arch: ${{ matrix.node_arch }}
84-
npm_config_target_arch: ${{ matrix.node_arch }}
82+
npm_config_target_arch: ${{ matrix.target_arch }}
8583
setup_node_arch: ${{ matrix.node_arch }}
8684
steps:
8785
- uses: actions/checkout@v4
@@ -105,7 +103,7 @@ jobs:
105103
shell: bash
106104

107105
- name: Setup Cpp
108-
if: ${{ matrix.native }}
106+
if: ${{ ! matrix.distro }}
109107
uses: aminya/setup-cpp@v1
110108
with:
111109
vcvarsall: ${{ contains(matrix.os, 'windows') }}
@@ -121,41 +119,36 @@ jobs:
121119
brew install gnutls autoconf automake libtool
122120
123121
- uses: pnpm/action-setup@v4
124-
if: ${{ matrix.native }}
122+
if: ${{ ! matrix.distro }}
125123

126124
- name: Install Node 20
127-
if: ${{ matrix.native }}
125+
if: ${{ ! matrix.distro }}
128126
uses: actions/setup-node@v4
129127
with:
130128
node-version: 20
131129
architecture: ${{ env.setup_node_arch }}
132130

133131
- name: Install and Build Native
134-
if: ${{ matrix.native }}
132+
if: ${{ ! matrix.distro }}
135133
run: pnpm install
136134

137135
- name: Build JavaScript
138-
if: ${{ matrix.native }}
136+
if: ${{ ! matrix.distro }}
139137
run: pnpm run build.js
140138

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

148146
- name: Build Native
149-
if: ${{ matrix.native && matrix.node_arch != 'ia32' }}
147+
if: ${{ ! matrix.distro }}
150148
run: npm run build.native
151149

152-
- name: Build Native Windows 32
153-
if: ${{ matrix.os == 'windows-2019' && matrix.node_arch == 'ia32' }}
154-
run:
155-
node --enable-source-maps ./node_modules/cmake-ts/build/main.js build --config win32-ia32-release
156-
157150
- name: Use Node 20
158-
if: ${{ matrix.native }}
151+
if: ${{ ! matrix.distro }}
159152
uses: actions/setup-node@v4
160153
with:
161154
node-version: 20
@@ -190,11 +183,11 @@ jobs:
190183
overwrite: true
191184

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

196189
- name: Test
197-
if: ${{ matrix.native }}
190+
if: ${{ ! matrix.distro && !(matrix.os == 'windows-2022' && matrix.target_arch == 'arm64') }}
198191
uses: nick-fields/retry@v3
199192
with:
200193
timeout_minutes: 5
@@ -205,7 +198,7 @@ jobs:
205198
rm -rf ./tmp && mkdir -p ./tmp
206199
207200
- name: Test Electron Windows/MacOS
208-
if: "${{ !contains(matrix.os, 'ubuntu') && matrix.native }}"
201+
if: "${{ !contains(matrix.os, 'ubuntu') && !matrix.distro && !(matrix.os == 'windows-2022' && matrix.target_arch == 'arm64') }}"
209202
uses: nick-fields/retry@v3
210203
with:
211204
timeout_minutes: 5
@@ -215,7 +208,7 @@ jobs:
215208
continue-on-error: true
216209

217210
- name: Test Electron Linux
218-
if: "${{ contains(matrix.os, 'ubuntu') && matrix.native }}"
211+
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.distro }}"
219212
uses: nick-fields/retry@v3
220213
with:
221214
timeout_minutes: 5

Diff for: CMakeLists.txt

+18-7
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,26 @@ endif()
6565

6666
# target system on Windows (for cross-compiling x86) and static linking runtimes
6767
if(WIN32)
68-
if("$ENV{Platform}" STREQUAL "x86")
69-
set(CMAKE_SYSTEM_PROCESSOR "x86")
70-
set(VCPKG_TARGET_TRIPLET "x86-windows-static")
71-
elseif(NOT "$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "")
72-
set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITEW6432}")
68+
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "")
69+
if("$ENV{Platform}" STREQUAL "x86")
70+
set(CMAKE_SYSTEM_PROCESSOR "x86")
71+
elseif(NOT "$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "")
72+
set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITEW6432}")
73+
else()
74+
set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
75+
endif()
76+
endif()
77+
78+
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR_LOWER)
79+
80+
if("${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "amd64" OR "${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "x64")
81+
set(VCPKG_TARGET_TRIPLET "x64-windows-static")
82+
elseif("${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "arm64" OR "${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "aarch64")
83+
set(VCPKG_TARGET_TRIPLET "arm64-windows-static")
84+
elseif("${CMAKE_SYSTEM_PROCESSOR_LOWER}" STREQUAL "x86")
7385
set(VCPKG_TARGET_TRIPLET "x86-windows-static")
7486
else()
75-
set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
76-
set(VCPKG_TARGET_TRIPLET "x64-windows-static")
87+
message(STATUS "Not setting VCPKG_TARGET_TRIPLET for ${CMAKE_SYSTEM_PROCESSOR}")
7788
endif()
7889

7990
# Avoid loading of project_optinos/WindowsToolchain

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
},
2020
"homepage": "http://zeromq.github.io/zeromq.js/",
2121
"dependencies": {
22-
"cmake-ts": "1.0.0",
23-
"node-addon-api": "^8.3.0"
22+
"cmake-ts": "1.0.2",
23+
"node-addon-api": "^8.3.1"
2424
},
2525
"devDependencies": {
2626
"@types/benchmark": "~2.1.5",

Diff for: pnpm-lock.yaml

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: script/install.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function cmakeTs() {
1515
)
1616
}
1717

18-
cp.execFileSync(process.execPath, [cmakeTsPath, "nativeonly"], {
18+
cp.execFileSync(process.execPath, [cmakeTsPath, "build"], {
1919
stdio: "inherit",
2020
})
2121
}

0 commit comments

Comments
 (0)