diff --git a/.gitignore b/.gitignore index 7c4f582..0f80a50 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ berlin-latest.osrm* stxxl.errlog stxxl.log *.sublime-* -/lib/osrm.node +mason_packages +npm-debug.log \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 7621366..532cf46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,66 +1,78 @@ language: cpp -os: - - linux - - osx +git: + depth: 10 -compiler: - - clang - - gcc +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 + - gdb + +# TODO: no core files on sudo:false machines until https://github.com/travis-ci/travis-ci/issues/3754 is resolved +sudo: false matrix: - exclude: + include: + # Coverage - os: osx + compiler: clang + env: NODE_VERSION="0.10" COVERAGE=true TARGET=Debug NPM_FLAGS="--debug" + # Linux + - os: linux compiler: gcc + env: NODE_VERSION="0.12.0" TARGET=Release - os: linux + compiler: gcc + env: NODE_VERSION="0.10.36" TARGET=Release + - os: linux + compiler: gcc + env: NODE_VERSION="0.10.36" TARGET=Debug NPM_FLAGS="--debug" + # OS X + - os: osx + compiler: clang + env: NODE_VERSION="0.12.0" TARGET=Release + - os: osx compiler: clang + env: NODE_VERSION="0.10.36" TARGET=Release env: - matrix: - - NVM_NODE_VERSION="0.10.36" - - NVM_NODE_VERSION="0.12.0" global: + - JOBS: "3" + - OSRM_RELEASE: "v4.6.1" - secure: KitzGZjoDblX/3heajcvssGz0JnJ/k02dr2tu03ksUV+6MogC3RSQudqyKY57+f8VyZrcllN/UOlJ0Q/3iG38Oz8DljC+7RZxtkVmE1SFBoOezKCdhcvWM12G3uqPs7hhrRxuUgIh0C//YXEkulUrqa2H1Aj2xeen4E3FAqEoy0= - secure: WLGmxl6VTVWhXGm6X83GYNYzPNsvTD+9usJOKM5YBLAdG7cnOBQBNiCCUKc9OZMMZVUr3ec2/iigakH5Y8Yc+U6AlWKzlORyqWLuk4nFuoedu62x6ocQkTkuOc7mHiYhKd21xTGMYauaZRS6kugv4xkpGES2UjI2T8cjZ+LN2jU= before_install: -# check if tag exists and matches package.json - scripts/validate_tag.sh -# get commit message -- COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n') -# put node-pre-gyp on path -- export PATH=./node_modules/.bin/:$PATH -# here we set up the node version on the fly based on the matrix value. -# This is done manually so that it is easy to flip the 'language' to -# objective-c in another branch (to run the same travis.yml on OS X) -- rm -rf ~/.nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm -- source ~/.nvm/nvm.sh -- nvm install $NVM_NODE_VERSION -- nvm use $NVM_NODE_VERSION -- node --version -- npm --version -- which node -- "if [[ `uname -s` == 'Linux' ]]; then sudo add-apt-repository -y ppa:kalakris/cmake && sudo apt-get update -qq && sudo apt-get install cmake pkg-config; fi" -- if [[ `uname -s` == 'Darwin' ]]; then brew install pkg-config; fi +- export COVERAGE=${COVERAGE:-false} +- if [[ $(uname -s) == 'Linux' ]]; then + export CXX="g++-4.8"; + export CC="gcc-4.8"; + export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python2.7/site-packages; + else + export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python/site-packages; + fi; +- source ./scripts/install_node.sh ${NODE_VERSION} install: -# set a few env settings for the static build script -- NODE_MODULE_ROOT=`pwd` -- export OSRM_RELEASE="v4.6.1" -# WARNING: this script modifies the environment -- source ./scripts/static_build.sh +- source ./bootstrap.sh +- if [[ ${COVERAGE} == true ]]; then + PYTHONUSERBASE=$(pwd)/mason_packages/.link pip install --user cpp-coveralls; + export LDFLAGS="--coverage"; + export CXXFLAGS="--coverage"; + fi; +- npm install --build-from-source ${NPM_FLAGS} --clang=1; before_script: -- if [[ `uname -s` == 'Darwin' ]]; then otool -L ./lib/binding/* || true; fi -- if [[ `uname -s` == 'Linux' ]]; then readelf -d ./lib/binding/* || true; fi -- which osrm-extract||true;rm -rf ${TMP_DEPS_DIR};which osrm-extract||true; -- make test +- ulimit -c unlimited -S script: -- node-pre-gyp package -- if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then - node-pre-gyp publish; - fi; -- if [[ ${COMMIT_MESSAGE} =~ "[republish binary]" ]]; then - node-pre-gyp unpublish publish; - fi; +- RESULT=0 +- make test || RESULT=$? +- for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb $(which node) $i -ex "thread apply all bt" -ex "set pagination 0" -batch; done; +- if [[ ${RESULT} != 0 ]]; then exit $RESULT; fi +- if [[ ${COVERAGE} == true ]]; then ./mason_packages/.link/bin/cpp-coveralls --exclude node_modules --exclude mason_packages --exclude tests --build-root build --gcov-options '\-lp' --exclude doc --exclude build/Release/obj/gen; fi; +- if [[ ${COVERAGE} != true ]]; then ./scripts/publish.sh; fi; diff --git a/Makefile b/Makefile index a597bf1..32ba4ae 100755 --- a/Makefile +++ b/Makefile @@ -1,22 +1,46 @@ -all: osrm.node +#http://www.gnu.org/prep/standards/html_node/Standard-Targets.html#Standard-Targets -./node_modules: - npm install --build-from-source +all: build -osrm.node: ./node_modules - ./node_modules/.bin/node-pre-gyp build --loglevel=silent +pkgconfig: + @if [[ `which pkg-config` ]]; then echo "Success: Found pkg-config"; else "echo you need pkg-config installed" && exit 1; fi; -debug: - ./node_modules/.bin/node-pre-gyp rebuild --debug +./node_modules/node-pre-gyp: + npm install node-pre-gyp -verbose: - ./node_modules/.bin/node-pre-gyp rebuild --loglevel=verbose +./node_modules: ./node_modules/node-pre-gyp + source ./bootstrap.sh && npm install `node -e "console.log(Object.keys(require('./package.json').dependencies).join(' '))"` \ + `node -e "console.log(Object.keys(require('./package.json').devDependencies).join(' '))"` --clang=1 + +./build: pkgconfig ./node_modules + source ./bootstrap.sh && ./node_modules/.bin/node-pre-gyp configure build --loglevel=error --clang=1 + +debug: pkgconfig ./node_modules + export TARGET=Debug && source ./bootstrap.sh && ./node_modules/.bin/node-pre-gyp configure build --debug --clang=1 + +coverage: pkgconfig ./node_modules + source ./bootstrap.sh && ./node_modules/.bin/node-pre-gyp configure build --debug --clang=1 --coverage=true + +verbose: pkgconfig ./node_modules + source ./bootstrap.sh && ./node_modules/.bin/node-pre-gyp configure build --loglevel=verbose --clang=1 clean: @rm -rf ./build rm -rf ./lib/binding/ - rm -rf ./node_modules - rm -f *.osrm* + rm -rf ./node_modules/ + rm -f ./*tgz + rm -f ./*.osrm* + rm -rf ./mason_packages + rm -rf ./osrm-backend-* + +grind: + valgrind --leak-check=full node node_modules/.bin/_mocha + +testpack: + rm -f ./*tgz + npm pack + tar -ztvf *tgz + rm -f ./*tgz rebuild: @make clean @@ -26,15 +50,13 @@ berlin-latest.osm.pbf: wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf berlin-latest.osrm: berlin-latest.osm.pbf - PATH="./lib/binding:${PATH}" && osrm-extract berlin-latest.osm.pbf -p test/data/car.lua + ./lib/binding/osrm-extract berlin-latest.osm.pbf -p test/data/car.lua berlin-latest.osrm.hsgr: berlin-latest.osrm - PATH="./lib/binding:${PATH}" && osrm-prepare berlin-latest.osrm -p test/data/car.lua + ./lib/binding/osrm-prepare berlin-latest.osrm -p test/data/car.lua && \ + ./lib/binding/osrm-datastore berlin-latest.osrm test: berlin-latest.osrm.hsgr - PATH="./lib/binding:${PATH}" && osrm-datastore berlin-latest.osrm - npm test - -check: test + ./node_modules/.bin/mocha -R spec -.PHONY: test +.PHONY: test clean build \ No newline at end of file diff --git a/binding.gyp b/binding.gyp index f5d0899..179dc91 100644 --- a/binding.gyp +++ b/binding.gyp @@ -20,7 +20,7 @@ 'conditions': [ [ 'OS=="linux"', { 'cflags_cc' : [ - '-std=c++11', '-flto' + '-std=c++11' ], 'libraries':[ '-Wl,-rpath=