Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add aarch64-pc-windows-msvc target #949

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ jobs:
build: yarn build --target x86_64-pc-windows-msvc
target: 'x86_64-pc-windows-msvc'
downloadTarget: ''
- host: windows-latest
setup: |
choco upgrade llvm
build: yarn build --target aarch64-pc-windows-msvc
target: 'aarch64-pc-windows-msvc'
downloadTarget: 'aarch64-pc-windows-msvc'
- host: ubuntu-latest
target: 'x86_64-unknown-linux-gnu'
downloadTarget: ''
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/skia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,57 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-windows-arm64:
if: "!contains(github.event.head_commit.message, 'skip skia')"

name: stable - windows-arm64 - build skia
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: List llvm dir
run: ls -R "C:\Program Files\LLVM"
shell: bash

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'

- uses: actions/setup-python@v5
with:
python-version: '3.x'
architecture: 'x64'

- name: Set env
run: echo "${PWD}/depot_tools" >> $GITHUB_PATH
shell: bash

- name: Install tools on Windows
run: |
choco install llvm ninja -y
choco upgrade llvm
pip install certifi

- name: Compile skia
shell: powershell
env:
PYTHONHTTPSVERIFY: 0
run: node ./scripts/build-skia.js --target=aarch64-pc-windows-msvc

- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: Upload release
run: node ./scripts/release-skia-binary.mjs --upload --target=aarch64-pc-windows-msvc
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-apple-silicon:
if: "!contains(github.event.head_commit.message, 'skip skia')"

Expand Down
3 changes: 3 additions & 0 deletions npm/win32-arm64-msvc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@napi-rs/canvas-win32-arm64-msvc`

This is the **aarch64-pc-windows-msvc** binary for `@napi-rs/canvas`
40 changes: 40 additions & 0 deletions npm/win32-arm64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@napi-rs/canvas-win32-arm64-msvc",
"version": "0.1.62",
"os": [
"win32"
],
"cpu": [
"arm64"
],
"main": "skia.win32-arm64-msvc.node",
"files": [
"skia.win32-arm64-msvc.node"
],
"description": "Canvas for Node.js with skia backend",
"keywords": [
"napi-rs",
"NAPI",
"N-API",
"Rust",
"node-addon",
"node-addon-api",
"canvas",
"image",
"pdf",
"svg",
"skia"
],
"license": "MIT",
"engines": {
"node": ">= 10"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Brooooooklyn/canvas.git"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"additional": [
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-musl",
"aarch64-pc-windows-msvc",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"aarch64-apple-darwin",
Expand Down
17 changes: 14 additions & 3 deletions scripts/build-skia.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const GN_ARGS = [
`skia_use_libjpeg_turbo_encode=true`,
`skia_use_libwebp_decode=true`,
`skia_use_libwebp_encode=true`,
`skia_use_freetype=true`,
`skia_use_freetype_woff2=true`,
`skia_use_freetype=${TARGET_TRIPLE !== 'aarch64-pc-windows-msvc'}`,
`skia_use_freetype_woff2=${TARGET_TRIPLE !== 'aarch64-pc-windows-msvc'}`,
`skia_use_fontconfig=false`,
`skia_use_x11=false`,
`skia_use_wuffs=true`,
Expand Down Expand Up @@ -108,7 +108,7 @@ switch (PLATFORM_NAME) {
ExtraSkiaBuildFlag = `clang_win_version=\\"${clangVersion}\\"`
}
GN_ARGS.push(`clang_win=\\"C:\\\\Program Files\\\\LLVM\\"`)
GN_ARGS.push(`skia_enable_fontmgr_win=false`)
GN_ARGS.push(`skia_enable_fontmgr_win=${TARGET_TRIPLE === 'aarch64-pc-windows-msvc'}`)
break
case 'linux':
case 'darwin':
Expand Down Expand Up @@ -144,6 +144,17 @@ switch (PLATFORM_NAME) {
}

switch (TARGET_TRIPLE) {
case 'aarch64-pc-windows-msvc':
ExtraCflagsCC += ', \\"--target=aarch64-pc-windows-msvc\\"'
ExtraCflags = '\\"--target=aarch64-pc-windows-msvc\\"'
ExtraSkiaBuildFlag += ' target_cpu=\\"arm64\\" target_os=\\"win\\"'
ExtraAsmFlags = '\\"--target=aarch64-pc-windows-msvc\\"'
GN_ARGS.push(
`extra_asmflags=[${ExtraAsmFlags}]`,
`extra_cflags=[${ExtraCflags}]`,
`extra_cflags_c=[${ExtraCflags}]`,
)
break
case 'aarch64-unknown-linux-gnu':
ExtraSkiaBuildFlag += ' target_cpu="arm64" target_os="linux"'
ExtraCflags =
Expand Down
2 changes: 1 addition & 1 deletion scripts/release-skia-binary.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ async function download() {
if (PLATFORM_NAME === 'win32') {
await downloadIcu()
await fs.copyFile(join(dirname, '..', ICU_DAT), join(dirname, '..', 'npm', 'win32-x64-msvc', ICU_DAT))
await fs.copyFile(join(dirname, '..', ICU_DAT), join(dirname, '..', 'npm', 'win32-arm64-msvc', ICU_DAT))
}
}

Expand All @@ -135,7 +136,6 @@ function downloadIcu() {
execSync(`curl -J -L -H "Accept: application/octet-stream" ${downloadUrl} -o ${ICU_DAT}`, {
stdio: 'inherit',
})
copyFileSync(join(dirname, '..', ICU_DAT), join(dirname, '..', 'npm', 'win32-x64-msvc', ICU_DAT))
return Promise.resolve(null)
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export function libPath(lib, hostPlatform, triple, tag = TAG) {
}
} else {
switch (triple) {
case 'aarch64-pc-windows-msvc':
platformName = `${lib}-win32-aarch64-msvc.lib`
break
case 'aarch64-unknown-linux-gnu':
platformName = `lib${lib}-linux-aarch64-gnu.a`
break
Expand Down
Loading