Skip to content

Commit 6de94b7

Browse files
authored
Merge pull request #88 from lgeiger/preinstall
Use prebuild preinstall script for building libzmq
2 parents a4e9574 + 348c5b5 commit 6de94b7

File tree

7 files changed

+37
-21
lines changed

7 files changed

+37
-21
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ deploy:
4646
skip_cleanup: true
4747
# Linking to prebuild directly since it doesn't work inside a npm script.
4848
script:
49-
- node_modules/prebuild/bin.js --all -u $GH_TOKEN
49+
- node_modules/prebuild/bin.js --all --strip -u $GH_TOKEN
5050
on:
5151
condition: "$DEPLOY = true"
5252
tags: true

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test_script:
2525
- IF DEFINED ELECTRON (appveyor-retry call npm run test:electron) ELSE (appveyor-retry call npm test)
2626

2727
deploy_script:
28-
- IF "%deploy%;%appveyor_repo_tag%"=="true;true" (node_modules\.bin\prebuild --all -u %GITHUB_TOKEN%)
28+
- IF "%deploy%;%appveyor_repo_tag%"=="true;true" (node_modules\.bin\prebuild --all --strip -u %GITHUB_TOKEN%)
2929

3030
notifications:
3131
- provider: Slack

binding.gyp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
'cflags_cc!': ['-fno-exceptions'],
99
'conditions': [
1010
['OS=="win"', {
11-
'download_lib': '<!(node scripts/download-win-lib 2>&1 > zmq-build.log)',
1211
'msbuild_toolset': 'v140',
1312
'defines': ['ZMQ_STATIC'],
1413
'include_dirs': ['windows/include'],
@@ -18,7 +17,6 @@
1817
],
1918
}],
2019
['OS=="mac" or OS=="solaris"', {
21-
'install_zmq': '<!(./build_libzmq.sh 2>&1 > zmq-build.log)',
2220
'xcode_settings': {
2321
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
2422
'MACOSX_DEPLOYMENT_TARGET': '10.7',
@@ -29,7 +27,6 @@
2927
['OS=="openbsd" or OS=="freebsd"', {
3028
}],
3129
['OS=="linux"', {
32-
'install_zmq': '<!(./build_libzmq.sh 2>&1 > zmq-build.log)',
3330
'libraries': [ '<(PRODUCT_DIR)/../../zmq/lib/libzmq.a' ],
3431
'include_dirs': [ '<(PRODUCT_DIR)/../../zmq/include' ],
3532
}],

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
"node": ">=0.10"
2525
},
2626
"scripts": {
27-
"install": "prebuild --install",
27+
"build:libzmq": "node scripts/preinstall.js",
28+
"install": "prebuild --install --preinstall \"npm run build:libzmq\"",
29+
"rebuild": "prebuild --compile",
30+
"prebuild": "prebuild --all --strip",
2831
"build:docs": "jsdoc -R README.md -d docs lib/*.js",
2932
"test": "mocha --expose-gc --slow 300",
3033
"test:electron": "electron-mocha --slow 300",

build_libzmq.sh renamed to scripts/build_libzmq.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ ZMQ_REPO=zeromq/zeromq4-1
99
realpath() {
1010
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
1111
}
12-
export ZMQ_PREFIX="$(dirname $(realpath $0))/zmq"
12+
export MAIN_DIR="$(dirname $(realpath $0))/../"
13+
export ZMQ_PREFIX=$MAIN_DIR/zmq
1314
export ZMQ_SRC_DIR=zeromq-$ZMQ
1415
cd $ZMQ_PREFIX
1516

1617
export CFLAGS=-fPIC
1718
export CXXFLAGS=-fPIC
1819
export PKG_CONFIG_PATH=$ZMQ_PREFIX/lib/pkgconfig
1920

20-
test -f zeromq-$ZMQ.tar.gz || ZMQ=$ZMQ ZMQ_REPO=$ZMQ_REPO node ../scripts/download-zmq.js 2>&1 > ../zmq-build.log
21+
test -f zeromq-$ZMQ.tar.gz || ZMQ=$ZMQ ZMQ_REPO=$ZMQ_REPO node $MAIN_DIR/scripts/download-zmq.js
2122
test -d $ZMQ_SRC_DIR || tar xzf zeromq-$ZMQ.tar.gz
2223
cd $ZMQ_SRC_DIR
2324

scripts/download-win-lib.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

scripts/preinstall.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var download = require('./download').download;
2+
var spawn = require('child_process').spawn;
3+
var path = require('path');
4+
var fs = require('fs');
5+
6+
if (process.platform === 'win32') {
7+
console.log('Downloading libzmq for Windows')
8+
9+
var TAR_URL = 'https://github.com/nteract/libzmq-win/releases/download/v1.0.0/libzmq-' + process.arch + '.lib';
10+
var DIR_NAME = path.join(__dirname, '..', 'windows', 'lib');
11+
var FILE_NAME = path.join(DIR_NAME, 'libzmq.lib');
12+
13+
if (!fs.existsSync(DIR_NAME)) {
14+
fs.mkdirSync(DIR_NAME);
15+
}
16+
17+
download(TAR_URL, FILE_NAME);
18+
} else {
19+
console.log('Building libzmq for ' + process.platform)
20+
21+
var child = spawn('./scripts/build_libzmq.sh');
22+
23+
child.stdout.pipe(process.stdout);
24+
child.stderr.pipe(process.stderr);
25+
child.on('error', (err) => {
26+
console.error('Failed to start child process.');
27+
});
28+
}

0 commit comments

Comments
 (0)