1#!/usr/bin/env sh 2set -evx 3 4# if possible, ask for the precise number of processors, 5# otherwise take 2 processors as reasonable default; see 6# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization 7if [ -x /usr/bin/getconf ]; then 8 NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN) 9else 10 NPROCESSORS=2 11fi 12# as of 2017-09-04 Travis CI reports 32 processors, but GCC build 13# crashes if parallelized too much (maybe memory consumption problem), 14# so limit to 4 processors for the time being. 15if [ $NPROCESSORS -gt 4 ] ; then 16 echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4." 17 NPROCESSORS=4 18fi 19# Tell make to use the processors. No preceding '-' required. 20MAKEFLAGS="j${NPROCESSORS}" 21export MAKEFLAGS 22 23env | sort 24 25mkdir build || true 26cd build 27cmake -Dgtest_build_samples=ON \ 28 -Dgtest_build_tests=ON \ 29 -Dgmock_build_tests=ON \ 30 -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ 31 -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ 32 .. 33make 34CTEST_OUTPUT_ON_FAILURE=1 make test 35