blob: 24a557e98a54296afb70bd8253357c371a97224d [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
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
Herbert Thielenfe973122017-09-04 18:56:52 +02008 NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
Herbert Thielend96a0382017-09-04 18:19:06 +02009else
Herbert Thielenfe973122017-09-04 18:56:52 +020010 NPROCESSORS=2
Herbert Thielend96a0382017-09-04 18:19:06 +020011fi
Herbert Thielenfe973122017-09-04 18:56:52 +020012# 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}"
Herbert Thielend96a0382017-09-04 18:19:06 +020021export MAKEFLAGS
22
Billy Donahuebbb54ef2015-08-31 02:19:39 -040023env | sort
24
Billy Donahuefbb0b962015-09-01 02:24:48 -040025mkdir build || true
Herbert Thielend33861d2017-08-29 17:41:26 +020026cd build
Billy Donahue6fc49052015-09-01 02:41:55 -040027cmake -Dgtest_build_samples=ON \
Billy Donahue6fc49052015-09-01 02:41:55 -040028 -Dgtest_build_tests=ON \
29 -Dgmock_build_tests=ON \
deki517b3bd2015-09-07 18:23:25 -040030 -DCMAKE_CXX_FLAGS=$CXX_FLAGS \
Herbert Thielencc246ec2017-08-30 11:59:36 +020031 -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
Herbert Thielend33861d2017-08-29 17:41:26 +020032 ..
Billy Donahuefefba422015-08-31 10:29:11 -040033make
Arkadiy Shapkin43c0ae32016-06-25 01:29:18 +030034CTEST_OUTPUT_ON_FAILURE=1 make test