Skip to content

Commit

Permalink
Merge pull request #14 from samizdatco/neon-napi
Browse files Browse the repository at this point in the history
Rewrite bindings using Neon's N-API backend
  • Loading branch information
samizdatco authored May 22, 2021
2 parents 43eb2b4 + fe56522 commit 8408313
Show file tree
Hide file tree
Showing 55 changed files with 6,264 additions and 6,541 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Compile binaries
on:
workflow_dispatch:
push:
tags:
- "v*"

jobs:
x86-platform:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- windows-latest
- ubuntu-18.04
node:
- 15

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Use Rust
uses: actions-rs/[email protected]
with:
toolchain: stable

- name: Build module
run: |
npm ci --ignore-scripts
npm run build -- --release
- name: Bundle ICU data (windows only)
if: startsWith(matrix.os,'windows')
shell: bash
run: |
ICU=$(find . -name icudtl.dat | grep skia-bindings | head -n 1)
cp $ICU lib/v6
- name: Package module
run: |
npm test
npm run package
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
npm run upload
apple-silicon:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
node:
- 15

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Use Rust
uses: actions-rs/[email protected]
with:
target: aarch64-apple-darwin
toolchain: nightly
override: true

- name: Inspect xcode paths
run: |
SDK=$(xcodebuild -showsdks -json | jq -r '.[] | .canonicalName' | grep '^macosx' | tail -n 1)
echo "SDKROOT=$(xcrun -sdk $SDK --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk $SDK --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Build & package module
run: |
npm ci --ignore-scripts
npm run build -- --release --target aarch64-apple-darwin
sed -i.bak 's/"package_name":.*/"package_name": "{platform}-arm64-{node_napi_label}.tar.gz",/' package.json
npm run package
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
npm run upload
24 changes: 24 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish to NPM
on:
workflow_dispatch:
release:
types: [published]

jobs:
publish:
name: Publish to NPM
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 15

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --dry-run
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: New release
on:
push:
tags:
- "v*"

jobs:
new-release:
name: Create Release
runs-on: ubuntu-latest

steps:
- name: Auto-generate release
uses: marvinpinto/[email protected]
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
draft: true
55 changes: 55 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Run tests
on:
workflow_dispatch:
push:
branches:
- master
- neon-napi
- gl
pull_request:
branches:
- main

jobs:
run-tests:
name: Rebuild & Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- windows-latest
- ubuntu-18.04
node:
- 10
- 15

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Use Rust
uses: actions-rs/[email protected]
with:
toolchain: stable

- name: Build module
run: |
npm ci --ignore-scripts
npm run build
- name: Bundle ICU data (windows only)
if: startsWith(matrix.os,'windows')
shell: bash
run: |
ICU=$(find . -name icudtl.dat | grep skia-bindings | head -n 1)
cp $ICU lib/v6
- name: Run tests
run: npm test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ node_modules
native/artifacts.json
native/target
native/*.node
test/assets/*/*
test/assets/Oswald
test/assets/Raleway
scr[ia]bble.*
/*.png
/*.jpg
Expand Down
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

26 changes: 12 additions & 14 deletions native/Cargo.lock → Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "skia-canvas"
version = "0.9.21"
description = "A canvas environment for Node"
authors = ["Christian Swinehart <[email protected]>"]
license = "MIT"
edition = "2018"
exclude = ["index.node"]

[lib]
crate-type = ["cdylib"]

[dependencies]
css-color = "0.1.1"
lazy_static = "1.4.0"

[dependencies.neon]
version = "0.8"
default-features = false
features = ["napi-6"]

[dependencies.skia-safe]
version = "0.39.1"
features = ["textlayout"]
Loading

0 comments on commit 8408313

Please sign in to comment.