blob: 9ff3bad3eebcf2e6da93f58c0033d2ad6aceb4c1 [file] [log] [blame]
Billy Donahuebbb54ef2015-08-31 02:19:39 -04001#!/usr/bin/env sh
Billy Donahue520d30c2015-08-31 09:54:37 -04002set -evx
Herbert Thielend96a0382017-09-04 18:19:06 +02003
Carlos O'Ryan75b85d52017-12-24 10:34:56 -05004. ci/get-nprocessors.sh
5
Herbert Thielend96a0382017-09-04 18:19:06 +02006# 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
Herbert Thielenfe973122017-09-04 18:56:52 +020010 NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
Herbert Thielend96a0382017-09-04 18:19:06 +020011else
Herbert Thielenfe973122017-09-04 18:56:52 +020012 NPROCESSORS=2
Herbert Thielend96a0382017-09-04 18:19:06 +020013fi
Herbert Thielenfe973122017-09-04 18:56:52 +020014# 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}"
Herbert Thielend96a0382017-09-04 18:19:06 +020023export MAKEFLAGS
24
Billy Donahuebbb54ef2015-08-31 02:19:39 -040025env | sort
26
Scott Graham95ec42d2018-04-27 11:27:06 -070027# 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
Billy Donahuefbb0b962015-09-01 02:24:48 -040032mkdir build || true
Herbert Thielend33861d2017-08-29 17:41:26 +020033cd build
Billy Donahue6fc49052015-09-01 02:41:55 -040034cmake -Dgtest_build_samples=ON \
Billy Donahue6fc49052015-09-01 02:41:55 -040035 -Dgtest_build_tests=ON \
36 -Dgmock_build_tests=ON \
Scott Graham95ec42d2018-04-27 11:27:06 -070037 -Dcxx_no_exception=$NO_EXCEPTION \
38 -Dcxx_no_rtti=$NO_RTTI \
39 -DCMAKE_COMPILER_IS_GNUCXX=$COMPILER_IS_GNUCXX \
deki517b3bd2015-09-07 18:23:25 -040040 -DCMAKE_CXX_FLAGS=$CXX_FLAGS \
Herbert Thielencc246ec2017-08-30 11:59:36 +020041 -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
Herbert Thielend33861d2017-08-29 17:41:26 +020042 ..
Billy Donahuefefba422015-08-31 10:29:11 -040043make
Arkadiy Shapkin43c0ae32016-06-25 01:29:18 +030044CTEST_OUTPUT_ON_FAILURE=1 make test