Created
December 7, 2016 20:24
-
-
Save chrisy/d400f03be6bc3f1aa417a90bc8bef15f to your computer and use it in GitHub Desktop.
Builds VPP in the Coverity Scan wrapper and uploads the results to the Scan service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -ex | |
token=<DELETED> | |
email=chrisy@flirble.org | |
project="fd.io VPP" | |
project_encoded="fd.io+VPP" | |
url=https://scan.coverity.com | |
export COV_HOST=$(hostname -f) | |
export COV_USER=vpp | |
# Location of various directories | |
bdir=$(readlink -f $(dirname $0)) | |
vppdir="${bdir}/vpp" | |
covdir="${bdir}/cov-int" | |
covbin="${bdir}/cov-analysis-linux64-8.5.0.3/bin" | |
# Before we run the build, check we can submit one | |
check=$(curl -s --form project="${project}" \ | |
--form token="${token}" "${url}/api/upload_permitted") | |
if [ "${check}" = "Access denied" ]; then | |
echo "Bad token or project name." | |
exit 1 | |
fi | |
if [ "${check}" != '{"upload_permitted":true}' ]; then | |
echo "Upload not permitted; skipping." | |
exit 1 | |
fi | |
# Clean up after last build | |
rm -rf "${covdir}" "/tmp/cov-vpp" "/tmp/cov-chrisy" | |
# Setup VPP build tree | |
cd "${vppdir}" | |
git clean -xdf | |
git reset --hard | |
git pull | |
git fetch --tags --all | |
git checkout master | |
git clean -xdf | |
git reset --hard | |
version=$(git describe) | |
# Tweak the build args to indicate coverity is present | |
_count=$(grep -c __COVERITY__ build-data/platforms/vpp.mk || true) | |
if [ "${_count}" = 0 ]; then | |
sed -e "s/-DCLIB_DEBUG/-DCLIB_DEBUG -D__COVERITY__/" \ | |
-i build-data/platforms/vpp.mk | |
fi | |
# Tweak the source to disable static assertions | |
_count=$(grep -c __COVERITY__ vppinfra/vppinfra/error.h || true) | |
if [ "${_count}" = 0 ]; then | |
cat <<EOT >>vppinfra/vppinfra/error.h | |
/* If we're running under Coverity we don't need to die on | |
* failed static assertions. */ | |
#ifdef __COVERITY__ | |
#ifndef _Static_assert | |
#define _Static_assert(x,y) | |
#endif | |
#endif | |
EOT | |
fi | |
# Check dependencies are up to date | |
make install-dep UNATTENDED=y | |
# Disable ccache | |
export CCACHE_DISABLE=1 | |
# Run the build | |
"${covbin}/cov-build" --dir "${covdir}" make bootstrap build build-vpp-api build-vat plugins | |
# Tar the build artifacts that scan wants | |
cd "${bdir}" | |
tar -czf fd.io-vpp.tgz "$(basename ${covdir})" | |
rm -rf "${covdir}" | |
# Submit the build | |
curl --form token="${token}" \ | |
--form email="${email}" \ | |
--form file=@fd.io-vpp.tgz \ | |
--form version="${version}" \ | |
--form description="master:${version}" \ | |
"${url}/builds?project=${project_encoded}" | |
# All done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment