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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#!/bin/sh
# This script is used for testing the build, primarily for use
# with GitLab CI, but may be used by hand as well.
set -e
set -x
# Test autoconf build
autoconf_build()
{
autoreconf -ivf
mkdir autoconf-build
cd autoconf-build
echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}"
CFLAGS="-Wall -Wextra -Werror" ../configure --prefix=$(pwd)/../autoconf-install ${opts}
make
make install
make check
make distcheck
mkdir ../distribution
cp tiff-*.tar.* tiff*.zip ../distribution
}
# Test autoconf build (minimal; no distcheck)
autoconf_build_minimal()
{
autoreconf -ivf
mkdir autoconf-build
cd autoconf-build
echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}"
CFLAGS="-Wall -Wextra -Werror" ../configure --prefix=$(pwd)/../autoconf-install ${opts}
make
make install
make check
}
# Test cmake build
cmake_build()
{
PATH="$(pwd)/tools/bin:$PATH"
if [ "$(uname -s)" = "Darwin" ]; then
PATH="$(pwd)/tools/CMake.app/Contents/bin:$PATH"
fi
mkdir cmake-build
cd cmake-build
opts="-Dfatal-warnings=ON"
para3=`echo "$3" | sed 's/./\L&/g'`
if [ "$para3" = "static" ]; then
opts2="-DBUILD_SHARED_LIBS:BOOL=OFF"
else
opts2=""
fi
echo "Running cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ${opts2} .."
cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install -DCMAKE_C_FLAGS="-Wall -Wextra -Werror" ${opts} ${opts2} ..
$COVERITY_BUILD cmake --build .
cmake --build . --target install
ctest -V
cd ..
if [ "$para3" = "static" ]; then
echo No test project build for STATIC CI/CD build - skipped -.
else
# Build test project using find_package(Tiff CONFIG)
mkdir cmake-test-build
cd cmake-test-build
cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" "-DTiff_DIR=$PWD/../cmake-install/lib/cmake/tiff" -S ../build/test_cmake -B .
cmake --build .
cd ..
mkdir cmake-test-no-target-build
cd cmake-test-no-target-build
cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" "-DTiff_DIR=$PWD/../cmake-install/lib/cmake/tiff" -S ../build/test_cmake_no_target -B .
cmake --build .
# Return to cmake-build for coverity_build()
cd ../cmake-build
fi
}
# Static-analysis with coverity
coverity_build()
{
curl -o /tmp/cov-analysis-linux64.tgz \
https://scan.coverity.com/download/linux64 \
--form project=$COVERITY_SCAN_PROJECT_NAME \
--form token=$COVERITY_SCAN_TOKEN
tar xfz /tmp/cov-analysis-linux64.tgz
COVERITY_BUILD="$(pwd)/cov-analysis-linux64-*/bin/cov-build --dir cov-int" cmake_build "$@"
tar cfz cov-int.tar.gz cov-int
curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME \
--form token=$COVERITY_SCAN_TOKEN \
--form email=$GITLAB_USER_EMAIL \
--form file=@cov-int.tar.gz \
--form version="`git describe --tags`" \
--form description="`git describe --tags` / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
}
build=$1
shift
case $build in
autoconf)
echo "Testing Autoconf build"
autoconf_build "$@"
;;
autoconf-minimal)
echo "Testing Autoconf build (minimal)"
autoconf_build_minimal "$@"
;;
cmake)
echo "Testing CMake build"
cmake_build "$@"
;;
coverity)
echo "Static analysis with Coverity"
coverity_build "$@"
;;
*)
echo "Invalid argument: \"$arg\"" >&2
exit 1
;;
esac
exit 0
|