Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Last active November 23, 2016 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save springmeyer/eb44aeaaaf37cd3358e20ec69b323208 to your computer and use it in GitHub Desktop.
Save springmeyer/eb44aeaaaf37cd3358e20ec69b323208 to your computer and use it in GitHub Desktop.
build all of osrm and run all the tests
#!/bin/bash
set -eu
set -o pipefail
function echo_color { >&2 echo -e "\033[1m\033[36m* $1\033[0m"; }
function echo_color_substep { >&2 echo -e "\033[1m\033[32m* $1\033[0m"; }
export SHOW_COMPILE_FLAGS=false
export OSRM_BUILD_DIR="$(pwd)/build-osrm"
export INSTALL_PREFIX=/tmp/osrm
export PKG_CONFIG_PATH=${INSTALL_PREFIX}/lib/pkgconfig
export BUILD_TYPE=Release
export JOBS=$(sysctl -n hw.ncpu)
echo_color "Building OSRM"
echo_color_substep "VERBOSE: ${SHOW_COMPILE_FLAGS}"
echo_color_substep "OSRM_BUILD_DIR: ${OSRM_BUILD_DIR}"
echo_color_substep "INSTALL_PREFIX: ${INSTALL_PREFIX}"
echo_color_substep "PKG_CONFIG_PATH: ${PKG_CONFIG_PATH}"
echo_color_substep "BUILD_TYPE: ${BUILD_TYPE}"
echo_color_substep "JOBS: ${JOBS}"
echo_color "Removing ${OSRM_BUILD_DIR} directory"
rm -rf ${OSRM_BUILD_DIR}
mkdir ${OSRM_BUILD_DIR}
cd ${OSRM_BUILD_DIR}
echo_color "Configuring OSRM"
cmake ../ -DENABLE_MASON=ON \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBUILD_TOOLS=1
if [[ ${SHOW_COMPILE_FLAGS} == true ]]; then
echo_color "Compiling and linking core of osrm-backend"
make --jobs=${JOBS} VERBOSE=1
echo_color "Compiling and linking tests"
make tests --jobs=${JOBS} VERBOSE=1
echo_color "Compiling and linking benchmarks"
make benchmarks --jobs=${JOBS} VERBOSE=1
else
echo_color "Compiling and linking core of osrm-backend"
make --jobs=${JOBS}
echo_color "Compiling and linking tests"
make tests --jobs=${JOBS}
echo_color "Compiling and linking benchmarks"
make benchmarks --jobs=${JOBS}
fi
echo_color "Installing"
make install
echo_color "Compiling and linking example.cpp"
cd ../
rm -rf example/build && mkdir -p example/build && cd example/build
cmake ../ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_MASON=1
make
cd ../../
echo_color "Creating test data"
make -C test/data clean || true
echo_color "Running benchmark"
make -C test/data benchmark
echo_color "Running example"
# https://github.com/Project-OSRM/osrm-backend/pull/3283
./example/build/osrm-example test/data/monaco.osrm
echo_color "Running unit tests"
cd ${OSRM_BUILD_DIR}
./unit_tests/library-tests ../test/data/monaco.osrm
./unit_tests/extractor-tests
./unit_tests/engine-tests
./unit_tests/util-tests
./unit_tests/server-tests
cd ../
echo_color "Running cucumber tests"
npm test
echo_color_substep "Yay, we finished successfully!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment