#!/bin/sh

set -e

# Perform our checks
if [ "${TRAVIS_COMPILER:-gcc}" != "gcc" ]; then
#    echo "Skipping coverity on non-gcc"
    exit 0
fi

if [ "${TRAVIS_ARCH:-amd64}" != "amd64" ]; then
#    echo "Skipping coverity on non-amd64"
    exit 0
fi

if [ "${TRAVIS_DIST:-bionic}" != "bionic" ]; then
#    echo "Skipping coverity on non-bionic"
    exit 0
fi

# Download and run the normal build script.
curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh -o coverity_scan
chmod +x coverity_scan
exec bash ./coverity_scan "$@"
