2016-06-22 15:02:23 +02:00
|
|
|
#!/bin/bash
|
2016-04-12 20:55:52 +02:00
|
|
|
|
|
|
|
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 ))
|
|
|
|
}
|
|
|
|
|
2016-06-21 17:14:28 +02:00
|
|
|
# We have to do this by hand rather than use the coverity addon because of
|
|
|
|
# matrix explosion: https://github.com/travis-ci/travis-ci/issues/1975
|
2016-06-24 11:09:28 +02:00
|
|
|
# We also do it by hand because when we're throttled, the addon will exit
|
|
|
|
# the build immediately and skip the main script!
|
2016-06-21 17:14:28 +02:00
|
|
|
coverity_scan() {
|
|
|
|
if [ "${TRAVIS_JOB_NUMBER##*.}" != "1" ] || \
|
|
|
|
[ -n "${TRAVIS_TAG}" ] || \
|
|
|
|
[ "${TRAVIS_PULL_REQUEST}" = "true" ]
|
|
|
|
then
|
|
|
|
echo "Skipping coverity scan."
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
export COVERITY_SCAN_PROJECT_NAME="${TRAVIS_REPO_SLUG}"
|
|
|
|
export COVERITY_SCAN_NOTIFICATION_EMAIL="google-breakpad-dev@googlegroups.com"
|
2016-06-24 10:40:03 +02:00
|
|
|
export COVERITY_SCAN_BUILD_COMMAND="make -j${JOBS}"
|
|
|
|
export COVERITY_SCAN_BUILD_COMMAND_PREPEND="git clean -q -x -d -f; git checkout -f; ./configure"
|
2016-06-21 17:14:28 +02:00
|
|
|
export COVERITY_SCAN_BRANCH_PATTERN="master"
|
|
|
|
|
|
|
|
curl -s "https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh" | bash || :
|
|
|
|
}
|
|
|
|
|
2016-05-25 20:36:37 +02:00
|
|
|
# Do an in-tree build and make sure tests pass.
|
2016-04-12 20:55:52 +02:00
|
|
|
build() {
|
|
|
|
./configure
|
2016-04-19 21:19:32 +02:00
|
|
|
make -j${JOBS} check VERBOSE=1
|
2016-05-25 20:36:37 +02:00
|
|
|
make distclean
|
|
|
|
}
|
|
|
|
|
|
|
|
# Do an out-of-tree build and make sure we can create a release tarball.
|
|
|
|
build_out_of_tree() {
|
|
|
|
mkdir -p build/native
|
2016-06-21 22:55:02 +02:00
|
|
|
pushd build/native >/dev/null
|
2016-05-25 20:36:37 +02:00
|
|
|
../../configure
|
|
|
|
make -j${JOBS} distcheck VERBOSE=1
|
2016-06-21 22:55:02 +02:00
|
|
|
popd >/dev/null
|
2016-04-12 20:55:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
setup_env
|
|
|
|
build
|
2016-05-25 20:36:37 +02:00
|
|
|
build_out_of_tree
|
2016-06-21 17:14:28 +02:00
|
|
|
|
|
|
|
# Do scans last as they like to dirty the tree and some tests
|
|
|
|
# expect a clean tree (like code style checks).
|
|
|
|
coverity_scan
|
2016-04-12 20:55:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|