From 10b342fb7ef673b7f4f609f7121146f1ac9e30c7 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 1 Oct 2017 14:02:31 +0200 Subject: [PATCH] Create frameworks for both iPhone and AppleTV --- assets/AppleTV/Info.plist | 1 + assets/iPhone/Info.plist | 1 + build-libssl.sh | 8 +++--- create-openssl-framework.sh | 57 +++++++++++++++++++++++++------------ 4 files changed, 45 insertions(+), 22 deletions(-) create mode 120000 assets/AppleTV/Info.plist create mode 120000 assets/iPhone/Info.plist diff --git a/assets/AppleTV/Info.plist b/assets/AppleTV/Info.plist new file mode 120000 index 0000000..776c8e5 --- /dev/null +++ b/assets/AppleTV/Info.plist @@ -0,0 +1 @@ +../../OpenSSL-for-tvOS/Info.plist \ No newline at end of file diff --git a/assets/iPhone/Info.plist b/assets/iPhone/Info.plist new file mode 120000 index 0000000..f3fb677 --- /dev/null +++ b/assets/iPhone/Info.plist @@ -0,0 +1 @@ +../../OpenSSL-for-iOS/Info.plist \ No newline at end of file diff --git a/build-libssl.sh b/build-libssl.sh index d7f0d68..5fb7bfa 100755 --- a/build-libssl.sh +++ b/build-libssl.sh @@ -473,15 +473,15 @@ fi # Build iOS library if selected for build if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then echo "Build library for iOS..." - lipo -create ${LIBSSL_IOS[@]} -output "${CURRENTPATH}/lib/libssl.a" - lipo -create ${LIBCRYPTO_IOS[@]} -output "${CURRENTPATH}/lib/libcrypto.a" + lipo -create ${LIBSSL_IOS[@]} -output "${CURRENTPATH}/lib/libssl-iPhone.a" + lipo -create ${LIBCRYPTO_IOS[@]} -output "${CURRENTPATH}/lib/libcrypto-iPhone.a" fi # Build tvOS library if selected for build if [ ${#LIBSSL_TVOS[@]} -gt 0 ]; then echo "Build library for tvOS..." - lipo -create ${LIBSSL_TVOS[@]} -output "${CURRENTPATH}/lib/libssl-tvOS.a" - lipo -create ${LIBCRYPTO_TVOS[@]} -output "${CURRENTPATH}/lib/libcrypto-tvOS.a" + lipo -create ${LIBSSL_TVOS[@]} -output "${CURRENTPATH}/lib/libssl-AppleTV.a" + lipo -create ${LIBCRYPTO_TVOS[@]} -output "${CURRENTPATH}/lib/libcrypto-AppleTV.a" fi # Copy include directory diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index c5ebe2f..1be2e4a 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -1,19 +1,19 @@ #!/bin/bash FWNAME=openssl +FWDIR=frameworks if [ ! -d lib ]; then echo "Please run build-libssl.sh first!" exit 1 fi -if [ -d $FWNAME.framework ]; then - echo "Removing previous $FWNAME.framework copy" - rm -rf $FWNAME.framework +if [ -d $FWDIR ]; then + echo "Removing previous $FWNAME.framework copies" + rm -rf $FWDIR fi -echo "Creating $FWNAME.framework" -mkdir -p $FWNAME.framework/Headers +ALL_SYSTEMS=("iPhone" "AppleTV") if [ "$1" == "dynamic" ]; then DEVELOPER=`xcode-select -print-path` @@ -22,7 +22,6 @@ if [ "$1" == "dynamic" ]; then COMPAT_VERSION="1.0.0" CURRENT_VERSION="1.0.0" - LIBTOOL_FLAGS="-dynamic -lSystem -ios_version_min 8.0" RX='([A-z]+)([0-9]+(\.[0-9]+)*)-([A-z0-9]+)\.sdk' cd bin @@ -39,8 +38,14 @@ if [ "$1" == "dynamic" ]; then CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" SDK="${CROSS_TOP}/SDKs/${CROSS_SDK}" + if [[ $PLATFORM == AppleTV* ]]; then + MIN_SDK="-tvos_version_min 9.0" + else + MIN_SDK="-ios_version_min 8.0" + fi + #cd $TARGETDIR - #libtool $LIBTOOL_FLAGS -L"$SDK/usr/lib/" -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib + #libtool -dynamic -lSystem $MIN_SDK -L"$SDK/usr/lib/" -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib TARGETOBJ="${TARGETDIR}/obj" rm -rf $TARGETOBJ @@ -49,27 +54,43 @@ if [ "$1" == "dynamic" ]; then ar -x ../lib/libcrypto.a ar -x ../lib/libssl.a cd .. - ld obj/*.o -dylib -lSystem -ios_version_min 8.0 -L"$SDK/usr/lib/" -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib + ld obj/*.o -dylib -lSystem $MIN_SDK -L"$SDK/usr/lib/" -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION -application_extension -o $FWNAME.dylib install_name_tool -id $INSTALL_NAME $FWNAME.dylib cd .. done cd .. - lipo -create bin/*/$FWNAME.dylib -output $FWNAME.framework/$FWNAME + for SYS in ${ALL_SYSTEMS[@]}; do + SYSDIR=$FWDIR/$SYS + + # FIXME: skip if no device objects + + echo "Creating framework for $SYS" + mkdir -p $SYSDIR/$FWNAME.framework/Headers + lipo -create bin/${SYS}*/$FWNAME.dylib -output $SYSDIR/$FWNAME.framework/$FWNAME + cp -r include/$FWNAME/* $SYSDIR/$FWNAME.framework/Headers/ + cp -L assets/$SYS/Info.plist $SYSDIR/$FWNAME.framework/Info.plist + echo "Created $SYSDIR/$FWNAME.framework" + done + rm bin/*/$FWNAME.dylib else - LIBTOOL_FLAGS="-static" - libtool $LIBTOOL_FLAGS -o $FWNAME.framework/$FWNAME lib/libcrypto.a lib/libssl.a + for SYS in ${ALL_SYSTEMS[@]}; do + SYSDIR=$FWDIR/$SYS + + # FIXME: skip if no device objects + + echo "Creating framework for $SYS" + mkdir -p $SYSDIR/$FWNAME.framework/Headers + libtool -static -o $SYSDIR/$FWNAME.framework/$FWNAME lib/libcrypto-$SYS.a lib/libssl-$SYS.a + cp -r include/$FWNAME/* $SYSDIR/$FWNAME.framework/Headers/ + cp -L assets/$SYS/Info.plist $SYSDIR/$FWNAME.framework/Info.plist + echo "Created $SYSDIR/$FWNAME.framework" + done fi -cp -r include/$FWNAME/* $FWNAME.framework/Headers/ - -DIR="$(cd "$(dirname "$0")" && pwd)" -cp $DIR/"OpenSSL-for-iOS/OpenSSL-for-iOS-Info.plist" $FWNAME.framework/Info.plist -echo "Created $FWNAME.framework" - -check_bitcode=`otool -arch arm64 -l $FWNAME.framework/$FWNAME | grep __bitcode` +check_bitcode=`otool -arch arm64 -l $FWDIR/iPhone/$FWNAME.framework/$FWNAME | grep __bitcode` if [ -z "$check_bitcode" ] then echo "INFO: $FWNAME.framework doesn't contain Bitcode"