Updated build script error checking.

This commit is contained in:
Armin Novak 2016-08-04 09:02:40 +02:00
parent 3b21209e72
commit 7b5d0d59c9

View File

@ -44,6 +44,16 @@ if [ ! -d "$DEVELOPER" ]; then
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
exit 1
fi
function run {
echo "PATH=$PATH"
$@
local status=$?
if [ $status -ne 0 ]; then
echo "error with $@" >&2
exit $status
fi
return $status
}
# Functions
function buildArch(){
@ -56,32 +66,32 @@ function buildArch(){
PLATFORM="iPhoneOS"
fi
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
run export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
run export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
run export BUILD_TOOLS="${DEVELOPER}"
run export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
if [ ! -z $MIN_SDK_VERSION ]; then
export CC="$CC -miphoneos-version-min=${MIN_SDK_VERSION}"
run export CC="$CC -miphoneos-version-min=${MIN_SDK_VERSION}"
fi
echo "Building openssl-${OPENSSLVERSION} for ${PLATFORM} ${SDK_VERSION} ${ARCH} (min SDK set: ${MIN_SDK_VERSION:-"none"})"
LOGFILE="BuildLog.darwin-${ARCH}.txt"
echo -n " Please wait ..."
if [[ "$OPENSSLVERSION" =~ 1.0.0. ]]; then
./Configure BSD-generic32 > "${LOGFILE}" 2>&1
run ./Configure BSD-generic32 > "${LOGFILE}" 2>&1
elif [ "${ARCH}" == "x86_64" ]; then
./Configure darwin64-x86_64-cc > "${LOGFILE}" 2>&1
run ./Configure darwin64-x86_64-cc > "${LOGFILE}" 2>&1
elif [ "${ARCH}" == "i386" ]; then
./Configure iphoneos-cross no-asm > "${LOGFILE}" 2>&1
run ./Configure iphoneos-cross no-asm > "${LOGFILE}" 2>&1
else
./Configure iphoneos-cross > "${LOGFILE}" 2>&1
run ./Configure iphoneos-cross > "${LOGFILE}" 2>&1
fi
make ${MAKEOPTS} >> ${LOGFILE} 2>&1
run make ${MAKEOPTS} >> ${LOGFILE} 2>&1
echo " Done. Build log saved in ${LOGFILE}"
cp libcrypto.a ../../lib/libcrypto_${ARCH}.a
cp libssl.a ../../lib/libssl_${ARCH}.a
make clean >/dev/null 2>&1
run cp libcrypto.a ../../lib/libcrypto_${ARCH}.a
run cp libssl.a ../../lib/libssl_${ARCH}.a
run make clean >/dev/null 2>&1
}
# main
@ -95,14 +105,14 @@ fi
cd $INSTALLDIR
if [ ! -d openssl ];then
mkdir openssl
run mkdir openssl
fi
cd openssl
run cd openssl
CS=`shasum -a 256 "openssl-$OPENSSLVERSION.tar.gz" | cut -d ' ' -f1`
if [ ! "$CS" = "$SHA256SUM" ]; then
echo "Downloading OpenSSL Version $OPENSSLVERSION ..."
rm -f "openssl-$OPENSSLVERSION.tar.gz"
curl -o "openssl-$OPENSSLVERSION.tar.gz" https://www.openssl.org/source/openssl-$OPENSSLVERSION.tar.gz
run rm -f "openssl-$OPENSSLVERSION.tar.gz"
run curl -o "openssl-$OPENSSLVERSION.tar.gz" https://www.openssl.org/source/openssl-$OPENSSLVERSION.tar.gz
CS=`shasum -a 256 "openssl-$OPENSSLVERSION.tar.gz" | cut -d ' ' -f1`
if [ ! "$CS" = "$SHA256SUM" ]; then
@ -112,19 +122,19 @@ if [ ! "$CS" = "$SHA256SUM" ]; then
fi
# remove old build dir
rm -rf openssltmp
mkdir openssltmp
cd openssltmp
run rm -rf openssltmp
run mkdir openssltmp
run cd openssltmp
echo "Unpacking OpenSSL ..."
tar xfz "../openssl-$OPENSSLVERSION.tar.gz"
run tar xfz "../openssl-$OPENSSLVERSION.tar.gz"
if [ ! $? = 0 ]; then
echo "Unpacking failed."
exit 1
fi
echo
cd "openssl-$OPENSSLVERSION"
run cd "openssl-$OPENSSLVERSION"
case `pwd` in
*\ * )
@ -134,14 +144,14 @@ case `pwd` in
esac
# Cleanup old build artifacts
mkdir -p ../../include/openssl
rm -f ../../include/openssl/*.h
run mkdir -p ../../include/openssl
run rm -f ../../include/openssl/*.h
mkdir -p ../../lib
rm -f ../../lib/*.a
run mkdir -p ../../lib
run rm -f ../../lib/*.a
echo "Copying header files ..."
cp include/openssl/*.h ../../include/openssl/
run cp include/openssl/*.h ../../include/openssl/
echo
for i in ${ARCHS}; do
@ -149,7 +159,7 @@ for i in ${ARCHS}; do
done
echo "Combining to unversal binary"
lipo -create ../../lib/libcrypto_*.a -o ../../lib/libcrypto.a
lipo -create ../../lib/libssl_*.a -o ../../lib/libssl.a
run lipo -create ../../lib/libcrypto_*.a -o ../../lib/libcrypto.a
run lipo -create ../../lib/libssl_*.a -o ../../lib/libssl.a
echo "Finished. Please verify the contens of the openssl folder in \"$INSTALLDIR\""