Merge branch 'watchos-targets'

This commit is contained in:
Davide De Rosa 2019-09-26 09:40:46 +02:00
commit 039d71c2b3
17 changed files with 134 additions and 24 deletions

0
Gemfile Normal file → Executable file
View File

0
Gemfile.lock Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
OPENSSL-LICENSE Normal file → Executable file
View File

0
OpenSSL-Apple.podspec.template Normal file → Executable file
View File

2
README.md Normal file → Executable file
View File

@ -9,7 +9,7 @@
This is a fork of the popular work by [Felix Schulze](https://github.com/x2on), that is a set of scripts for using self-compiled builds of the OpenSSL library on the iPhone and the Apple TV.
However, this repository focuses more on framework-based setups and also adds macOS support.
However, this repository focuses more on framework-based setups and also adds macOS and watchOS support.
# Compile library

0
assets/AppleTV/Info.plist Normal file → Executable file
View File

0
assets/MacOSX/Info.plist Normal file → Executable file
View File

24
assets/WatchOS/Info.plist Executable file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>openssl</string>
<key>CFBundleIdentifier</key>
<string>org.openssl.OpenSSL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>openssl</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>MinimumOSVersion</key>
<string>4.0</string>
</dict>
</plist>

0
assets/iPhone/Info.plist Normal file → Executable file
View File

View File

@ -30,13 +30,14 @@ DEFAULTVERSION="1.1.0i"
# Default (=full) set of architectures (OpenSSL <= 1.0.2) or targets (OpenSSL >= 1.1.0) to build
#DEFAULTARCHS="ios_x86_64 ios_arm64 ios_armv7s ios_armv7 tv_x86_64 tv_arm64 mac_x86_64"
#DEFAULTTARGETS="ios-sim-cross-x86_64 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 tvos-sim-cross-x86_64 tvos64-cross-arm64 macos64-x86_64"
DEFAULTARCHS="ios_x86_64 ios_arm64 tv_x86_64 tv_arm64 mac_x86_64"
DEFAULTTARGETS="ios-sim-cross-x86_64 ios64-cross-arm64 tvos-sim-cross-x86_64 tvos64-cross-arm64 macos64-x86_64"
DEFAULTARCHS="ios_x86_64 ios_arm64 tv_x86_64 tv_arm64 mac_x86_64 watchos_armv7k watchos_arm64_32 watchos_i386"
DEFAULTTARGETS="ios-sim-cross-x86_64 ios64-cross-arm64 tvos-sim-cross-x86_64 tvos64-cross-arm64 macos64-x86_64 watchos-cross-armv7k watchos-cross-arm64_32 watchos-sim-cross-i386"
# Minimum iOS/tvOS SDK version to build for
MACOS_MIN_SDK_VERSION="10.11"
IOS_MIN_SDK_VERSION="11.0"
TVOS_MIN_SDK_VERSION="11.0"
WATCHOS_MIN_SDK_VERSION="4.0"
# Init optional env variables (use available variable or default to empty string)
CURL_OPTIONS="${CURL_OPTIONS:-}"
@ -54,7 +55,7 @@ echo_help()
echo " --ios-sdk=SDKVERSION Override iOS SDK version"
echo " --noparallel Disable running make with parallel jobs (make -j)"
echo " --tvos-sdk=SDKVERSION Override tvOS SDK version"
#echo " --disable-bitcode Disable embedding Bitcode"
echo " --disable-bitcode Disable embedding Bitcode"
echo " -v, --verbose Enable verbose logging"
echo " --verbose-on-error Dump last 500 lines from log file if an error occurs (for Travis builds)"
echo " --version=VERSION OpenSSL version to build (defaults to ${DEFAULTVERSION})"
@ -172,6 +173,10 @@ finish_build_loop()
LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="tvos_${ARCH}"
elif [[ "${PLATFORM}" == Watch* ]]; then
LIBSSL_WATCHOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_WATCHOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="watchos_${ARCH}"
elif [[ "${PLATFORM}" == iPhone* ]]; then
LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a")
@ -202,6 +207,7 @@ CONFIG_DISABLE_BITCODE=""
CONFIG_NO_DEPRECATED=""
MACOS_SDKVERSION=""
IOS_SDKVERSION=""
WATCHOS_SDKVERSION=""
LOG_VERBOSE=""
PARALLEL=""
TARGETS=""
@ -229,9 +235,9 @@ case $i in
--ec-nistp-64-gcc-128)
CONFIG_ENABLE_EC_NISTP_64_GCC_128="true"
;;
#--disable-bitcode)
# CONFIG_DISABLE_BITCODE="true"
# ;;
--disable-bitcode)
CONFIG_DISABLE_BITCODE="true"
;;
-h|--help)
echo_help
exit
@ -255,6 +261,10 @@ case $i in
TVOS_SDKVERSION="${i#*=}"
shift
;;
--watchos-sdk=*)
WATCHOS_SDKVERSION="${i#*=}"
shift
;;
-v|--verbose)
LOG_VERBOSE="verbose"
;;
@ -349,6 +359,9 @@ fi
if [ ! -n "${TVOS_SDKVERSION}" ]; then
TVOS_SDKVERSION=$(xcrun -sdk appletvos --show-sdk-version)
fi
if [ ! -n "${WATCHOS_SDKVERSION}" ]; then
WATCHOS_SDKVERSION=$(xcrun -sdk watchos --show-sdk-version)
fi
# Determine number of cores for (parallel) build
BUILD_THREADS=1
@ -399,6 +412,7 @@ fi
echo " macOS SDK: ${MACOS_SDKVERSION}"
echo " iOS SDK: ${IOS_SDKVERSION}"
echo " tvOS SDK: ${TVOS_SDKVERSION}"
echo " watchOS SDK: ${WATCHOS_SDKVERSION}"
if [ "${CONFIG_DISABLE_BITCODE}" == "true" ]; then
echo " Bitcode embedding disabled"
fi
@ -481,6 +495,8 @@ LIBSSL_IOS=()
LIBCRYPTO_IOS=()
LIBSSL_TVOS=()
LIBCRYPTO_TVOS=()
LIBSSL_WATCHOS=()
LIBCRYPTO_WATCHOS=()
# Run relevant build loop (archs = 1.0 style, targets = 1.1 style)
if [ "${BUILD_TYPE}" == "archs" ]; then
@ -489,7 +505,7 @@ else
source "${SCRIPTDIR}/scripts/build-loop-targets.sh"
fi
# Build macOS library if selected for build
#Build macOS library if selected for build
if [ ${#LIBSSL_MACOS[@]} -gt 0 ]; then
echo "Build library for macOS..."
lipo -create ${LIBSSL_MACOS[@]} -output "${CURRENTPATH}/lib/libssl-MacOSX.a"
@ -510,6 +526,13 @@ if [ ${#LIBSSL_TVOS[@]} -gt 0 ]; then
lipo -create ${LIBCRYPTO_TVOS[@]} -output "${CURRENTPATH}/lib/libcrypto-AppleTV.a"
fi
# Build tvOS library if selected for build
if [ ${#LIBSSL_WATCHOS[@]} -gt 0 ]; then
echo "Build library for watchOS..."
lipo -create ${LIBSSL_WATCHOS[@]} -output "${CURRENTPATH}/lib/libssl-WatchOS.a"
lipo -create ${LIBCRYPTO_WATCHOS[@]} -output "${CURRENTPATH}/lib/libcrypto-WatchOS.a"
fi
# Copy include directory
cp -R "${INCLUDE_DIR}" "${CURRENTPATH}/include/"
@ -558,6 +581,15 @@ if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then
*_tvos_arm64.h)
DEFINE_CONDITION="TARGET_OS_TV && TARGET_OS_EMBEDDED && TARGET_CPU_ARM64"
;;
*_watchos_armv7k.h)
DEFINE_CONDITION="TARGET_OS_WATCHOS && TARGET_OS_EMBEDDED && TARGET_CPU_ARMV7K"
;;
*_watchos_arm64_32.h)
DEFINE_CONDITION="TARGET_OS_WATCHOS && TARGET_OS_EMBEDDED && TARGET_CPU_ARM64_32"
;;
*_watchos_i386.h)
DEFINE_CONDITION="TARGET_OS_SIMULATOR && TARGET_CPU_X86 || TARGET_OS_EMBEDDED"
;;
*)
# Don't run into unexpected cases by setting the default condition to false
DEFINE_CONDITION="0"
@ -583,4 +615,3 @@ if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then
fi
echo "Done."

32
config/20-all-platforms.conf Normal file → Executable file
View File

@ -12,7 +12,7 @@
? '-fembed-bitcode' : (); },
),
},
## Base settings for iOS
"ios-cross-base" => {
inherit_from => [ "all-base" ],
@ -36,6 +36,36 @@
cflags => add(sub { defined($ENV{'MACOS_MIN_SDK_VERSION'}) ? '-mmacosx-version-min=$(MACOS_MIN_SDK_VERSION)' : '-mmacosx-version-min=10.11'; }),
},
## Apple WatchOS
## Base settings for iOS
"watchos-cross-base" => {
inherit_from => [ "all-base" ],
template => 1,
cflags => add(sub { defined($ENV{'WATCH_MIN_SDK_VERSION'}) ? '-mwatchos-version-min=$(WATCH_MIN_SDK_VERSION)' : '-mwatchos-version-min=4.0'; }),
},
"watchos-cross-armv7k" => {
inherit_from => [ "darwin-common", "watchos-cross-base", asm("armv7_asm") ],
cflags => add("-arch armv7k -fembed-bitcode"),
defines => [ "HAVE_FORK=0" ],
sys_id => "WatchOS",
},
"watchos-cross-arm64_32" => {
inherit_from => [ "darwin-common", "watchos-cross-base"],
cflags => add("-arch arm64_32 -fembed-bitcode"),
defines => [ "HAVE_FORK=0" ],
sys_id => "WatchOS",
},
"watchos-sim-cross-i386" => {
inherit_from => [ "darwin-common", "watchos-cross-base"],
cflags => add("-arch i386 -fembed-bitcode"),
defines => [ "HAVE_FORK=0" ],
sys_id => "WatchOS",
},
## Apple iOS simulator (x86_64)
# Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc
"ios-sim-cross-x86_64" => {

View File

@ -21,22 +21,22 @@ if [ -d $FWROOT ]; then
rm -rf $FWROOT
fi
ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX")
ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX" "WatchOS")
function check_bitcode() {
local FWDIR=$1
if [[ $FWTYPE == "dynamic" ]]; then
BITCODE_PATTERN="__LLVM"
BITCODE_PATTERN="__LLVM"
else
BITCODE_PATTERN="__bitcode"
fi
BITCODE_PATTERN="__bitcode"
fi
if otool -l "$FWDIR/$FWNAME" | grep "${BITCODE_PATTERN}" >/dev/null; then
echo "INFO: $FWDIR contains Bitcode"
else
echo "INFO: $FWDIR doesn't contain Bitcode"
fi
if otool -l "$FWDIR/$FWNAME" | grep "${BITCODE_PATTERN}" >/dev/null; then
echo "INFO: $FWDIR contains Bitcode"
else
echo "INFO: $FWDIR doesn't contain Bitcode"
fi
}
if [ $FWTYPE == "dynamic" ]; then
@ -70,6 +70,10 @@ if [ $FWTYPE == "dynamic" ]; then
MIN_SDK="-macosx_version_min 10.11"
elif [[ $PLATFORM == iPhoneSimulator* ]]; then
MIN_SDK="-ios_simulator_version_min 11.0"
elif [[ $PLATFORM == WatchOS* ]]; then
MIN_SDK="-watchos_version_min 4.0"
elif [[ $PLATFORM == WatchSimulator* ]]; then
MIN_SDK="-watchos_simulator_version_min 4.0"
else
MIN_SDK="-ios_version_min 11.0"
fi

0
include/LICENSE Normal file → Executable file
View File

0
include/opensslconf-template.h Normal file → Executable file
View File

24
scripts/build-loop-archs.sh Executable file → Normal file
View File

@ -26,6 +26,8 @@ do
SDKVERSION=${TVOS_SDKVERSION}
elif [[ "$ARCH" == mac* ]]; then
SDKVERSION=${MACOS_SDKVERSION}
elif [[ "$ARCH" == watchos* ]]; then
SDKVERSION=${WATCHOS_SDKVERSION}
else
SDKVERSION=${IOS_SDKVERSION}
fi
@ -39,6 +41,10 @@ do
PLATFORM="AppleTVOS"
elif [[ "${ARCH}" == "mac_x86_64" || "${ARCH}" == "mac_i386" ]]; then
PLATFORM="MacOSX"
elif [[ "${ARCH}" == "watchos_arm64_32" || "${ARCH}" == "watchos_armv7k" ]]; then
PLATFORM="WatchOS"
elif [[ "${ARCH}" == "watchos_i386" ]]; then
PLATFORM="WatchSimulator"
else
PLATFORM="iPhoneOS"
fi
@ -65,11 +71,8 @@ do
esac
fi
# Embed bitcode for SDK >= 9
if [ "${CONFIG_DISABLE_BITCODE}" != "true" ]; then
if [[ "${SDKVERSION}" == 9.* || "${SDKVERSION}" == [0-9][0-9].* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -fembed-bitcode"
fi
fi
# Add platform specific config options
@ -77,6 +80,14 @@ do
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -DHAVE_FORK=0 -mtvos-version-min=${TVOS_MIN_SDK_VERSION}"
echo " Patching Configure..."
LC_ALL=C sed -i -- 's/D\_REENTRANT\:iOS/D\_REENTRANT\:tvOS/' "./Configure"
elif [[ "${PLATFORM}" == WatchOS* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -DHAVE_FORK=0 -mwatchos-version-min=${WATCHOS_MIN_SDK_VERSION}"
echo " Patching Configure..."
LC_ALL=C sed -i -- 's/D\_REENTRANT\:iOS/D\_REENTRANT\:WatchOS/' "./Configure"
elif [[ "${PLATFORM}" == WatchSimulator* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -DHAVE_FORK=0 -mwatchos-version-min=${WATCHOS_MIN_SDK_VERSION}"
echo " Patching Configure..."
LC_ALL=C sed -i -- 's/D\_REENTRANT\:iOS/D\_REENTRANT\:WatchOS/' "./Configure"
elif [[ "${PLATFORM}" == MacOSX* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -mmacosx-version-min=${MACOS_MIN_SDK_VERSION}"
else
@ -87,8 +98,10 @@ do
LOCAL_CONFIG_OPTIONS="--openssldir=${TARGETDIR} ${LOCAL_CONFIG_OPTIONS}"
# Determine configure target
if [ "${ARCH}" == "x86_64" ]; then
if [[ "${ARCH}" == "x86_64" ]]; then
LOCAL_CONFIG_OPTIONS="darwin64-x86_64-cc no-asm ${LOCAL_CONFIG_OPTIONS}"
elif [[ "${ARCH}" == "watchos_i386" ]]; then
LOCAL_CONFIG_OPTIONS="darwin-i386-cc no-asm ${LOCAL_CONFIG_OPTIONS}"
else
LOCAL_CONFIG_OPTIONS="iphoneos-cross ${LOCAL_CONFIG_OPTIONS}"
fi
@ -97,7 +110,7 @@ do
run_configure
# Only required for Darwin64 builds (-isysroot is automatically added by iphoneos-cross target)
if [ "${ARCH}" == "x86_64" ]; then
if [[ "${ARCH}" == "x86_64" || "${ARCH}" == "watchos_i386" ]]; then
echo " Patching Makefile..."
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} !" "Makefile"
fi
@ -129,4 +142,5 @@ do
# Remove source dir, add references to library files to relevant arrays
# Keep reference to first build target for include file
finish_build_loop
done

View File

@ -26,6 +26,8 @@ do
SDKVERSION="${TVOS_SDKVERSION}"
elif [[ "${TARGET}" == macos* ]]; then
SDKVERSION="${MACOS_SDKVERSION}"
elif [[ "${TARGET}" == watchos* ]]; then
SDKVERSION="${WATCHOS_SDKVERSION}"
else
SDKVERSION="${IOS_SDKVERSION}"
fi
@ -35,6 +37,7 @@ do
export MACOS_MIN_SDK_VERSION
export IOS_MIN_SDK_VERSION
export TVOS_MIN_SDK_VERSION
export WATCHOS_MIN_SDK_VERSION
export CONFIG_DISABLE_BITCODE
# Determine platform
@ -46,6 +49,10 @@ do
PLATFORM="AppleTVOS"
elif [[ "${TARGET}" == "macos"* ]]; then
PLATFORM="MacOSX"
elif [[ "${TARGET}" == "watchos-sim-cross"* ]]; then
PLATFORM="WatchSimulator"
elif [[ "${TARGET}" == "watchos"* ]]; then
PLATFORM="WatchOS"
else
PLATFORM="iPhoneOS"
fi