Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Project-OSRM/node-osrm into latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Dane Springmeyer committed Sep 9, 2016
2 parents 926186a + 8a27445 commit 66ec280
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 129 deletions.
132 changes: 58 additions & 74 deletions .travis.yml
Expand Up @@ -11,8 +11,8 @@ branches:
- /^v[0-9]/

cache:
ccache: true
apt: true
directories:
- ${HOME}/.ccache

notifications:
email: false
Expand All @@ -23,86 +23,70 @@ notifications:

sudo: false

env:
global:
- CCACHE_TEMPDIR=/tmp/.ccache-temp
- CCACHE_COMPRESS=1
- CASHER_TIME_OUT=1000
- CC="clang"
- CXX="clang++"
- secure: KitzGZjoDblX/3heajcvssGz0JnJ/k02dr2tu03ksUV+6MogC3RSQudqyKY57+f8VyZrcllN/UOlJ0Q/3iG38Oz8DljC+7RZxtkVmE1SFBoOezKCdhcvWM12G3uqPs7hhrRxuUgIh0C//YXEkulUrqa2H1Aj2xeen4E3FAqEoy0=
- secure: WLGmxl6VTVWhXGm6X83GYNYzPNsvTD+9usJOKM5YBLAdG7cnOBQBNiCCUKc9OZMMZVUr3ec2/iigakH5Y8Yc+U6AlWKzlORyqWLuk4nFuoedu62x6ocQkTkuOc7mHiYhKd21xTGMYauaZRS6kugv4xkpGES2UjI2T8cjZ+LN2jU=

addons_default: &apt_packages
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
# note: libstdc++-5-dev is required by clang-3.8 for its headers (clang-3.8 is installed by mason on linux)
packages: [ 'libstdc++-5-dev', 'apport', 'gdb' ]

script_default: &build_and_publish
- ./scripts/build.sh
- ./scripts/publish.sh

matrix:
include:
# Linux
- os: linux
compiler: ": clang38-release-node-v4"
env: NODE="4" TARGET=Release CC="clang-3.8" CXX="clang++-3.8" PUBLISHABLE=true
# note: libstdc++-5-dev is required by clang-3.8 for its headers (clang-3.8 is installed by mason below)
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'libstdc++-5-dev', 'apport', 'gdb' ]
env: NODE="4" TARGET=Release
addons: *apt_packages
script: *build_and_publish
- os: linux
compiler: ": clang38-debug-node-v4"
env: NODE="4" TARGET=Debug CC="clang-3.8" CXX="clang++-3.8" PUBLISHABLE=true
# note: libstdc++-5-dev is required by clang-3.8 for its headers (clang-3.8 is installed by mason below)
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'libstdc++-5-dev', 'apport', 'gdb' ]
env: NODE="4" TARGET=Debug NPM_FLAGS="--debug"
addons: *apt_packages
script: *build_and_publish
- os: linux
env: NODE="6" TARGET=Release
addons: *apt_packages
script: *build_and_publish
- os: linux
env: NODE="6" TARGET=Debug NPM_FLAGS="--debug"
addons: *apt_packages
script: *build_and_publish
# OS X
- os: osx
# https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions
osx_image: xcode8 # upgrades clang from 6 -> 7
compiler: clang
env: NODE="4" TARGET=Release PUBLISHABLE=true
osx_image: xcode8
env: NODE="4" TARGET=Release
script: *build_and_publish
- os: osx
osx_image: xcode8
env: NODE="4" TARGET=Debug NPM_FLAGS="--debug"
script: *build_and_publish
- os: osx
# https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions
osx_image: xcode8
env: NODE="6" TARGET=Release
script: *build_and_publish
- os: osx
osx_image: xcode8 # upgrades clang from 6 -> 7
compiler: clang
env: NODE="4" TARGET=Debug PUBLISHABLE=true
osx_image: xcode8
env: NODE="6" TARGET=Debug NPM_FLAGS="--debug"
script: *build_and_publish
# Linux coverage build
- os: linux
compiler: ": clang38-debug-coverage-node-v4"
env: NODE="4" TARGET=Debug CC="clang-3.8" CXX="clang++-3.8" COVERAGE=true PUBLISHABLE=false
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'libstdc++-5-dev', 'apport', 'gdb' ]

env:
global:
- CCACHE_TEMPDIR=/tmp/.ccache-temp
- CCACHE_COMPRESS=1
- CASHER_TIME_OUT=1000
- secure: KitzGZjoDblX/3heajcvssGz0JnJ/k02dr2tu03ksUV+6MogC3RSQudqyKY57+f8VyZrcllN/UOlJ0Q/3iG38Oz8DljC+7RZxtkVmE1SFBoOezKCdhcvWM12G3uqPs7hhrRxuUgIh0C//YXEkulUrqa2H1Aj2xeen4E3FAqEoy0=
- secure: WLGmxl6VTVWhXGm6X83GYNYzPNsvTD+9usJOKM5YBLAdG7cnOBQBNiCCUKc9OZMMZVUr3ec2/iigakH5Y8Yc+U6AlWKzlORyqWLuk4nFuoedu62x6ocQkTkuOc7mHiYhKd21xTGMYauaZRS6kugv4xkpGES2UjI2T8cjZ+LN2jU=

before_install:
# workaround travis rvm bug
# http://superuser.com/questions/1044130/why-am-i-having-how-can-i-fix-this-error-shell-session-update-command-not-f
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
rvm get head || true
fi
- source scripts/setup_mason.sh
- scripts/validate_tag.sh
- |
if [[ $(uname -s) == 'Linux' ]]; then
mason install clang 3.8.0
export PATH=$(mason prefix clang 3.8.0)/bin:${PATH}
which clang++
fi
install:
- |
if [[ "$(uname -s)" == "Linux" ]]; then
export JOBS=2
source ./scripts/build.sh
else
export JOBS=4
source ./scripts/build.sh
fi
script:
- if [[ ${PUBLISHABLE} == true ]]; then
./scripts/publish.sh;
fi;
- |
if [ -n "${COVERAGE}" ]; then
which llvm-cov
curl -S -f https://codecov.io/bash -o codecov
chmod +x codecov
./codecov -x "llvm-cov gcov" -Z
fi
env: NODE="4" TARGET=Debug COVERAGE=true NPM_FLAGS="--debug"
addons: *apt_packages
script:
- ./scripts/build.sh
- curl -S -f https://codecov.io/bash -o codecov
- chmod +x codecov
- ./codecov -x "llvm-cov gcov" -Z
9 changes: 3 additions & 6 deletions package.json
Expand Up @@ -31,11 +31,8 @@
},
"dependencies": {
"nan": "^2.1.0",
"node-pre-gyp": "~0.6.7"
"node-pre-gyp": "~0.6.30"
},
"bundledDependencies": [
"node-pre-gyp"
],
"devDependencies": {
"aws-sdk": "~2.0.31",
"documentation": "^4.0.0-beta2",
Expand All @@ -45,9 +42,9 @@
"node": ">=4"
},
"scripts": {
"prepublish": "npm ls",
"preinstall": "npm install node-pre-gyp",
"install": "node-pre-gyp install --fallback-to-build",
"test": "node test/index.js",
"docs": "documentation build src/node_osrm.cpp --polyglot -f md -o docs/api.md"
"docs": "npm install documentation@^4.0.0-beta2 && documentation build src/node_osrm.cpp --polyglot -f md -o docs/api.md"
}
}
33 changes: 14 additions & 19 deletions scripts/build.sh
Expand Up @@ -11,29 +11,24 @@ export NODE=${NODE:-4}

export CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source ${CURRENT_DIR}/travis_helper.sh

mapbox_time "setup-mason" source ${CURRENT_DIR}/setup_mason.sh
mapbox_time "setup-compiler" source ${CURRENT_DIR}/setup_compiler.sh

# ensure we start inside the root directory (one level up)
cd ${CURRENT_DIR}/../

if [[ $(which wget) ]]; then
echo "Success: Found wget";
else
if [[ ! $(which wget) ]]; then
echo "echo wget must be installed";
exit 1;
fi;

if [[ $(which pkg-config) ]]; then
echo "Success: Found pkg-config";
else
if [[ ! $(which pkg-config) ]]; then
echo "echo pkg-config must be installed";
exit 1;
fi;

if [[ ${TARGET} == 'Debug' ]]; then
export NPM_FLAGS="--debug"
else
export NPM_FLAGS=""
fi

if [[ "$(uname -s)" == "Darwin" ]]; then
if [[ -f /etc/sysctl.conf ]] && [[ $(grep shmmax /etc/sysctl.conf) ]]; then
echo "Note: found shmmax setting in /etc/sysctl.conf, not modifying"
Expand All @@ -42,17 +37,17 @@ if [[ "$(uname -s)" == "Darwin" ]]; then
sudo sysctl -w kern.sysv.shmmax=4294967296
sudo sysctl -w kern.sysv.shmall=1048576
sudo sysctl -w kern.sysv.shmseg=128
brew install md5sha1sum
mapbox_time "brew" brew install md5sha1sum
fi
fi

# install consistent node version
source ./scripts/install_node.sh ${NODE}
mapbox_time "install_node" source ./scripts/install_node.sh ${NODE}

if [[ ${TARGET} == 'Debug' ]]; then
export BUILD_TYPE=Debug && source ./bootstrap.sh
mapbox_time "bootstrap" export BUILD_TYPE=Debug && source ./bootstrap.sh
else
source ./bootstrap.sh
mapbox_time "bootstrap" source ./bootstrap.sh
fi

# only set coverage flags for node-osrm to avoid
Expand All @@ -61,20 +56,20 @@ if [[ ${COVERAGE} == true ]]; then
export LDFLAGS="${LDFLAGS:-} --coverage" && export CXXFLAGS="${CXXFLAGS:-} --coverage"
fi

npm install --build-from-source ${NPM_FLAGS} --clang=1
mapbox_time "npm-install" npm install --build-from-source ${NPM_FLAGS} --clang=1

# run tests, with backtrace support
if [[ "$(uname -s)" == "Linux" ]]; then
ulimit -c unlimited -S
RESULT=0
make test || RESULT=$?
mapbox_time "make-test" 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
else
# todo: coredump support on OS X
make test
mapbox_time "make-test" make test
fi


Expand Down
8 changes: 7 additions & 1 deletion scripts/publish.sh
@@ -1,5 +1,11 @@
#!/bin/bash

set -eu
set -o pipefail

# should be set for debug builds
export NPM_FLAGS=${NPM_FLAGS:-}

echo "dumping binary meta..."
./node_modules/.bin/node-pre-gyp reveal ${NPM_FLAGS}

Expand All @@ -25,7 +31,7 @@ else
echo "This is a push commit, continuing to package..."
./node_modules/.bin/node-pre-gyp package ${NPM_FLAGS}

COMMIT_MESSAGE=$(git log --format=%B --no-merges | head -n 1 | tr -d '\n')
export COMMIT_MESSAGE=$(git log --format=%B --no-merges | head -n 1 | tr -d '\n')
echo "Commit message: ${COMMIT_MESSAGE}"

if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then
Expand Down
10 changes: 10 additions & 0 deletions scripts/setup_compiler.sh
@@ -0,0 +1,10 @@
#!/bin/bash

set -eu
set -o pipefail

if [[ $(uname -s) == 'Linux' ]]; then
mason install clang 3.8.0
export PATH=$(mason prefix clang 3.8.0)/bin:${PATH}
which clang++
fi
6 changes: 1 addition & 5 deletions scripts/setup_mason.sh
Expand Up @@ -20,8 +20,4 @@ function setup_mason() {
export CC=${CC:-clang}
}


setup_mason

set +eu
set +o pipefail
setup_mason
71 changes: 71 additions & 0 deletions scripts/travis_helper.sh
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

# This script is sourced, so do not set -e or -o pipefail here. Doing so would
# bleed into Travis' wrapper script, which messes with their workflow, e.g.
# preventing after_failure scripts to be triggered.

case `uname -s` in
'Darwin') JOBS=$((`sysctl -n hw.ncpu` + 2)) ;;
'Linux') JOBS=$((`nproc` + 2)) ;;
*) JOBS=2 ;;
esac

function mapbox_time_start {
local name=$1
mapbox_timer_name=$name

mapbox_fold start $name

mapbox_timer_id=$(printf %08x $(( RANDOM * RANDOM )))
eval "mapbox_start_time_$mapbox_timer_id=$(mapbox_nanoseconds)"
echo -en "travis_time:start:$mapbox_timer_id\n"
}

function mapbox_time_finish {
local name=${1:-$mapbox_timer_name}
local timer_id=${2:-$mapbox_timer_id}
local timer_start="mapbox_start_time_$timer_id"
eval local start_time=\${$timer_start}
local end_time=$(mapbox_nanoseconds)
local duration=$(($end_time-$start_time))
echo -en "travis_time:end:$timer_id:start=$start_time,finish=$end_time,duration=$duration\n"

mapbox_fold end $name
}

function mapbox_time {
local name=$1 ; shift
mapbox_time_start $name
local timer_id=$mapbox_timer_id
echo "\$ $@"
$@
mapbox_time_finish $name $timer_id
}

function mapbox_fold {
local action=$1
local name=$2
local ANSI_CLEAR="\e[0m"
echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}"
}

function mapbox_nanoseconds {
local cmd="date"
local format="+%s%N"
local os=$(uname -s)

if hash gdate > /dev/null 2>&1; then
cmd="gdate" # use gdate if available
elif [[ "$os" = Darwin ]]; then
format="+%s000000000" # fallback to second precision on darwin (does not support %N)
fi

$cmd -u $format
}

export JOBS
export -f mapbox_fold
export -f mapbox_nanoseconds
export -f mapbox_time
export -f mapbox_time_start
export -f mapbox_time_finish

0 comments on commit 66ec280

Please sign in to comment.