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
|
#!/bin/bash
# Create the build system, configure a out-of-source build and run the build
# once there.
handle_exit() {
local FOUND_FILE
local FILE_NAME
FOUND_FILE=0
for FILE_NAME in teg*test.log
do
if test -e "$FILE_NAME"
then
FOUND_FILE=1
echo "---8<----8<----8<----8<----8<- $FILE_NAME ---8<----8<----8<----8<-"
cat "$FILE_NAME"
fi
done
if test "$FOUND_FILE" = "0"
then
echo "No test log found" >&2
fi
exit "${EXIT_CODE}"
}
teg_build(){
local BUILD_DIR="$1"
rm -rf "${BUILD_DIR}"
mkdir "${BUILD_DIR}"
cd "${BUILD_DIR}"
# Make sure that the build artifacts are not sneaking into the VCS
echo '*' > .gitignore
# Currently teg needs to know the run time path during configuration.
# See issue #21
"${SCRIPT_DIR}/configure" --enable-warnings-as-errors --enable-maintainer-mode "--prefix=${PWD}/DD" "CFLAGS=-Wall -Wextra"
set +e
# We need to do some work regardless if make succeedes or fails. So here we
# don't stop on a failure, but preserve the exit code for later usage.
make all check
EXIT_CODE="$?"
set -e
}
# ===========================================================================
set -o errexit # script exit when a command fails ( add "... || true" to allow fail)
set -o nounset # script exit when it use undeclared variables
set -o pipefail # exit status of last command that throws a non-zero exit code
trap handle_exit 0 SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
# if we called the script via a symbolic link
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
readonly SCRIPT_DIR
EXIT_CODE=23
# create the autotools build machinery.
bash -eu autogen.sh
# build the software
# the default build directory is TOP_SRCDIR/bd, but can be overridden on the
# command line.
teg_build "$SCRIPT_DIR/${1:-bd}"
|