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

Commit 4ca913b

Browse files
committed
Add N-API prebuild for Windows arm64
1 parent dfb4b6f commit 4ca913b

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

.github/workflows/ci.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ jobs:
4545
if: ${{ matrix.os == 'ubuntu-16.04' }}
4646
name: Install additional dependencies
4747
48+
# This step can be removed as soon as official Windows arm64 builds are published:
49+
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
50+
- run: |
51+
$NodeVersion = (node --version) -replace '^.'
52+
$NodeFallbackVersion = "15.2.1"
53+
& .\script\download-node-lib-win-arm64.ps1 $NodeVersion $NodeFallbackVersion
54+
if: ${{ matrix.os == 'windows-latest' }}
55+
name: Install Windows arm64 node.lib
56+
4857
- run: npm install
4958
name: Setup environment
5059

@@ -68,16 +77,19 @@ jobs:
6877
- run: npm run prebuild-napi-x64
6978
name: Prebuild (x64)
7079

80+
- run: npm run prebuild-napi-arm64
81+
name: Prebuild (arm64)
82+
if: ${{ matrix.os != 'macos-latest' }}
83+
7184
- run: |
72-
npm run prebuild-napi-arm64
7385
docker build -t node-keytar/i386 docker/i386
7486
docker run --rm -v ${PWD}:/project node-keytar/i386 /bin/bash -c "cd /project && npm run prebuild-napi-ia32"
7587
if: ${{ matrix.os == 'ubuntu-16.04' }}
76-
name: Prebuild (x86 and arm64)
88+
name: Prebuild (Linux x86)
7789
7890
- run: npm run prebuild-napi-ia32
7991
if: ${{ matrix.os == 'windows-latest' }}
80-
name: Prebuild (x86)
92+
name: Prebuild (Windows x86)
8193

8294
- run: |
8395
ls prebuilds/

appveyor.yml

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ build_script:
2424
- npm test
2525
- npm run prebuild-napi-x64
2626
- npm run prebuild-napi-ia32
27+
- ps: >-
28+
$NodeVersion = (node --version) -replace '^.'
29+
$NodeFallbackVersion = "15.2.1"
30+
& .\script\download-node-lib-win-arm64.ps1 $NodeVersion $NodeFallbackVersion
31+
npm run prebuild-napi-arm64
2732
- if defined APPVEYOR_REPO_TAG_NAME (npm run upload)
2833

2934
test: off
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This script can be removed as soon as official Windows arm64 builds are published:
2+
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
3+
4+
$nodeVersion = $args[0]
5+
$fallbackVersion = $args[1]
6+
7+
If ($null -eq $nodeVersion -Or $null -eq $fallbackVersion) {
8+
Write-Error "No NodeJS version given as argument to this file. Run it like download-nodejs-win-arm64.ps1 NODE_VERSION NODE_FALLBACK_VERSION"
9+
exit 1
10+
}
11+
12+
$url = "https://unofficial-builds.nodejs.org/download/release/v$nodeVersion/win-arm64/node.lib"
13+
$fallbackUrl = "https://unofficial-builds.nodejs.org/download/release/v$fallbackVersion/win-arm64/node.lib"
14+
15+
# Always write to the $nodeVersion cache folder, even if we're using the fallbackVersion
16+
$cacheFolder = "$env:LOCALAPPDATA\Temp\prebuild\napi\$nodeVersion\arm64"
17+
18+
If (!(Test-Path $cacheFolder)) {
19+
New-Item -ItemType Directory -Force -Path $cacheFolder
20+
}
21+
22+
$output = "$cacheFolder\node.lib"
23+
$start_time = Get-Date
24+
25+
try {
26+
Invoke-WebRequest -Uri $url -OutFile $output
27+
$downloadedNodeVersion = $nodeVersion
28+
} catch {
29+
if ($_.Exception.Response -And $_.Exception.Response.StatusCode -eq "NotFound") {
30+
Write-Output "No arm64 node.lib found for Node Windows $nodeVersion, trying fallback version $fallbackVersion..."
31+
Invoke-WebRequest -Uri $fallbackUrl -OutFile $output
32+
$downloadedNodeVersion = $fallbackVersion
33+
}
34+
}
35+
36+
Write-Output "Downloaded arm64 NodeJS lib v$downloadedNodeVersion to $output in $((Get-Date).Subtract($start_time).Seconds) second(s)"

0 commit comments

Comments
 (0)