Skip to content

Commit

Permalink
feat: use N-API 6 builds (#1556)
Browse files Browse the repository at this point in the history
* feat: specify NAPI version in binding.gyp

* feat: adjust nodejs scripts

* feat: update covector to use updated prebuild script

* chore: newline

* chore: add .md to changes folder

* feat: remove node-version from matrix

* fix: remove ubuntu-18.04 & set nodejs to 16.x
  • Loading branch information
Tuditi authored Feb 7, 2023
1 parent f029dac commit b41ddd7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 102 deletions.
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']
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 @@ -137,54 +126,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.

0 comments on commit b41ddd7

Please sign in to comment.