Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Add N-API prebuild for Windows arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisameling committed Nov 19, 2020
1 parent dfb4b6f commit 4ca913b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ jobs:
if: ${{ matrix.os == 'ubuntu-16.04' }}
name: Install additional dependencies
# This step can be removed as soon as official Windows arm64 builds are published:
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
- run: |
$NodeVersion = (node --version) -replace '^.'
$NodeFallbackVersion = "15.2.1"
& .\script\download-node-lib-win-arm64.ps1 $NodeVersion $NodeFallbackVersion
if: ${{ matrix.os == 'windows-latest' }}
name: Install Windows arm64 node.lib
- run: npm install
name: Setup environment

Expand All @@ -68,16 +77,19 @@ jobs:
- run: npm run prebuild-napi-x64
name: Prebuild (x64)

- run: npm run prebuild-napi-arm64
name: Prebuild (arm64)
if: ${{ matrix.os != 'macos-latest' }}

- run: |
npm run prebuild-napi-arm64
docker build -t node-keytar/i386 docker/i386
docker run --rm -v ${PWD}:/project node-keytar/i386 /bin/bash -c "cd /project && npm run prebuild-napi-ia32"
if: ${{ matrix.os == 'ubuntu-16.04' }}
name: Prebuild (x86 and arm64)
name: Prebuild (Linux x86)
- run: npm run prebuild-napi-ia32
if: ${{ matrix.os == 'windows-latest' }}
name: Prebuild (x86)
name: Prebuild (Windows x86)

- run: |
ls prebuilds/
Expand Down
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ build_script:
- npm test
- npm run prebuild-napi-x64
- npm run prebuild-napi-ia32
- ps: >-
$NodeVersion = (node --version) -replace '^.'
$NodeFallbackVersion = "15.2.1"
& .\script\download-node-lib-win-arm64.ps1 $NodeVersion $NodeFallbackVersion
npm run prebuild-napi-arm64
- if defined APPVEYOR_REPO_TAG_NAME (npm run upload)

test: off
Expand Down
36 changes: 36 additions & 0 deletions script/download-node-lib-win-arm64.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This script can be removed as soon as official Windows arm64 builds are published:
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342

$nodeVersion = $args[0]
$fallbackVersion = $args[1]

If ($null -eq $nodeVersion -Or $null -eq $fallbackVersion) {
Write-Error "No NodeJS version given as argument to this file. Run it like download-nodejs-win-arm64.ps1 NODE_VERSION NODE_FALLBACK_VERSION"
exit 1
}

$url = "https://unofficial-builds.nodejs.org/download/release/v$nodeVersion/win-arm64/node.lib"
$fallbackUrl = "https://unofficial-builds.nodejs.org/download/release/v$fallbackVersion/win-arm64/node.lib"

# Always write to the $nodeVersion cache folder, even if we're using the fallbackVersion
$cacheFolder = "$env:LOCALAPPDATA\Temp\prebuild\napi\$nodeVersion\arm64"

If (!(Test-Path $cacheFolder)) {
New-Item -ItemType Directory -Force -Path $cacheFolder
}

$output = "$cacheFolder\node.lib"
$start_time = Get-Date

try {
Invoke-WebRequest -Uri $url -OutFile $output
$downloadedNodeVersion = $nodeVersion
} catch {
if ($_.Exception.Response -And $_.Exception.Response.StatusCode -eq "NotFound") {
Write-Output "No arm64 node.lib found for Node Windows $nodeVersion, trying fallback version $fallbackVersion..."
Invoke-WebRequest -Uri $fallbackUrl -OutFile $output
$downloadedNodeVersion = $fallbackVersion
}
}

Write-Output "Downloaded arm64 NodeJS lib v$downloadedNodeVersion to $output in $((Get-Date).Subtract($start_time).Seconds) second(s)"

0 comments on commit 4ca913b

Please sign in to comment.