output log file when lbrycrd build fails

This commit is contained in:
Job Evers-Meltzer 2016-07-15 19:13:53 -05:00
parent 134a1f48f9
commit 3495c9a5b4

View file

@ -30,6 +30,7 @@ CLEAN=false
BUILD_DEPENDENCIES=true
BUILD_LBRYCRD=true
TIMEOUT=false
THREE_MB=3145728
while getopts :crldoth:w:d: FLAG; do
case $FLAG in
@ -151,14 +152,19 @@ function wait_and_echo() {
# and wait until it completed
function background() {
$1 >> "$2" 2>&1 &
wait_and_echo $! "$3"
BACKGROUND_PID=$!
wait_and_echo $BACKGROUND_PID "$3"
}
function cleanup() {
rv=$?
# cat the log file if it exists
if [ -f "$2" ]; then
cat "$2"
echo
echo "Output of log file $2"
echo
tail -c $THREE_MB "$1"
echo
fi
# delete the build directory
rm -rf "$1"
@ -166,6 +172,22 @@ function cleanup() {
exit $rv
}
function cat_and_exit() {
rv=$?
# cat the log file if it exists
if [ -f "$1" ]; then
echo
echo "Output of log file $1"
echo
# log size is limited to 4MB on travis
# so hopefully the last 3MB is enough
# to debug whatever went wrong
tail -c $THREE_MB "$1"
echo
fi
exit $rv
}
function brew_if_not_installed() {
if ! brew ls | grep $1 --quiet; then
brew install $1
@ -298,20 +320,19 @@ function build_lbrycrd() {
else
cd "${SOURCE_DIR}"
fi
./autogen.sh
./autogen.sh > "${LBRYCRD_LOG}" 2>&1
LDFLAGS="-L${OPENSSL_PREFIX}/lib/ -L${BDB_PREFIX}/lib/ -L${LIBEVENT_PREFIX}/lib/ -static-libstdc++"
CPPFLAGS="-I${OPENSSL_PREFIX}/include -I${BDB_PREFIX}/include -I${LIBEVENT_PREFIX}/include/"
if [ "${OS_NAME}" = "osx" ]; then
./configure --without-gui --enable-cxx --enable-static --disable-shared --with-pic \
OPTIONS="--enable-cxx --enable-static --disable-shared --with-pic"
else
OPTIONS=""
fi
./configure --without-gui ${OPTIONS} \
--with-boost="${BOOST_PREFIX}" \
LDFLAGS="${LDFLAGS}" \
CPPFLAGS="${CPPFLAGS}"
else
./configure --without-gui --with-boost="${BOOST_PREFIX}" \
LDFLAGS="${LDFLAGS}" \
CPPFLAGS="${CPPFLAGS}"
fi
make
CPPFLAGS="${CPPFLAGS}" >> "${LBRYCRD_LOG}" 2>&1
background make "${LBRYCRD_LOG}" "Waiting for lbrycrd to finish building"
# tests don't work on OSX. Should definitely figure out why
# that is but, for now, not letting that stop the rest
# of the build
@ -344,5 +365,7 @@ set -u
if [ "${BUILD_LBRYCRD}" = true ]; then
LBRYCRD_LOG="${LOG_DIR}/lbrycrd_build.log"
echo "Building lbrycrd. tail -f ${LBRYCRD_LOG} to see the details and monitor progress"
background build_lbrycrd "${LBRYCRD_LOG}" "Waiting for lbrycrd to finish building"
trap 'cat_and_exit "${LBRYCRD_LOG}"' INT TERM EXIT
build_lbrycrd
trap - INT TERM EXIT
fi