Skip to content

Support for binary deployment #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*.lo
*.Makefile
*.target.gyp.mk
stage
lib/binding
build
out
Release
Expand Down
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
language: node_js

node_js:
- "0.10"
- "0.8"
- "0.6"
before_script: "npm install mocha"
- "0.10"
- "0.8"
- "0.6"

install:
- npm install
- npm install mocha
- npm test

before_script: "make clean"

script:
- npm install --stage
- npm test
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
build:
node-gyp build
npm install --build-from-source

clean:
rm -f test/support/big.db*
rm -f test/tmp/*
rm -f ./lib/node_sqlite3.node
rm -rf ./lib/binding/
#rm -f ./test/support/big.db*
rm -f ./test/tmp/*
rm -rf ./deps/sqlite-autoconf-*/
rm -rf ./build
rm -rf ./out
Expand Down
28 changes: 0 additions & 28 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
'variables': {
'sqlite%':'internal',
},
'conditions': [
['OS=="win"', {
'variables': {
'copy_command%': 'copy',
},
},{
'variables': {
'copy_command%': 'cp',
},
}]
],
'targets': [
{
'target_name': 'node_sqlite3',
Expand All @@ -37,23 +26,6 @@
'src/node_sqlite3.cc',
'src/statement.cc'
],
},
{
'target_name': 'action_after_build',
'type': 'none',
'dependencies': [ 'node_sqlite3' ],
'actions': [
{
'action_name': 'move_node_module',
'inputs': [
'<@(PRODUCT_DIR)/node_sqlite3.node'
],
'outputs': [
'lib/node_sqlite3.node'
],
'action': ['<@(copy_command)', '<@(PRODUCT_DIR)/node_sqlite3.node', 'lib/node_sqlite3.node']
}
]
}
]
}
34 changes: 34 additions & 0 deletions build-util/remake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

export UNAME=$(uname -s);

cd $ROOTDIR
cd ../

if [ ${UNAME} = 'Darwin' ]; then
# note: requires FAT (duel-arch) node installed via .pkg
npm install --stage --target_arch=ia32
npm install --stage --target_arch=ia32 --debug
npm install --stage --target_arch=x64
npm install --stage --target_arch=x64 --debug

elif [ ${UNAME} = 'Linux' ]; then
rm -rf ./bin/linux-*
apt-get -y update
apt-get -y install git make build-essential
git clone https://github.com/creationix/nvm.git ~/.nvm
source ~/.nvm/nvm.sh
nvm install 0.10
npm install -g node-gyp
node ./build.js --target_arch=x64
# now do 32 bit
NVER=`node -v`
wget http://nodejs.org/dist/${NVER}/node-${NVER}-linux-x86.tar.gz
tar xf node-${NVER}-linux-x86.tar.gz
export PATH=$(pwd)/node-${NVER}-linux-x86/bin:$PATH
# ignore:
# dependency problems - leaving unconfigure gcc-4.6:i386 g++-4.6:i386 libstdc++6-4.6-dev:i386
# E: Sub-process /usr/bin/dpkg returned an error code (1)
apt-get -y install binutils:i386 cpp:i386 gcc-4.6:i386 g++-4.6:i386 libstdc++6-4.6-dev:i386 | true
CC=gcc-4.6 CXX=g++-4.6 node ./build.js --target_arch=ia32
fi
102 changes: 102 additions & 0 deletions build-util/tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
var ProgressBar = require('progress');
var http = require('http');
var url = require('url');
var fs = require('fs');

function download(from,to,callback) {
var uri = url.parse(from);
var req = http.request(uri);
req.on('response', function(res){
// needed for end to be called
res.resume();
if (res.statusCode !== 200) {
return callback(new Error('Server returned '+ res.statusCode),false);
}
var len = parseInt(res.headers['content-length'], 10);
console.log();
var bar = new ProgressBar(' downloading [:bar] :percent :etas', {
complete: '='
, incomplete: ' '
, width: 40
, total: len
});
function returnBuffer() {
for (var length = 0, i = 0; i < out.length; i++) {
length += out[i].length;
}
var result = new Buffer(length);
for (var pos = 0, j = 0; j < out.length; j++) {
out[j].copy(result, pos);
pos += out[j].length;
}
fs.writeFile(to,result,function(err) {
if (err) return callback(err,true);
return callback(null,true);
});
}
var out = [];
res.on('data', function(chunk) {
bar.tick(chunk.length);
out.push(chunk);
found_remote = true;
});
res.on('end', function(){
console.log('\n');
returnBuffer();
});
res.on('close', function(){
returnBuffer();
});
});
req.on('error', function(err){
callback(err,false);
});
req.end();
}


function parse_args(_args, opts) {
// first split them like npm returns
var args = [];
_args.forEach(function(a) {
var parts = a.split('=');
parts.forEach(function(p) {
args.push(p);
})
})
// respect flags passed to npm install
if (process.env.npm_config_argv) {
var argv_obj = JSON.parse(process.env.npm_config_argv);
args = args.concat(argv_obj.cooked.slice(1))
}
var debug = (args.indexOf('--debug') > -1);
if (debug) opts.configuration = 'Debug';

opts.stage = (args.indexOf('--stage') > -1);
if (opts.stage) {
opts.force = true;
} else {
var from_source = args.indexOf('--build-from-source');
if ( from_source > -1) {
// no specific module name passed
var next_arg = args[from_source+1];
if (!next_arg || next_arg.indexOf('--') <= 0) {
opts.force = true;
} else if (next_arg == 'sqlite3'){
opts.force = true;
}
}
}
var target_arch = args.indexOf('--target_arch');
if (target_arch > -1) {
var next_arg = args[target_arch+1];
if (next_arg && next_arg.indexOf('--') < 0) {
opts.target_arch = next_arg;
}
}
opts.args = args;
return opts;
}

module.exports.parse_args = parse_args;
module.exports.download = download;
18 changes: 18 additions & 0 deletions build-util/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

export DRY_RUN="--dry-run"

cd ${ROOTDIR}/../stage/
if [ -d Debug ]; then
cd Debug
../../../s3cmd/s3cmd sync --no-check-md5 --acl-public ./*.tar.gz s3://node-sqlite3/Debug/ ${DRY_RUN}
cd ../
fi

if [ -d Release ]; then
cd Release
../../../s3cmd/s3cmd sync --no-check-md5 --acl-public ./*.tar.gz s3://node-sqlite3/Release/ ${DRY_RUN}
cd ../
fi

#../../s3cmd/s3cmd ls s3://node-sqlite3/
Loading