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: use N-API 6 builds #1556

Merged
merged 7 commits into from
Feb 7, 2023
Merged
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 .changes/switch-to-napi-6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

---
"nodejs-binding": patch
---

Move to N-API 6 builds.
66 changes: 4 additions & 62 deletions .github/workflows/covector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,7 @@ jobs:
# The GitHub hosted Windows 2022 image comes with Visual Studio 2022, but node-gyp
# (which is used by neon-sys) sadly fails to recognize it. As a mitigation, we still run the
# tests on Windows 2019, until we can figure out a way to fix the problem.
# NOTE: Using Ubuntu 18.04 to provide glibc compatibility. (#588)
os: [ubuntu-18.04, ubuntu-latest, macos-latest, windows-2019]
node-version: ['14.x', '16.x', '18.x']
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
exclude:
# GLIBC_2.28 is only available with a newer ubuntu version
- os: ubuntu-18.04
node-version: '18.x'
# ubuntu-18.04 is needed for for node 14.x and 16.x
- os: ubuntu-latest
node-version: '14.x'
- os: ubuntu-latest
node-version: '16.x'
os: [ubuntu-latest, macos-latest, windows-2019]

steps:
- name: Checkout the Source Code
Expand All @@ -113,10 +102,10 @@ jobs:
toolchain: stable
cache: false

- name: Set up Node.js ${{ matrix.node-version }}
- name: Set up Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
node-version: '16.x'

- name: Install required packages (Ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
Expand All @@ -130,54 +119,7 @@ jobs:

- name: Build Node.js Prebuilds
working-directory: client/bindings/nodejs/
run: yarn prebuild:node

- name: Upload Prebuilds to GitHub Release
working-directory: client/bindings/nodejs/
run: yarn prebuild --upload-all ${{ secrets.GITHUB_TOKEN }} --tag-prefix nodejs-binding-v

electron-binding-prebuild:
name: Build Prebuilt Binaries for Electron
if: needs.version-or-publish.outputs.successfulPublish == 'true'
needs: version-or-publish
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# The GitHub hosted Windows 2022 image comes with Visual Studio 2022, but node-gyp
# (which is used by neon-sys) sadly fails to recognize it. As a mitigation, we still run the
# tests on Windows 2019, until we can figure out a way to fix the problem.
# NOTE: Using Ubuntu 18.04 to provide glibc compatibility. (#588)
os: [ubuntu-18.04, macos-latest, windows-2019]

steps:
- name: Checkout the Source Code
uses: actions/checkout@v3

- name: Set Up Stable Rust
uses: ./.github/actions/setup-rust
with:
toolchain: stable
cache: false

- name: Set up Node.js 14
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install required packages (Ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
sudo apt-get install libudev-dev libusb-1.0-0-dev

- name: Run Yarn Install
working-directory: client/bindings/nodejs/
run: yarn install

- name: Build Electron Prebuilds
working-directory: client/bindings/nodejs/
run: yarn prebuild:electron
run: yarn prebuild

- name: Upload Prebuilds to GitHub Release
working-directory: client/bindings/nodejs/
Expand Down
8 changes: 6 additions & 2 deletions client/bindings/nodejs/binding.gyp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"targets": [
{
"target_name": "index"
"target_name": "index",
'defines': [
"NAPI_VERSION=<(napi_build_version)",
],
"win_delay_load_hook": "true",
}
]
}
}
12 changes: 8 additions & 4 deletions client/bindings/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
"lint": "eslint --ignore-path .eslintignore --ext .js,.ts .",
"format": "prettier --ignore-path .eslintignore -w {,*/**/}*.{ts,js,json}",
"format-check": "prettier --ignore-path .eslintignore -c {,*/**/}*.{ts,js,json}",
"install": "prebuild-install --tag-prefix nodejs-binding-v || npm run rebuild",
"install": "prebuild-install --runtime napi --tag-prefix nodejs-binding-v || npm run rebuild",
"build": "npm run build:neon && tsc",
"build:neon": "cargo-cp-artifact -nc ./index.node -- cargo build --release --message-format=json-render-diagnostics",
"rebuild": "npm run build:neon && tsc && node scripts/node-neon-build.js --strip && node scripts/strip.js",
"prebuild:node": "prebuild --prepack scripts/node-neon-build.js --strip",
"prebuild:electron": "node scripts/electron-prebuild.js",
"rebuild": "npm run build:neon && tsc && node scripts/neon-build.js --strip && node scripts/strip.js",
"prebuild": "prebuild --runtime napi --target 6 --prepack scripts/neon-build.js --strip",
"docs-wiki-build": "typedoc --githubPages false --disableSources --excludePrivate --excludeInternal --excludeNotDocumented --plugin typedoc-plugin-markdown --theme markdown --hideBreadcrumbs --entryDocument api_ref.md --readme none --hideGenerator --sort source-order --exclude ./**/src/index.ts --out ../../../documentation/docs/libraries/nodejs/references/ ./lib/index.ts",
"test": "jest --forceExit"
},
Expand Down Expand Up @@ -55,5 +54,10 @@
"tar": "^4.4.19",
"simple-get": "^2.8.2",
"json5": "^2.2.2"
},
"binary": {
"napi_versions": [
6
]
}
}
11 changes: 0 additions & 11 deletions client/bindings/nodejs/scripts/electron-neon-build.js

This file was deleted.

23 changes: 0 additions & 23 deletions client/bindings/nodejs/scripts/electron-prebuild.js

This file was deleted.