Skip to content

Commit 687f885

Browse files
committed
fix: detect cross-compilation in the install script
1 parent cce4323 commit 687f885

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

.github/workflows/CI.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,9 @@ jobs:
147147
node-version: 10
148148
architecture: ${{ env.setup_node_arch }}
149149

150-
- name: Build Native
151-
if: ${{ matrix.native && matrix.node_arch != 'ia32' }}
152-
run: npm run build.native
153-
154-
- name: Build Native Windows 32
155-
if: ${{ matrix.os == 'windows-2019' && matrix.node_arch == 'ia32' }}
156-
run:
157-
node ./node_modules/@aminya/cmake-ts/build/main.js named-configs
158-
windows-x86
150+
- name: Build Node 10 Native
151+
if: ${{ matrix.native }}
152+
run: node ./script/install.js
159153

160154
- name: Use Node 20
161155
if: ${{ matrix.native }}

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@
177177
"runtime": "node",
178178
"runtimeVersion": "12.22.12"
179179
},
180+
{
181+
"name": "windows-arm64",
182+
"os": "win32",
183+
"arch": "arm64",
184+
"runtime": "node",
185+
"runtimeVersion": "12.22.12"
186+
},
180187
{
181188
"name": "windows-x86",
182189
"os": "win32",
@@ -250,4 +257,4 @@
250257
],
251258
"license": "MIT AND MPL-2.0",
252259
"author": "Amin Yahyaabadi <[email protected]>, Rolf Timmermans <[email protected]>"
253-
}
260+
}

script/install.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,21 @@ function cmakeTs() {
77
)
88
const cmakeTsPath = require.resolve("@aminya/cmake-ts/build/main.js")
99

10-
cp.execFileSync(process.execPath, [cmakeTsPath, "nativeonly"], {
10+
// Default args
11+
let args = ["nativeonly"]
12+
13+
if (process.arch !== process.env.node_target_arch) {
14+
// cross-compilation
15+
if (process.platform === "win32") {
16+
if (process.env.node_target_arch === "ia32") {
17+
args = ["named-configs", "windows-x86"]
18+
} else if (process.env.node_target_arch === "arm64") {
19+
args = ["named-configs", "windows-arm64"]
20+
}
21+
}
22+
}
23+
24+
cp.execFileSync(process.execPath, [cmakeTsPath, ...args], {
1125
stdio: "inherit",
1226
})
1327
}

src/socket.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ Napi::Value Socket::Bind(const Napi::CallbackInfo& info) {
397397
if (run_ctx->error != 0) {
398398
res.Reject(ErrnoException(
399399
Env(), static_cast<int32_t>(run_ctx->error), run_ctx->address)
400-
.Value());
400+
.Value());
401401
return;
402402
}
403403

@@ -491,7 +491,7 @@ Napi::Value Socket::Unbind(const Napi::CallbackInfo& info) {
491491
if (run_ctx->error != 0) {
492492
res.Reject(ErrnoException(
493493
Env(), static_cast<int32_t>(run_ctx->error), run_ctx->address)
494-
.Value());
494+
.Value());
495495
return;
496496
}
497497

0 commit comments

Comments
 (0)