3 # Automated build and test of libarchive on CI systems
5 # Variables that can be passed via environment:
6 # BS= # build system (autotools or cmake)
7 # BUILDDIR= # build directory
8 # SRCDIR= # source directory
9 # CONFIGURE_ARGS= # configure arguments
10 # MAKE_ARGS= # make arguments
11 # DEBUG= # set -g -fsanitize=address flags
14 if [ -n "${BUILD_SYSTEM}" ]; then
20 CMAKE="${CMAKE:-cmake}"
22 SRCDIR="${SRCDIR:-`pwd`}"
26 echo "Usage: $0 [-b autotools|cmake] [-a autogen|configure|build|test|install|distcheck ] [ -a ... ] [ -d builddir ] [-s srcdir ]"
33 while getopts a:b:d:s: opt; do
43 *) inputerror "Invalid action (-a)" ;;
45 ACTIONS="${ACTIONS} ${OPTARG}"
51 *) inputerror "Invalid build system (-b)" ;;
59 if [ ! -f "${SRCDIR}/build/version" ]; then
60 inputerror "Missing file: ${SRCDIR}/build/version"
65 if [ -z "${MAKE_ARGS}" ]; then
66 if [ "${BS}" = "autotools" ]; then
68 elif [ "${BS}" = "cmake" ]; then
72 if [ -n "${DEBUG}" ]; then
73 if [ -n "${CFLAGS}" ]; then
74 export CFLAGS="${CFLAGS} -g -fsanitize=address"
76 export CFLAGS="-g -fsanitize=address"
78 if ["${BS}" = "cmake" ]; then
79 CONFIGURE_ARGS="${CONFIGURE_ARGS} -DCMAKE_C_CFLAGS=-g -fsanitize=address"
82 if [ -z "${ACTIONS}" ]; then
83 ACTIONS="autogen configure build test install"
85 if [ -z "${BS}" ]; then
86 inputerror "Missing build system (-b) parameter"
88 if [ -z "${BUILDDIR}" ]; then
89 BUILDDIR="${CURDIR}/build_ci/${BS}"
91 mkdir -p "${BUILDDIR}"
92 for action in ${ACTIONS}; do
106 autotools) "${SRCDIR}/configure" ${CONFIGURE_ARGS} ;;
107 cmake) ${CMAKE} ${CONFIGURE_ARGS} "${SRCDIR}" ;;
118 ${MAKE} ${MAKE_ARGS} check LOG_DRIVER="${SRCDIR}/build/ci/test_driver"
121 ${MAKE} ${MAKE_ARGS} test
125 find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \;
128 ${MAKE} ${MAKE_ARGS} install DESTDIR="${BUILDDIR}/destdir"
130 cd ${BUILDDIR}/destdir && ls -lR .
133 ${MAKE} ${MAKE_ARGS} distcheck
137 if [ "${RET}" != "0" ]; then