Skip to content

Commit 8c36e99

Browse files
authored
chore(binaries): Lets switch to prebuild! (#1282)
- Build once on each platform (win32, win64, linux32, linux64, osx) - upload to github - Binaries for windows are megabytes smaller! - Now 60 binaries per release!?!?!?!? - Builds are much easier to manage - Removes the bundled node-pre-gyp which was big `npm i --production` went from 11mb to 4.9Mb. `prebuild-install` is still larger than all our binaries but smaller than `node-pre-gyp` none the less. BREAKING CHANGE: I'm considering this a breaking change because it's substantially changes our install processes. It's also possible the install flags to ensure downloading or building from source has changed slightly. That's not our api per say, but it's enough.
1 parent 5b8d163 commit 8c36e99

File tree

6 files changed

+67
-148
lines changed

6 files changed

+67
-148
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# MAKE SURE ALL ADDITIONS HERE ARE MIRRORED INTO THE .npmignore AS WELL
2+
.mailmap
23
build/
4+
coverage
35
node_modules
46
npm-debug.log
5-
coverage
6-
.mailmap
77
package-lock.json
8+
Release/
9+
prebuilds/

.npmignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ changelog.md
2020
.DS_Store
2121

2222
# MIRRORED FROM .gitignore PLEASE MAINTAIN
23+
.mailmap
2324
build/
25+
coverage
2426
node_modules
2527
npm-debug.log
26-
coverage
27-
.mailmap
2828
package-lock.json
29+
Release/

.travis.yml

Lines changed: 33 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,139 +10,96 @@ addons:
1010
- g++-4.8
1111
- g++-4.8-multilib
1212
- gcc-multilib
13-
- libgtk2.0-0
14-
- libxtst6
15-
- libnotify4
16-
- libgconf2-4
17-
- libgtk2.0-0:i386
18-
- libxtst6:i386
19-
- libnotify4:i386
20-
- libgconf2-4:i386
21-
- libnss3:i386
22-
- libasound2:i386
23-
- libxss1:i386
24-
- socat
2513

2614
# Build matrix
2715
os:
2816
- linux
2917
- osx
3018
env:
3119
global:
32-
- secure: "qEdwCY/ilHkqWkqasN5MgWCnzzop4lEYkbpxEiVMTZBY12p4uV6ysPQ+ZLZcx10Cg90RIQlsPeEANIhCzkWfnQi+ySmeiKY9JR2eSnb69wM7dBQ/uxv04eVChAlZSsDHwmTIIzIzZFsrWrcwwJaENGCJYKqZ9LKOiGFGQ8Is09A="
20+
- secure: "L+AGMJc5NAsuym+xzB4FWj0c2rCobosixkoxLBhDBVkLiYsMtfS9y1w8Xz0pbWKJnJAH9tfwHluu5aX2qYk2HbreSyNzy8hbPW+9RbSyAQexeiZG4mLuDEz0xvlpCCQBsS1OfMypQk0/JvL4oA9B/xasrpkeVuPI7dwAz2WcFms="
3321
matrix:
3422
- TRAVIS_NODE_VERSION="4"
3523
- TRAVIS_NODE_VERSION="4" ARCH="x86"
3624
- TRAVIS_NODE_VERSION="6"
3725
- TRAVIS_NODE_VERSION="6" ARCH="x86"
38-
- TRAVIS_NODE_VERSION="8"
39-
- TRAVIS_NODE_VERSION="8" ARCH="x86"
40-
- TRAVIS_ELECTRON_VERSION="1.4.12" TRAVIS_NODE_VERSION="6"
41-
- TRAVIS_ELECTRON_VERSION="1.4.12" ARCH="x86" TRAVIS_NODE_VERSION="6"
26+
- BINARY_BUILDER="true" TRAVIS_NODE_VERSION="8"
27+
- BINARY_BUILDER="true" TRAVIS_NODE_VERSION="8" ARCH="x86"
4228
matrix:
4329
exclude:
4430
- os: osx
4531
env: TRAVIS_NODE_VERSION="4" ARCH="x86"
4632
- os: osx
4733
env: TRAVIS_NODE_VERSION="6" ARCH="x86"
4834
- os: osx
49-
env: TRAVIS_NODE_VERSION="8" ARCH="x86"
50-
- os: osx
51-
env: TRAVIS_ELECTRON_VERSION="1.4.12" ARCH="x86" TRAVIS_NODE_VERSION="6"
52-
- os: linux
53-
env: TRAVIS_ELECTRON_VERSION="1.4.12" ARCH="x86" TRAVIS_NODE_VERSION="6"
35+
env: BINARY_BUILDER="true" TRAVIS_NODE_VERSION="8" ARCH="x86"
5436

5537
before_install:
56-
# reinstall latest nvm
57-
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh
58-
- nvm install $TRAVIS_NODE_VERSION
59-
- PATH=$PATH:`pwd`/node_modules/.bin
6038

61-
- BASE_URL=$(node -p "'https://nodejs.org/dist/' + process.version")
62-
- X86_FILE=$(node -p "'node-' + process.version + '-' + process.platform + '-x86'")
6339
# download node if testing x86 architecture
64-
- if [[ "$ARCH" == "x86" ]]; then wget $BASE_URL/$X86_FILE.tar.gz; tar -xf $X86_FILE.tar.gz; export PATH=$X86_FILE/bin:$PATH; fi
40+
- >
41+
if [[ "$ARCH" == "x86" ]]; then
42+
BASE_URL=$(node -p "'https://nodejs.org/dist/' + process.version");
43+
X86_FILE=$(node -p "'node-' + process.version + '-' + process.platform + '-x86'");
44+
wget $BASE_URL/$X86_FILE.tar.gz;
45+
tar -xf $X86_FILE.tar.gz;
46+
nvm deactivate;
47+
export PATH=$X86_FILE/bin:$PATH;
48+
else
49+
nvm install $TRAVIS_NODE_VERSION
50+
fi;
51+
52+
# use g++-4.8 on Linux
53+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi
54+
- $CXX --version
6555

66-
# upgrade npm if on node 4 as it doesn't like our dev peer deps
56+
# upgrade npm if on node 4 as npm2 doesn't like our dev peer deps
6757
- if [[ $TRAVIS_NODE_VERSION == "4" ]]; then npm install -g npm; fi
6858

59+
# Cleanup the output of npm
60+
- npm config set progress false
61+
- npm config set spin false
62+
6963
# print versions
7064
- uname -a
71-
- file `which node`
65+
- which node; file `which node`
7266
- node --version
7367
- node -p 'process.platform + "@" + process.arch'
7468
- npm --version
7569

76-
# use g++-4.8 on Linux
77-
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi
78-
- $CXX --version
79-
8070
# figure out if we should publish
8171
- PUBLISH_BINARY=false
82-
# if we are building a tag then publish
8372
- echo $TRAVIS_BRANCH
8473
- echo `git describe --tags --always HEAD`
85-
- if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then PUBLISH_BINARY=true; fi;
74+
- if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then PUBLISH_BINARY=$BINARY_BUILDER; fi;
8675
- echo "Publishing native platform Binary Package? ->" $PUBLISH_BINARY
8776

88-
# Cleanup the output of npm
89-
- npm config set progress false
90-
- npm config set spin false
91-
9277
# setup virtual serialports
9378
# - >
9479
# socat -d -d -unlink-close pty,raw,nonblock,echo=0,link=ttyV0 pty,raw,nonblock,echo=0,link=ttyV1 &
9580
# ./bin/echo.js --port ttyV0 &
9681
# export TEST_PORT=ttyV1
9782

98-
- >
99-
if [[ ! -z $TRAVIS_ELECTRON_VERSION ]]; then
100-
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
101-
export DISPLAY=:99.0
102-
sh -e /etc/init.d/xvfb start
103-
fi
104-
105-
export npm_config_target=$TRAVIS_ELECTRON_VERSION
106-
export npm_config_arch=$ARCH
107-
export npm_config_disturl=https://atom.io/download/atom-shell
108-
export npm_config_runtime=electron
109-
110-
npm install --arch=$ARCH electron@$TRAVIS_ELECTRON_VERSION
111-
npm install electron-mocha
112-
113-
echo "installed Electron $TRAVIS_ELECTRON_VERSION"
114-
fi
115-
11683
install:
11784
# ensure source install works
11885
- npm install --build-from-source
11986

120-
12187
script:
12288
# linting no longer works on node 4
12389
- >
12490
if [[ $TRAVIS_NODE_VERSION != "4" ]]; then
12591
npm run lint
126-
fi
92+
fi;
12793
12894
- npm run docs:diff
129-
- >
130-
if [[ -z $TRAVIS_ELECTRON_VERSION ]]; then
131-
node ./
132-
npm test
133-
else
134-
electron test/electron
135-
fi
95+
- node ./
96+
- npm test
13697

13798
# if publishing, do it
138-
- if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package; fi;
139-
- if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp-github publish --release; fi;
140-
141-
# cleanup
142-
- node-pre-gyp clean
143-
144-
# test binary exists
145-
- if [[ $PUBLISH_BINARY == true ]]; then npm install --fallback-to-build=false; fi;
99+
- >
100+
if [[ $PUBLISH_BINARY == true ]]; then
101+
npm run prebuild-upload;
102+
fi;
146103
147104
after_success:
148105
- bash <(curl -s https://codecov.io/bash)

PUBLISHING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This can be checked in the .travis.yml file and appveyor.yml file. Within these
1313
2. Fill out `changelog.md`
1414
3. Bump up npm version in `package.json`
1515
4. Update the `.docs/README.hbs` to reference this current version and to previous major version docs then regenerate docs `npm run docs`.
16-
5. Commit then generate new tags based on package.json version number with `git tag 5.0.0 -a` and include the change log in the tag's annotation.
16+
5. Commit then generate new tags based on package.json version number with `git tag v5.0.0 -a` and include the change log in the tag's annotation.
1717
6. Push tags to Github with `git push --tags`
1818
7. `rm -rf package-lock.json node_modules build && npm install`
1919
8. Publish to npm after builds finish. Builds can take half an hour and occasionally fail for seemingly no reason. Restart any failures in the travis or appeveyor ui. While you wait, remove the content of the Github release message so the tag's text shows. When the entire matrix succeeds and all binaries exist run `npm publish`.

appveyor.yml

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
os: unstable
22
environment:
3-
NODE_PRE_GYP_GITHUB_TOKEN:
4-
secure: VM4yc2j2L3KS5qWLZLY7WUAXoqdB9YkodmXlHC2I+LSF0Y8a2cZ70M0+2+Fd5GkQ
3+
prebuild_upload:
4+
secure: a/seaM+nUnQWhWUnbyz8fl9vPwuyqDTrFviptDykYp2c46vdTvlAxU6yqD/PpDiI
55
COVERALLS_REPO_TOKEN:
66
secure: iDcAJCYgJK4tffyzEHbMVR8DatJcIN8eY0h29p9JQkl43TcEcm6Z6JLOBpGDk1MJ
77

88
matrix:
99
- nodejs_version: "4"
1010
- nodejs_version: "6"
11-
- nodejs_version: "8"
12-
- electron_version: "1.4.12"
13-
nodejs_version: "6"
11+
- binary_builder: "true"
12+
nodejs_version: "8"
1413

1514
platform:
1615
- x86
@@ -25,13 +24,13 @@ matrix:
2524

2625
install:
2726
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform;
28-
- ps: $env:Path += ";$(pwd)\node_modules\.bin";
29-
# work around bug in npm 2 where id doesn't like our dev dep peers
27+
# upgrade npm if on node 4 as npm2 doesn't like our dev peer deps
3028
- ps: >
3129
if ($env:nodejs_version -eq "4") {
3230
npm install -g npm | Write-Host;
3331
}
34-
true;
32+
npm config set progress false
33+
npm config set spin false
3534
3635
- ps: >
3736
@{
@@ -43,77 +42,42 @@ install:
4342
"APPVEYOR_REPO_COMMIT_MESSAGE" = $env:APPVEYOR_REPO_COMMIT_MESSAGE
4443
"git latest tag" = "$(git describe --tags --always HEAD)"
4544
"appveyor_repo_tag" = $env:appveyor_repo_tag
46-
"electron_version" = $env:electron_version
4745
} | Out-String | Write-Host;
4846
4947
# Check if we're building the latest tag, if so
5048
# then we publish the binaries if tests pass.
5149
- ps: >
5250
if ($env:appveyor_repo_tag -match "true" -and ("$(git describe --tags --always HEAD)" -eq $env:appveyor_repo_tag_name)) {
53-
$env:publish_binary = 1;
54-
} else {
55-
$env:publish_binary = 0;
51+
$env:publish_binary = $env:binary_builder;
5652
}
57-
true;
58-
59-
- ps: >
60-
if ($env:publish_binary -eq 1) {
53+
if ($env:publish_binary -eq "true") {
6154
"We're publishing a binary!" | Write-Host
6255
} else {
6356
"We're not publishing a binary" | Write-Host
6457
}
6558
true;
6659
67-
# Cleanup the output of npm
68-
- ps: >
69-
npm config set progress false
70-
npm config set spin false
71-
7260
# We don't currently have a port to test on windows
7361
# - ps: $env:TEST_PORT = "COM1";
7462

75-
# Setup Electron variables
76-
- ps: >
77-
if ($env:electron_version) {
78-
"We're an electron build, setup variables" | Write-Host
79-
$env:npm_config_target = $env:electron_version
80-
$env:npm_config_disturl = "https://atom.io/download/atom-shell"
81-
$env:npm_config_runtime = "electron"
82-
83-
if ($env:plaftorm -eq "x86") {
84-
$env:npm_config_arch = "ia32"
85-
} else {
86-
$env:npm_config_arch = "x64"
87-
}
88-
89-
"Install electron and electron-mocha" | Write-Host
90-
91-
npm install -g electron@$env:electron_version
92-
npm install electron-mocha
93-
}
94-
true;
95-
9663
build_script:
97-
- npm install --build-from-source --msvs_version=2013
64+
- npm install --build-from-source
9865

9966
test_script:
10067
- ps: >
10168
if ($env:nodejs_version -ne "4") {
10269
npm run lint
10370
}
104-
true;
105-
106-
# If we run npm test in powershell it'll have the wrong encoding
107-
# so we have to do it like this
71+
node ./
10872
109-
- IF DEFINED electron_version (electron test/electron)
110-
- IF NOT DEFINED electron_version (node ./)
111-
- IF NOT DEFINED electron_version (npm test)
73+
# If we run npm test in powershell it'll have the wrong encoding so we have to do it like this
74+
- npm test
11275

113-
- IF %PUBLISH_BINARY% == 1 (node-pre-gyp package 2>&1)
114-
- IF %PUBLISH_BINARY% == 1 (node-pre-gyp-github publish --release 2>&1)
115-
- IF %PUBLISH_BINARY% == 1 (node-pre-gyp clean)
116-
- IF %PUBLISH_BINARY% == 1 (npm install --fallback-to-build=false)
76+
- ps: >
77+
if ($env:publish_binary -eq "true") {
78+
npm run prebuild-upload
79+
}
80+
true;
11781
11882
after_test:
11983
- pip install codecov && codecov --file coverage\coverage.json

package.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
{
22
"name": "serialport",
3-
"version": "5.0.0",
3+
"version": "5.1.0-beta5",
44
"description": "Node.js package to access serial ports. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!",
55
"author": {
66
"name": "Chris Williams",
77
"email": "voodootikigod@gmail.com",
88
"url": "http://www.voodootikigod.com"
99
},
10-
"binary": {
11-
"module_name": "serialport",
12-
"module_path": "build/{configuration}/",
13-
"host": "https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/5.0.0"
14-
},
1510
"main": "lib",
1611
"repository": {
1712
"type": "git",
@@ -67,7 +62,7 @@
6762
"commander": "^2.11.0",
6863
"debug": "^2.6.6",
6964
"nan": "^2.6.2",
70-
"node-pre-gyp": "^0.6.36",
65+
"prebuild-install": "^2.2.1",
7166
"promirepl": "^1.0.1",
7267
"safe-buffer": "^5.0.1"
7368
},
@@ -84,13 +79,10 @@
8479
"istanbul": "^0.4.4",
8580
"jsdoc-to-markdown": "^3.0.0",
8681
"mocha": "^3.4.2",
87-
"node-pre-gyp-github": "^1.1.2",
82+
"prebuild": "^6.2.1",
8883
"proxyquire": "^1.7.10",
8984
"sinon": "^2.3.8"
9085
},
91-
"bundledDependencies": [
92-
"node-pre-gyp"
93-
],
9486
"engines": {
9587
"node": ">=4.0.0"
9688
},
@@ -104,15 +96,18 @@
10496
"arduino-test": "TEST_PORT=$(./bin/find-arduino.js) npm test",
10597
"docs": "jsdoc2md --no-cache -t .docs/README.hbs --partial .docs/sig-name.hbs --partial .docs/sig-link.hbs --partial .docs/edit-warning.hbs -r table --separators --name-format -f lib/* lib/bindings/* lib/parsers/* > README.md",
10698
"docs:diff": "jsdoc2md --no-cache -t .docs/README.hbs --partial .docs/sig-name.hbs --partial .docs/sig-link.hbs --partial .docs/edit-warning.hbs -r table --separators --name-format -f lib/* lib/bindings/* lib/parsers/* | diff README.md - || (echo 'Docs out of date, run `npm run docs` and commit the new README.md' && false)",
107-
"install": "node-pre-gyp install --fallback-to-build",
10899
"lint": "eslint lib test bin examples",
109100
"rebuild-all": "npm rebuild && node-gyp rebuild",
110101
"repl": "node bin/repl.js",
111102
"stress": "mocha --no-timeouts test/arduinoTest/stress.js",
112103
"test": "istanbul cover ./node_modules/mocha/bin/_mocha",
113104
"test:watch": "mocha -w",
114105
"valgrind": "TEST_PORT=$(./bin/find-arduino.js) valgrind --leak-check=full node test/manual-testing/memory-binding.js",
115-
"debugger": "TEST_PORT=$(./bin/find-arduino.js) node --inspect --debug-brk test/manual-testing/performance.js"
106+
"debugger": "TEST_PORT=$(./bin/find-arduino.js) node --inspect --debug-brk test/manual-testing/performance.js",
107+
"install": "prebuild-install || node-gyp rebuild",
108+
"rebuild": "prebuild --compile",
109+
"prebuild": "prebuild --all --strip --verbose",
110+
"prebuild-upload": "prebuild --all --strip --verbose"
116111
},
117112
"gypfile": true
118113
}

0 commit comments

Comments
 (0)