Allow build of subset of archs: make lipo arguments dynamic and copy include files from first built ARCH

This commit is contained in:
Anton Tieleman 2016-09-17 14:54:55 +02:00
parent 762bbc82d4
commit 0f2afa24af
1 changed files with 47 additions and 35 deletions

View File

@ -51,7 +51,7 @@ spinner()
} }
CURRENTPATH=`pwd` CURRENTPATH=`pwd`
ARCHS="i386 x86_64 armv7 armv7s arm64 tv_x86_64 tv_arm64" ARCHS="x86_64 i386 arm64 armv7s armv7 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"
@ -93,6 +93,13 @@ mkdir -p "${CURRENTPATH}/src"
mkdir -p "${CURRENTPATH}/bin" mkdir -p "${CURRENTPATH}/bin"
mkdir -p "${CURRENTPATH}/lib" mkdir -p "${CURRENTPATH}/lib"
# Init vars for library references
INCLUDE_DIR=""
LIBSSL_IOS=()
LIBCRYPTO_IOS=()
LIBSSL_TVOS=()
LIBCRYPTO_TVOS=()
for ARCH in ${ARCHS} for ARCH in ${ARCHS}
do do
if [[ "$ARCH" == tv* ]]; then if [[ "$ARCH" == tv* ]]; then
@ -120,11 +127,14 @@ do
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}" export BUILD_TOOLS="${DEVELOPER}"
mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" # Prepare target dir
LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-openssl-${VERSION}.log" TARGETDIR="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
mkdir -p "${TARGETDIR}"
LOG="${TARGETDIR}/build-openssl-${VERSION}.log"
echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}..."
echo " Logfile: ${LOG}"
echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}"
echo " Logfile: $LOG"
LOCAL_CONFIG_OPTIONS="${CONFIG_OPTIONS}" LOCAL_CONFIG_OPTIONS="${CONFIG_OPTIONS}"
if [ "${ENABLE_EC_NISTP_64_GCC_128}" == "true" ]; then if [ "${ENABLE_EC_NISTP_64_GCC_128}" == "true" ]; then
@ -164,15 +174,15 @@ do
set +e set +e
if [ "$1" == "verbose" ]; then if [ "$1" == "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="${TARGETDIR}" ${LOCAL_CONFIG_OPTIONS}
else else
./Configure iphoneos-cross --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" ${LOCAL_CONFIG_OPTIONS} ./Configure iphoneos-cross --openssldir="${TARGETDIR}" ${LOCAL_CONFIG_OPTIONS}
fi fi
else else
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} > "${LOG}" 2>&1) & spinner (./Configure no-asm darwin64-x86_64-cc --openssldir="${TARGETDIR}" ${LOCAL_CONFIG_OPTIONS} > "${LOG}" 2>&1) & spinner
else else
(./Configure iphoneos-cross --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" ${LOCAL_CONFIG_OPTIONS} > "${LOG}" 2>&1) & spinner (./Configure iphoneos-cross --openssldir="${TARGETDIR}" ${LOCAL_CONFIG_OPTIONS} > "${LOG}" 2>&1) & spinner
fi fi
fi fi
@ -219,35 +229,37 @@ do
fi fi
rm -rf "$src_work_dir" rm -rf "$src_work_dir"
# Add references to library files to relevant arrays
if [[ "${PLATFORM}" == AppleTV* ]]; then
LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a")
else
LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a")
fi
# Keep reference to first build target for include file
if [ -z "${INCLUDE_DIR}" ]; then
INCLUDE_DIR="${TARGETDIR}/include/openssl"
fi
done done
# Build iOS library if selected for build
if [ ${#LIBSSL_IOS} -gt 0 ]; then
echo "Build library for iOS..." echo "Build library for iOS..."
lipo -create \ lipo -create ${LIBSSL_IOS[@]} -output "${CURRENTPATH}/lib/libssl.a"
${CURRENTPATH}/bin/iPhoneSimulator${IOS_SDKVERSION}-i386.sdk/lib/libssl.a \ lipo -create ${LIBCRYPTO_IOS[@]} -output "${CURRENTPATH}/lib/libcrypto.a"
${CURRENTPATH}/bin/iPhoneSimulator${IOS_SDKVERSION}-x86_64.sdk/lib/libssl.a \ fi
${CURRENTPATH}/bin/iPhoneOS${IOS_SDKVERSION}-armv7.sdk/lib/libssl.a \
${CURRENTPATH}/bin/iPhoneOS${IOS_SDKVERSION}-armv7s.sdk/lib/libssl.a \
${CURRENTPATH}/bin/iPhoneOS${IOS_SDKVERSION}-arm64.sdk/lib/libssl.a \
-output ${CURRENTPATH}/lib/libssl.a
lipo -create \
${CURRENTPATH}/bin/iPhoneSimulator${IOS_SDKVERSION}-i386.sdk/lib/libcrypto.a \
${CURRENTPATH}/bin/iPhoneSimulator${IOS_SDKVERSION}-x86_64.sdk/lib/libcrypto.a \
${CURRENTPATH}/bin/iPhoneOS${IOS_SDKVERSION}-armv7.sdk/lib/libcrypto.a \
${CURRENTPATH}/bin/iPhoneOS${IOS_SDKVERSION}-armv7s.sdk/lib/libcrypto.a \
${CURRENTPATH}/bin/iPhoneOS${IOS_SDKVERSION}-arm64.sdk/lib/libcrypto.a \
-output ${CURRENTPATH}/lib/libcrypto.a
# Build tvOS library if selected for build
if [ ${#LIBSSL_TVOS} -gt 0 ] ; then
echo "Build library for tvOS..." echo "Build library for tvOS..."
lipo -create \ lipo -create ${LIBSSL_TVOS[@]} -output "${CURRENTPATH}/lib/libssl-tvOS.a"
${CURRENTPATH}/bin/AppleTVSimulator${TVOS_SDKVERSION}-x86_64.sdk/lib/libssl.a \ lipo -create ${LIBCRYPTO_TVOS[@]} -output "${CURRENTPATH}/lib/libcrypto-tvOS.a"
${CURRENTPATH}/bin/AppleTVOS${TVOS_SDKVERSION}-arm64.sdk/lib/libssl.a \ fi
-output ${CURRENTPATH}/lib/libssl-tvOS.a
lipo -create \
${CURRENTPATH}/bin/AppleTVSimulator${TVOS_SDKVERSION}-x86_64.sdk/lib/libcrypto.a \
${CURRENTPATH}/bin/AppleTVOS${TVOS_SDKVERSION}-arm64.sdk/lib/libcrypto.a \
-output ${CURRENTPATH}/lib/libcrypto-tvOS.a
mkdir -p ${CURRENTPATH}/include # Copy include directory
cp -R ${CURRENTPATH}/bin/iPhoneSimulator${IOS_SDKVERSION}-x86_64.sdk/include/openssl ${CURRENTPATH}/include/ cp -R "${INCLUDE_DIR}" ${CURRENTPATH}/include/
echo "Done." echo "Done."