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