Fix error handling for non-verbose mode, add verbose-on-error

- Error handling was broken since spinner() did not return the status of the command that was executed.
- New option verbose-on-error to limit output, but still log in case of errors (for Travis builds)
- Check for errors during make depend
- Also log to file for verbose builds
- Remove make clean since the full build directory is removed anyway
- Make spinner cursor less nervous
This commit is contained in:
Anton Tieleman 2016-09-18 00:34:08 +02:00
parent 762bbc82d4
commit 74c4341f71
2 changed files with 66 additions and 32 deletions

View File

@ -1,7 +1,7 @@
osx_image: xcode7.3 osx_image: xcode7.3
language: objective-c language: objective-c
before_install: before_install:
- ./build-libssl.sh verbose - ./build-libssl.sh verbose-on-error
- xcrun -sdk iphoneos lipo -info ./lib/*.a - xcrun -sdk iphoneos lipo -info ./lib/*.a
- ./create-openssl-framework.sh - ./create-openssl-framework.sh
- xcrun -sdk iphoneos lipo -info openssl.framework/openssl - xcrun -sdk iphoneos lipo -info openssl.framework/openssl

View File

@ -42,12 +42,38 @@ spinner()
local spinstr='|/-\' local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?} local temp=${spinstr#?}
printf " [%c] " "$spinstr" printf " [%c]" "$spinstr"
local spinstr=$temp${spinstr%"$temp"} local spinstr=$temp${spinstr%"$temp"}
sleep $delay sleep $delay
printf "\b\b\b\b\b\b" printf "\b\b\b\b"
done done
printf " \b\b\b\b" printf " \b\b"
wait $pid
return $?
}
# Check for error status
check_status()
{
local STATUS=$1
local COMMAND=$2
echo "\n"
if [ "${STATUS}" != 0 ]; then
if [[ "${LOG_VERBOSE}" != "verbose"* ]]; then
echo "Problem during ${COMMAND} - Please check ${LOG}"
fi
# Dump last 500 lines from log file for verbose-on-error
if [ "${LOG_VERBOSE}" == "verbose-on-error" ]; then
echo "Problem during ${COMMAND} - Dumping last 500 lines from log file"
echo
tail -n 500 "${LOG}"
fi
exit 1
fi
} }
CURRENTPATH=`pwd` CURRENTPATH=`pwd`
@ -55,6 +81,7 @@ ARCHS="i386 x86_64 armv7 armv7s arm64 tv_x86_64 tv_arm64"
DEVELOPER=`xcode-select -print-path` DEVELOPER=`xcode-select -print-path`
IOS_MIN_SDK_VERSION="7.0" IOS_MIN_SDK_VERSION="7.0"
TVOS_MIN_SDK_VERSION="9.0" TVOS_MIN_SDK_VERSION="9.0"
LOG_VERBOSE="$1" # Options: verbose (full output) or verbose-on-error (echo last 500 logged lines when error occurs)
if [ ! -d "$DEVELOPER" ]; then if [ ! -d "$DEVELOPER" ]; then
echo "xcode path is not set correctly $DEVELOPER does not exist" echo "xcode path is not set correctly $DEVELOPER does not exist"
@ -79,7 +106,11 @@ case $CURRENTPATH in
;; ;;
esac esac
set -e # -e Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)
# -o pipefail Causes a pipeline to return the exit status of the last command in the pipe that returned a non-zero return value
set -eo pipefail
# Download OpenSSL when not present
OPENSSL_ARCHIVE_BASE_NAME=OpenSSL_${VERSION//./_} OPENSSL_ARCHIVE_BASE_NAME=OpenSSL_${VERSION//./_}
OPENSSL_ARCHIVE_FILE_NAME=${OPENSSL_ARCHIVE_BASE_NAME}.tar.gz OPENSSL_ARCHIVE_FILE_NAME=${OPENSSL_ARCHIVE_BASE_NAME}.tar.gz
if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then
@ -160,13 +191,14 @@ do
sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c" sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
fi fi
# Run Configure
echo " Configure...\c" echo " Configure...\c"
set +e set +e
if [ "$1" == "verbose" ]; then if [ "${LOG_VERBOSE}" == "verbose" ]; then
if [ "${ARCH}" == "x86_64" ]; then if [ "${ARCH}" == "x86_64" ]; then
./Configure no-asm darwin64-x86_64-cc --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" ${LOCAL_CONFIG_OPTIONS} ./Configure no-asm darwin64-x86_64-cc --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" ${LOCAL_CONFIG_OPTIONS} | tee "${LOG}"
else else
./Configure iphoneos-cross --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" ${LOCAL_CONFIG_OPTIONS} ./Configure iphoneos-cross --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" ${LOCAL_CONFIG_OPTIONS} | tee "${LOG}"
fi fi
else else
if [ "${ARCH}" == "x86_64" ]; then if [ "${ARCH}" == "x86_64" ]; then
@ -176,12 +208,10 @@ do
fi fi
fi fi
if [ $? != 0 ]; then # Check for error status
echo "Problem while configure - Please check ${LOG}" check_status $? "Configure"
exit 1
fi
echo "\n Patch Makefile..." echo " Patch Makefile..."
# add -isysroot to CC= # add -isysroot to CC=
if [[ "${PLATFORM}" == "AppleTVSimulator" || "${PLATFORM}" == "AppleTVOS" ]]; then if [[ "${PLATFORM}" == "AppleTVSimulator" || "${PLATFORM}" == "AppleTVOS" ]]; then
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -mtvos-version-min=${TVOS_MIN_SDK_VERSION} !" "Makefile" sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -mtvos-version-min=${TVOS_MIN_SDK_VERSION} !" "Makefile"
@ -189,35 +219,39 @@ do
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${MIN_SDK_VERSION} !" "Makefile" sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${MIN_SDK_VERSION} !" "Makefile"
fi fi
echo " Make...\c" # Run make depend if relevant
if [[ ! -z "${CONFIG_OPTIONS}" ]]; then
if [ "$1" == "verbose" ]; then echo " Make depend...\c"
if [[ ! -z $CONFIG_OPTIONS ]]; then if [ "${LOG_VERBOSE}" == "verbose" ]; then
make depend make depend | tee -a "${LOG}"
fi
make
else else
if [[ ! -z $CONFIG_OPTIONS ]]; then (make depend >> "${LOG}" 2>&1) & spinner
make depend >> "${LOG}" 2>&1
fi fi
# Check for error status
check_status $? "make depend"
fi
# Run make
echo " Make...\c"
if [ "${LOG_VERBOSE}" == "verbose" ]; then
make | tee -a "${LOG}"
else
(make >> "${LOG}" 2>&1) & spinner (make >> "${LOG}" 2>&1) & spinner
fi fi
echo "\n"
if [ $? != 0 ]; then # Check for error status
echo "Problem while make - Please check ${LOG}" check_status $? "make"
exit 1
fi
# Run make install
set -e set -e
if [ "$1" == "verbose" ]; then if [ "${LOG_VERBOSE}" == "verbose" ]; then
make install_sw make install_sw | tee -a "${LOG}"
make clean
else else
make install_sw >> "${LOG}" 2>&1 make install_sw >> "${LOG}" 2>&1
make clean >> "${LOG}" 2>&1
fi fi
# Remove source dir
rm -rf "$src_work_dir" rm -rf "$src_work_dir"
done done