aboutsummaryrefslogtreecommitdiff
path: root/scripts/travis-build.sh
blob: d41f7ed00fcd9892078aedc635862ccd62a1a904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

set -ex

setup_env() {
  # Travis sets CC/CXX to the system toolchain, so our .travis.yml
  # exports USE_{CC,CXX} for this script to use.
  if [ -n "$USE_CC" ]; then
      export CC=$USE_CC
  fi
  if [ -n "$USE_CXX" ]; then
      export CXX=$USE_CXX
  fi
  # Use -jN for faster builds. Travis build machines under Docker
  # have a lot of cores, but are memory-limited, so the kernel
  # will OOM if we try to use them all, so use at most 4.
  # See https://github.com/travis-ci/travis-ci/issues/1972
  export NCPUS=$(getconf _NPROCESSORS_ONLN)
  export JOBS=$(( $NCPUS < 4 ? $NCPUS : 4 ))
}

build() {
  ./configure
  make -j${JOBS} check
}

main() {
  setup_env
  build
}

main "$@"