Skip to content

Commit

Permalink
Reworking build scripts, added package and install.js
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Mar 8, 2012
1 parent 8acee56 commit 237eab3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 64 deletions.
54 changes: 7 additions & 47 deletions Makefile
@@ -1,67 +1,27 @@
NODE = node
NPM = npm
NODEUNIT = node_modules/nodeunit/bin/nodeunit
DOX = node_modules/dox/bin/dox
name = all

total: build_native

build_native:
$(MAKE) -C ./external-libs/bson all
$(MAKE) -C ./ext all

build_native_debug:
$(MAKE) -C ./external-libs/bson all_debug
$(MAKE) -C ./ext all_debug

build_native_clang:
$(MAKE) -C ./external-libs/bson clang
$(MAKE) -C ./ext clang

build_native_clang_debug:
$(MAKE) -C ./external-libs/bson clang_debug
$(MAKE) -C ./ext clang_debug

clean_native:
$(MAKE) -C ./external-libs/bson clean

test: build_native
@echo "\n == Run All tests minus replicaset tests=="
$(NODE) dev/tools/test_all.js --noreplicaset --boot

test_junit: build_native
@echo "\n == Run All tests minus replicaset tests=="
$(NODE) dev/tools/test_all.js --junit --noreplicaset

test_nodeunit_pure:
@echo "\n == Execute Test Suite using Pure JS BSON Parser == "
@$(NODEUNIT) test/ test/gridstore test/bson

test_js:
@$(NODEUNIT) $(TESTS)

test_nodeunit_replicaset_pure:
@echo "\n == Execute Test Suite using Pure JS BSON Parser == "
@$(NODEUNIT) test/replicaset

test_nodeunit_native:
@echo "\n == Execute Test Suite using Native BSON Parser == "
@TEST_NATIVE=TRUE $(NODEUNIT) test/ test/gridstore test/bson

test_nodeunit_replicaset_native:
@echo "\n == Execute Test Suite using Native BSON Parser == "
@TEST_NATIVE=TRUE $(NODEUNIT) test/replicaset

test_all: build_native
@echo "\n == Run All tests =="
$(NODE) dev/tools/test_all.js --boot

test_all_junit: build_native
@echo "\n == Run All tests =="
$(NODE) dev/tools/test_all.js --junit --boot
$(MAKE) -C ./ext clean

clean:
rm ./external-libs/bson/bson.node
rm -r ./external-libs/bson/build

generate_docs:
$(NODE) dev/tools/build-docs.js
make --directory=./docs/sphinx-docs --file=Makefile html
rm ./ext/bson.node
rm -r ./ext/build

.PHONY: total
17 changes: 0 additions & 17 deletions ext/Makefile
Expand Up @@ -6,38 +6,21 @@ all:
rm -rf build .lock-wscript bson.node
node-waf configure build
cp -R ./build/Release/bson.node . || true
@$(NODE) --expose-gc test/test_bson.js
@$(NODE) --expose-gc test/test_full_bson.js
# @$(NODE) --expose-gc test/test_stackless_bson.js

all_debug:
rm -rf build .lock-wscript bson.node
node-waf --debug configure build
cp -R ./build/Release/bson.node . || true
@$(NODE) --expose-gc test/test_bson.js
@$(NODE) --expose-gc test/test_full_bson.js
# @$(NODE) --expose-gc test/test_stackless_bson.js

test:
@$(NODE) --expose-gc test/test_bson.js
@$(NODE) --expose-gc test/test_full_bson.js
# @$(NODE) --expose-gc test/test_stackless_bson.js

clang:
rm -rf build .lock-wscript bson.node
CXX=clang node-waf configure build
cp -R ./build/Release/bson.node . || true
@$(NODE) --expose-gc test/test_bson.js
@$(NODE) --expose-gc test/test_full_bson.js
# @$(NODE) --expose-gc test/test_stackless_bson.js

clang_debug:
rm -rf build .lock-wscript bson.node
CXX=clang node-waf --debug configure build
cp -R ./build/Release/bson.node . || true
@$(NODE) --expose-gc test/test_bson.js
@$(NODE) --expose-gc test/test_full_bson.js
# @$(NODE) --expose-gc test/test_stackless_bson.js

clean:
rm -rf build .lock-wscript bson.node
Expand Down
41 changes: 41 additions & 0 deletions install.js
@@ -0,0 +1,41 @@
var spawn = require('child_process').spawn,
exec = require('child_process').exec;

process.stdout.write("================================================================================\n");
process.stdout.write("= =\n");
process.stdout.write("= To install with C++ bson parser do <npm install mongodb --mongodb:native> =\n");
process.stdout.write("= =\n");
process.stdout.write("================================================================================\n");

// Check if we want to build the native code
var build_native = process.env['npm_package_config_native'] != null ? process.env['npm_package_config_native'] : 'false';
build_native = build_native == 'true' ? true : false;

// If we are building the native bson extension ensure we use gmake if available
if(build_native) {
// Check if we need to use gmake
exec('which gmake', function(err, stdout, stderr) {
// Set up spawn command
var make = null;
// No gmake build using make
if(err != null) {
make = spawn('make', ['total']);
} else {
make = spawn('gmake', ['total']);
}

// Execute spawn
make.stdout.on('data', function(data) {
process.stdout.write(data);
})

make.stderr.on('data', function(data) {
process.stdout.write(data);
})

make.on('exit', function(code) {
process.stdout.write('child process exited with code ' + code + "\n");
})
});
}

26 changes: 26 additions & 0 deletions package.json
@@ -0,0 +1,26 @@
{ "name" : "bson"
, "description" : "A bson parser for node.js and the browser"
, "keywords" : ["mongodb", "bson", "parser"]
, "version" : "0.0.1"
, "author" : "Christian Amor Kvalheim <christkv@gmail.com>"
, "contributors" : []

, "repository" : { "type" : "git"
, "url" : "git@github.com:christkv/bson.git" }
, "bugs" : { "mail" : "node-mongodb-native@googlegroups.com"
, "url" : "https://github.com/christkv/bson/issues" }
, "os" : [ "linux"
, "darwin"
, "freebsd" ]
, "devDependencies": {
, "nodeunit": "0.7.3"
, "gleak": "0.2.3"
}
, "config": { "native" : false }
, "main": "./lib/bson/index"
, "directories" : { "lib" : "./lib/bson" }
, "engines" : { "node" : ">=0.6.0" }
, "scripts": { "install" : "node install.js" }
, "licenses" : [ { "type" : "Apache License, Version 2.0"
, "url" : "http://www.apache.org/licenses/LICENSE-2.0" } ]
}

0 comments on commit 237eab3

Please sign in to comment.