Skip to content

Commit

Permalink
feat: Introduce prebuildify (#2368)
Browse files Browse the repository at this point in the history
* prebuildify
* Prebuildify cross

This is a breaking change but will be included in the 10x major release currently in beta.
  • Loading branch information
thegecko authored Dec 27, 2021
1 parent 64365c5 commit d50673f
Show file tree
Hide file tree
Showing 10 changed files with 7,739 additions and 43 deletions.
75 changes: 60 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,67 @@ on:
- '@serialport/bindings@*'
- 'v*'
- 'force-build'

jobs:
test:
runs-on: ${{ matrix.config.os }}
prebuild:
strategy:
matrix:
config:
# arch isn't used and we have no way to use it currently
- { os: macos-latest, arch: x64 }
- { os: ubuntu-latest, arch: x64 }
- { os: windows-latest, arch: x64 }
include:
- name: darwin
os: macos-11
node: x64
command: prebuild
args: --arch x64+arm64
- name: win32-x86
os: windows-latest
node: x86
command: prebuild
- name: win32-x64
os: windows-latest
node: x64
command: prebuild
- name: linux-x64
os: ubuntu-latest
command: prebuild-cross
args: -i centos7-devtoolset7 -i alpine
- name: linux-arm
os: ubuntu-latest
command: prebuild-cross
args: -i linux-arm64 -i linux-armv7 -i linux-armv6
- name: android-arm
os: ubuntu-latest
command: prebuild-cross
args: -i android-arm64 -i android-armv7
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
- run: npm ci
- run: npm run prebuild
env:
prebuild_upload: ${{ secrets.GITHUB_TOKEN }}
- if: matrix.node
uses: actions/setup-node@v2
with:
node-version: 14.x
architecture: ${{ matrix.node }}
- uses: actions/checkout@v2
- run: npm ci
- run: npm run ${{ matrix.command }} -- -- -- ${{ matrix.args }}
- run: tar -zcvf ${{ matrix.name }}.tar.gz -C packages/bindings/prebuilds .
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}.tar.gz
retention-days: 1
release:
needs: prebuild
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/@serialport/bindings@')
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: artifacts
- uses: docker://antonyurchenko/git-release:v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHANGELOG_FILE: none
with:
args: artifacts/*/*.tar.gz
14 changes: 0 additions & 14 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"outdated": "lerna exec --no-bail npm outdated && npm outdated",
"postinstall": "lerna bootstrap --no-ci",
"prebuild": "lerna run --stream prebuild",
"prebuild-cross": "lerna run --stream prebuild-cross",
"publish": "lerna publish --exact",
"test": "nyc --reporter=html --reporter=text --reporter lcovonly mocha",
"test:arduino": "TEST_PORT=$(./bin/find-arduino.js) npm test",
Expand All @@ -40,8 +41,6 @@
"lerna-changelog": "^2.2.0",
"lerna": "^4.0.0",
"mocha": "^9.1.3",
"node-abi": "3.5.0",
"node-addon-api": "^4.2.0",
"nyc": "^15.1.0",
"plop": "^2.7.6",
"prebuild": "^11.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/bindings/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
'src/serialport.cpp'
],
'include_dirs': ["<!(node -p \"require('node-addon-api').include_dir\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
"defines": ["NAPI_CPP_EXCEPTIONS"],
Expand Down
3 changes: 2 additions & 1 deletion packages/bindings/lib/darwin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { promisify } = require('util')
const binding = require('bindings')('bindings.node')
const { join } = require('path')
const binding = require('node-gyp-build')(join(__dirname, '../'))
const AbstractBinding = require('@serialport/binding-abstract')
const Poller = require('./poller')
const unixRead = require('./unix-read')
Expand Down
3 changes: 2 additions & 1 deletion packages/bindings/lib/linux.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { promisify } = require('util')
const binding = require('bindings')('bindings.node')
const { join } = require('path')
const binding = require('node-gyp-build')(join(__dirname, '../'))
const AbstractBinding = require('@serialport/binding-abstract')
const linuxList = require('./linux-list')
const Poller = require('./poller')
Expand Down
3 changes: 2 additions & 1 deletion packages/bindings/lib/poller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const debug = require('debug')
const logger = debug('serialport/bindings/poller')
const EventEmitter = require('events')
const PollerBindings = require('bindings')('bindings.node').Poller
const { join } = require('path')
const PollerBindings = require('node-gyp-build')(join(__dirname, '../')).Poller

const EVENTS = {
UV_READABLE: 0b0001,
Expand Down
3 changes: 2 additions & 1 deletion packages/bindings/lib/win32.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const binding = require('bindings')('bindings.node')
const { join } = require('path')
const binding = require('node-gyp-build')(join(__dirname, '../'))
const AbstractBinding = require('@serialport/binding-abstract')
const { promisify } = require('util')
const serialNumParser = require('./win32-sn-parser')
Expand Down
Loading

0 comments on commit d50673f

Please sign in to comment.