-
-
Notifications
You must be signed in to change notification settings - Fork 814
/
build_against_node.sh
executable file
·74 lines (66 loc) · 2.32 KB
/
build_against_node.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
set -u -e
function publish() {
if test "${COMMIT_MESSAGE#*'[publish binary]'}" != "$COMMIT_MESSAGE"; then
node-pre-gyp publish
node-pre-gyp info
node-pre-gyp clean
make clean
# now install from binary
INSTALL_RESULT=$(npm install --fallback-to-build=false > /dev/null)$? || true
# if install returned non zero (errored) then we first unpublish and then call false so travis will bail at this line
if [[ $INSTALL_RESULT != 0 ]]; then echo "returned $INSTALL_RESULT";node-pre-gyp unpublish;false; fi
# If success then we arrive here so lets clean up
node-pre-gyp clean
fi
}
if [[ ! -d ../.nvm ]]; then
git clone https://github.com/creationix/nvm.git ../.nvm
fi
set +u
source ../.nvm/nvm.sh
nvm install $NODE_VERSION
nvm use $NODE_VERSION
set -u
node --version
npm --version
# work around old npm problem with ^
npm install npm -g
npm --version
# test installing from source
npm install --build-from-source
node-pre-gyp package testpackage
npm test
publish
# now test building against shared sqlite
if [[ $(uname -s) == 'Darwin' ]]; then
brew install sqlite
npm install --build-from-source --sqlite=$(brew --prefix)
else
sudo apt-get -qq update
sudo apt-get -qq install libsqlite3-dev
npm install --build-from-source --sqlite=/usr
fi
npm test
platform=$(uname -s | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/")
if [[ $(uname -s) == 'Linux' ]]; then
sudo apt-get -y install gcc-multilib g++-multilib
# node v0.8 and above provide pre-built 32 bit and 64 bit binaries
# so here we use the 32 bit ones to also test 32 bit builds
NVER=`node -v`
wget http://nodejs.org/dist/${NVER}/node-${NVER}-${platform}-x86.tar.gz
tar xf node-${NVER}-${platform}-x86.tar.gz
# enable 32 bit node
export PATH=$(pwd)/node-${NVER}-${platform}-x86/bin:$PATH
# install 32 bit compiler toolchain and X11
# test source compile in 32 bit mode with internal libsqlite3
CC=gcc-4.6 CXX=g++-4.6 npm install --build-from-source
node-pre-gyp package testpackage
npm test
publish
make clean
# test source compile in 32 bit mode against external libsqlite3
sudo apt-get -y install libsqlite3-dev:i386
CC=gcc-4.6 CXX=g++-4.6 npm install --build-from-source --sqlite=/usr
npm test
fi