diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b34f929a..9ec24e07 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -10,7 +10,7 @@ jobs: if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} runs-on: ${{ matrix.os }} # prettier-ignore - name: ${{ matrix.os }}-${{ matrix.node_arch }}-${{ matrix.dockerfile }}-${{ matrix.distro }} + name: ${{ matrix.os }}-${{ matrix.node_target_arch }}-${{ matrix.dockerfile }}-${{ matrix.distro }} strategy: fail-fast: false matrix: @@ -19,61 +19,79 @@ jobs: - windows-2019 node_arch: - x64 + node_target_arch: + - x64 cpp_arch: - x64 dockerfile: - "" distro: - "" - native: - - true - + vm: + - false + cross_compiling: + - false include: - os: windows-2019 node_arch: ia32 + node_target_arch: ia32 cpp_arch: amd64_x86 - native: true + vm: false + cross_compiling: true - # - os: windows-2022 - # node_arch: x64 - # arch: arm64 - # cpp_arch: amd64_arm64 + - os: windows-2022 + node_arch: x64 + node_target_arch: arm64 + cpp_arch: amd64_arm64 + vm: false + cross_compiling: true - os: macos-13 node_arch: x64 + node_target_arch: x64 cpp_arch: x64 - native: true + vm: false + cross_compiling: false - os: macos-14 node_arch: arm64 - cpp_arch: amd64_arm64 - native: true + node_target_arch: arm64 + cpp_arch: arm64 + vm: false + cross_compiling: false # Musl Alpine - os: ubuntu-24.04 dockerfile: docker/alpine.dockerfile node_arch: x64 + node_target_arch: x64 cpp_arch: x64 - native: false + vm: true + cross_compiling: false # Debian Arm - os: ubuntu-24.04 - node_arch: arm64 - cpp_arch: amd64_arm64 distro: bookworm - native: false + node_arch: arm64 + node_target_arch: arm64 + cpp_arch: arm64 + vm: true + cross_compiling: false # Musl Alpine Arm - os: ubuntu-24.04 - node_arch: arm64 - cpp_arch: amd64_arm64 distro: alpine_latest - native: false + node_arch: arm64 + node_target_arch: arm64 + cpp_arch: arm64 + vm: true + cross_compiling: false env: npm_config_arch: ${{ matrix.node_arch }} - npm_config_target_arch: ${{ matrix.node_arch }} + npm_config_target_arch: ${{ matrix.node_target_arch }} setup_node_arch: ${{ matrix.node_arch }} + cross_compiling: ${{ matrix.cross_compiling }} steps: - uses: actions/checkout@v4 @@ -96,8 +114,8 @@ jobs: shell: bash - name: Setup Cpp - if: ${{ matrix.native }} - uses: aminya/setup-cpp@v1 + if: ${{ !matrix.vm }} + uses: aminya/setup-cpp@master with: vcvarsall: ${{ contains(matrix.os, 'windows') }} cmake: true @@ -112,44 +130,38 @@ jobs: brew install gnutls autoconf automake libtool - uses: pnpm/action-setup@v4 - if: ${{ matrix.native }} + if: ${{ !matrix.vm }} with: version: 9 - name: Install Node 20 - if: ${{ matrix.native }} + if: ${{ !matrix.vm }} uses: actions/setup-node@v4 with: node-version: 20 architecture: ${{ env.setup_node_arch }} - name: Install and Build Native - if: ${{ matrix.native }} + if: ${{ !matrix.vm }} run: pnpm install - name: Build JavaScript - if: ${{ matrix.native }} + if: ${{ !matrix.vm }} run: pnpm run build.js - name: Install Node 10 - if: ${{ matrix.native && matrix.os != 'macos-14' }} + if: ${{ !matrix.vm && matrix.os != 'macos-14' }} uses: actions/setup-node@v4 with: 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.vm }} + run: node ./script/install.js - name: Use Node 20 - if: ${{ matrix.native }} + if: ${{ !matrix.vm }} uses: actions/setup-node@v4 with: node-version: 20 @@ -201,11 +213,11 @@ jobs: overwrite: true - name: Lint - if: "${{ contains(matrix.os, 'ubuntu') && matrix.native }}" + if: "${{ !matrix.vm && contains(matrix.os, 'ubuntu') }}" run: pnpm run lint-test - name: Test - if: ${{ matrix.native }} + if: ${{ !matrix.vm }} uses: nick-fields/retry@v3 with: timeout_minutes: 5 @@ -216,7 +228,7 @@ jobs: rm -rf ./tmp && mkdir -p ./tmp - name: Test Electron Windows/MacOS - if: "${{ !contains(matrix.os, 'ubuntu') && matrix.native }}" + if: "${{ !matrix.vm && !contains(matrix.os, 'ubuntu') }}" uses: nick-fields/retry@v3 with: timeout_minutes: 5 @@ -226,7 +238,7 @@ jobs: continue-on-error: true - name: Test Electron Linux - if: "${{ contains(matrix.os, 'ubuntu') && matrix.native }}" + if: "${{ !matrix.vm && contains(matrix.os, 'ubuntu') }}" uses: nick-fields/retry@v3 with: timeout_minutes: 5 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1380b8ee..5a170e82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,9 @@ if(WIN32) elseif(NOT "$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "") set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITEW6432}") set(VCPKG_TARGET_TRIPLET "x86-windows-static") + elseif("$ENV{Platform}" STREQUAL "arm64") + set(CMAKE_SYSTEM_PROCESSOR "arm64") + set(VCPKG_TARGET_TRIPLET "arm64-windows-static") else() set(CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}") set(VCPKG_TARGET_TRIPLET "x64-windows-static") diff --git a/package.json b/package.json index b8e8fcbf..b27bb435 100644 --- a/package.json +++ b/package.json @@ -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", @@ -250,4 +257,4 @@ ], "license": "MIT AND MPL-2.0", "author": "Amin Yahyaabadi , Rolf Timmermans " -} \ No newline at end of file +} diff --git a/script/install.js b/script/install.js index 83e9431f..6bb603fb 100644 --- a/script/install.js +++ b/script/install.js @@ -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.npm_config_target_arch || process.env.cross_compiling === "true") { + // cross-compilation + if (process.platform === "win32") { + if (process.env.npm_config_target_arch === "ia32") { + args = ["named-configs", "windows-x86"] + } else if (process.env.npm_config_target_arch === "arm64") { + args = ["named-configs", "windows-arm64"] + } + } + } + + cp.execFileSync(process.execPath, [cmakeTsPath, ...args], { stdio: "inherit", }) } diff --git a/src/socket.cc b/src/socket.cc index 95385db2..b7229e14 100644 --- a/src/socket.cc +++ b/src/socket.cc @@ -397,7 +397,7 @@ Napi::Value Socket::Bind(const Napi::CallbackInfo& info) { if (run_ctx->error != 0) { res.Reject(ErrnoException( Env(), static_cast(run_ctx->error), run_ctx->address) - .Value()); + .Value()); return; } @@ -491,7 +491,7 @@ Napi::Value Socket::Unbind(const Napi::CallbackInfo& info) { if (run_ctx->error != 0) { res.Reject(ErrnoException( Env(), static_cast(run_ctx->error), run_ctx->address) - .Value()); + .Value()); return; }