Skip to content

Commit

Permalink
fix: detect cross-compilation in the install script
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 12, 2025
1 parent cce4323 commit 687f885
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,9 @@ jobs:
node-version: 10
architecture: ${{ env.setup_node_arch }}

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

- name: Build Native Windows 32
if: ${{ matrix.os == 'windows-2019' && matrix.node_arch == 'ia32' }}
run:
node ./node_modules/@aminya/cmake-ts/build/main.js named-configs
windows-x86
- name: Build Node 10 Native
if: ${{ matrix.native }}
run: node ./script/install.js

- name: Use Node 20
if: ${{ matrix.native }}
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@
"runtime": "node",
"runtimeVersion": "12.22.12"
},
{
"name": "windows-arm64",
"os": "win32",
"arch": "arm64",
"runtime": "node",
"runtimeVersion": "12.22.12"
},
{
"name": "windows-x86",
"os": "win32",
Expand Down Expand Up @@ -250,4 +257,4 @@
],
"license": "MIT AND MPL-2.0",
"author": "Amin Yahyaabadi <[email protected]>, Rolf Timmermans <[email protected]>"
}
}
16 changes: 15 additions & 1 deletion script/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@ function cmakeTs() {
)
const cmakeTsPath = require.resolve("@aminya/cmake-ts/build/main.js")

cp.execFileSync(process.execPath, [cmakeTsPath, "nativeonly"], {
// Default args
let args = ["nativeonly"]

if (process.arch !== process.env.node_target_arch) {
// cross-compilation
if (process.platform === "win32") {
if (process.env.node_target_arch === "ia32") {
args = ["named-configs", "windows-x86"]
} else if (process.env.node_target_arch === "arm64") {
args = ["named-configs", "windows-arm64"]
}
}
}

cp.execFileSync(process.execPath, [cmakeTsPath, ...args], {
stdio: "inherit",
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ Napi::Value Socket::Bind(const Napi::CallbackInfo& info) {
if (run_ctx->error != 0) {
res.Reject(ErrnoException(
Env(), static_cast<int32_t>(run_ctx->error), run_ctx->address)
.Value());
.Value());
return;
}

Expand Down Expand Up @@ -491,7 +491,7 @@ Napi::Value Socket::Unbind(const Napi::CallbackInfo& info) {
if (run_ctx->error != 0) {
res.Reject(ErrnoException(
Env(), static_cast<int32_t>(run_ctx->error), run_ctx->address)
.Value());
.Value());
return;
}

Expand Down

0 comments on commit 687f885

Please sign in to comment.