Merge pull request #23 from keeshux/support-mac-catalyst

Add macOS Catalyst support
This commit is contained in:
Davide De Rosa 2020-11-12 16:43:46 +01:00 committed by GitHub
commit 41e15eb577
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 94 additions and 8 deletions

View File

@ -3,6 +3,7 @@
![iOS support](https://img.shields.io/badge/iOS-11+-blue.svg) ![iOS support](https://img.shields.io/badge/iOS-11+-blue.svg)
![tvOS support](https://img.shields.io/badge/tvOS-11+-blue.svg) ![tvOS support](https://img.shields.io/badge/tvOS-11+-blue.svg)
![macOS support](https://img.shields.io/badge/macOS-10.11+-blue.svg) ![macOS support](https://img.shields.io/badge/macOS-10.11+-blue.svg)
![macOS Catalyst support](https://img.shields.io/badge/macOS%20Catalyst-10.15+-blue.svg)
![watchOS support](https://img.shields.io/badge/watchOS-4.0+-blue.svg) ![watchOS support](https://img.shields.io/badge/watchOS-4.0+-blue.svg)
![OpenSSL version](https://img.shields.io/badge/OpenSSL-1.1.1g-green.svg) ![OpenSSL version](https://img.shields.io/badge/OpenSSL-1.1.1g-green.svg)
[![license](https://img.shields.io/badge/license-Apache%202.0-lightgrey.svg)](LICENSE) [![license](https://img.shields.io/badge/license-Apache%202.0-lightgrey.svg)](LICENSE)

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>10.15</string>
</dict>
</plist>

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Automatic build script for libssl and libcrypto # Automatic build script for libssl and libcrypto
# for iPhoneOS and iPhoneSimulator # for Apple devices.
# #
# Created by Felix Schulze on 16.12.10. # Created by Felix Schulze on 16.12.10.
# Copyright 2010-2017 Felix Schulze. All rights reserved. # Copyright 2010-2017 Felix Schulze. All rights reserved.
@ -28,13 +28,13 @@ set -u
DEFAULTVERSION="1.1.1h" DEFAULTVERSION="1.1.1h"
# Default (=full) set of targets (OpenSSL >= 1.1.1) to build # Default (=full) set of targets (OpenSSL >= 1.1.1) to build
#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" DEFAULTTARGETS="ios-sim-cross-x86_64 ios64-cross-arm64 ios64-cross-arm64e tvos-sim-cross-x86_64 tvos64-cross-arm64 macos64-x86_64 watchos-cross-armv7k watchos-cross-arm64_32 watchos-sim-cross-i386 watchos-sim-cross-x86_64 mac-catalyst-x86_64"
DEFAULTTARGETS="ios-sim-cross-x86_64 ios64-cross-arm64 ios64-cross-arm64e tvos-sim-cross-x86_64 tvos64-cross-arm64 macos64-x86_64 watchos-cross-armv7k watchos-cross-arm64_32 watchos-sim-cross-i386 watchos-sim-cross-x86_64"
# Minimum iOS/tvOS SDK version to build for # Minimum iOS/tvOS SDK version to build for
IOS_MIN_SDK_VERSION="12.0" IOS_MIN_SDK_VERSION="12.0"
TVOS_MIN_SDK_VERSION="12.0" TVOS_MIN_SDK_VERSION="12.0"
MACOS_MIN_SDK_VERSION="10.15" MACOS_MIN_SDK_VERSION="10.15"
CATALYST_MIN_SDK_VERSION="10.15"
WATCHOS_MIN_SDK_VERSION="4.0" WATCHOS_MIN_SDK_VERSION="4.0"
# Init optional env variables (use available variable or default to empty string) # Init optional env variables (use available variable or default to empty string)
@ -50,6 +50,7 @@ echo_help()
echo " --ec-nistp-64-gcc-128 Enable configure option enable-ec_nistp_64_gcc_128 for 64 bit builds" echo " --ec-nistp-64-gcc-128 Enable configure option enable-ec_nistp_64_gcc_128 for 64 bit builds"
echo " -h, --help Print help (this message)" echo " -h, --help Print help (this message)"
echo " --macos-sdk=SDKVERSION Override macOS SDK version" echo " --macos-sdk=SDKVERSION Override macOS SDK version"
echo " --catalyst-sdk=SDKVERSION Override macOS SDK version for Catalyst"
echo " --ios-sdk=SDKVERSION Override iOS SDK version" echo " --ios-sdk=SDKVERSION Override iOS SDK version"
echo " --tvos-sdk=SDKVERSION Override tvOS SDK version" echo " --tvos-sdk=SDKVERSION Override tvOS SDK version"
echo " --watchos-sdk=SDKVERSION Override watchOS SDK version" echo " --watchos-sdk=SDKVERSION Override watchOS SDK version"
@ -178,6 +179,10 @@ finish_build_loop()
LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a") LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a") LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="ios_${ARCH}" OPENSSLCONF_SUFFIX="ios_${ARCH}"
elif [[ "${PLATFORM}" == Catalyst* ]]; then
LIBSSL_CATALYST+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_CATALYST+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="catalyst_${ARCH}"
else else
LIBSSL_MACOS+=("${TARGETDIR}/lib/libssl.a") LIBSSL_MACOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_MACOS+=("${TARGETDIR}/lib/libcrypto.a") LIBCRYPTO_MACOS+=("${TARGETDIR}/lib/libcrypto.a")
@ -203,6 +208,7 @@ CONFIG_ENABLE_EC_NISTP_64_GCC_128=""
CONFIG_DISABLE_BITCODE="" CONFIG_DISABLE_BITCODE=""
CONFIG_NO_DEPRECATED="" CONFIG_NO_DEPRECATED=""
MACOS_SDKVERSION="" MACOS_SDKVERSION=""
CATALYST_SDKVERSION=""
IOS_SDKVERSION="" IOS_SDKVERSION=""
WATCHOS_SDKVERSION="" WATCHOS_SDKVERSION=""
LOG_VERBOSE="" LOG_VERBOSE=""
@ -239,6 +245,10 @@ case $i in
MACOS_SDKVERSION="${i#*=}" MACOS_SDKVERSION="${i#*=}"
shift shift
;; ;;
--catalyst-sdk=*)
CATALYST_SDKVERSION="${i#*=}"
shift
;;
--ios-sdk=*) --ios-sdk=*)
IOS_SDKVERSION="${i#*=}" IOS_SDKVERSION="${i#*=}"
shift shift
@ -342,6 +352,9 @@ fi
if [ ! -n "${MACOS_SDKVERSION}" ]; then if [ ! -n "${MACOS_SDKVERSION}" ]; then
MACOS_SDKVERSION=$(xcrun -sdk macosx --show-sdk-version) MACOS_SDKVERSION=$(xcrun -sdk macosx --show-sdk-version)
fi fi
if [ ! -n "${CATALYST_SDKVERSION}" ]; then
CATALYST_SDKVERSION=$(xcrun -sdk macosx --show-sdk-version)
fi
if [ ! -n "${IOS_SDKVERSION}" ]; then if [ ! -n "${IOS_SDKVERSION}" ]; then
IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version) IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version)
fi fi
@ -355,6 +368,8 @@ fi
# Truncate to minor version # Truncate to minor version
MINOR_VERSION=(${MACOS_SDKVERSION//./ }) MINOR_VERSION=(${MACOS_SDKVERSION//./ })
MACOS_SDKVERSION="${MINOR_VERSION[0]}.${MINOR_VERSION[1]}" MACOS_SDKVERSION="${MINOR_VERSION[0]}.${MINOR_VERSION[1]}"
MINOR_VERSION=(${CATALYST_SDKVERSION//./ })
CATALYST_SDKVERSION="${MINOR_VERSION[0]}.${MINOR_VERSION[1]}"
# Determine number of cores for (parallel) build # Determine number of cores for (parallel) build
BUILD_THREADS=1 BUILD_THREADS=1
@ -399,6 +414,7 @@ echo "Build options"
echo " OpenSSL version: ${VERSION}" echo " OpenSSL version: ${VERSION}"
echo " Targets: ${TARGETS}" echo " Targets: ${TARGETS}"
echo " macOS SDK: ${MACOS_SDKVERSION} (min ${MACOS_MIN_SDK_VERSION})" echo " macOS SDK: ${MACOS_SDKVERSION} (min ${MACOS_MIN_SDK_VERSION})"
echo " macOS SDK (Catalyst): ${CATALYST_SDKVERSION} (min ${CATALYST_MIN_SDK_VERSION})"
echo " iOS SDK: ${IOS_SDKVERSION} (min ${IOS_MIN_SDK_VERSION})" echo " iOS SDK: ${IOS_SDKVERSION} (min ${IOS_MIN_SDK_VERSION})"
echo " tvOS SDK: ${TVOS_SDKVERSION} (min ${TVOS_MIN_SDK_VERSION})" echo " tvOS SDK: ${TVOS_SDKVERSION} (min ${TVOS_MIN_SDK_VERSION})"
echo " watchOS SDK: ${WATCHOS_SDKVERSION} (min ${WATCHOS_MIN_SDK_VERSION})" echo " watchOS SDK: ${WATCHOS_SDKVERSION} (min ${WATCHOS_MIN_SDK_VERSION})"
@ -480,6 +496,8 @@ INCLUDE_DIR=""
OPENSSLCONF_ALL=() OPENSSLCONF_ALL=()
LIBSSL_MACOS=() LIBSSL_MACOS=()
LIBCRYPTO_MACOS=() LIBCRYPTO_MACOS=()
LIBSSL_CATALYST=()
LIBCRYPTO_CATALYST=()
LIBSSL_IOS=() LIBSSL_IOS=()
LIBCRYPTO_IOS=() LIBCRYPTO_IOS=()
LIBSSL_TVOS=() LIBSSL_TVOS=()
@ -496,6 +514,13 @@ if [ ${#LIBSSL_MACOS[@]} -gt 0 ]; then
lipo -create ${LIBCRYPTO_MACOS[@]} -output "${CURRENTPATH}/lib/libcrypto-MacOSX.a" lipo -create ${LIBCRYPTO_MACOS[@]} -output "${CURRENTPATH}/lib/libcrypto-MacOSX.a"
fi fi
#Build Catalyst library if selected for build
if [ ${#LIBSSL_CATALYST[@]} -gt 0 ]; then
echo "Build library for Catalyst..."
lipo -create ${LIBSSL_CATALYST[@]} -output "${CURRENTPATH}/lib/libssl-Catalyst.a"
lipo -create ${LIBCRYPTO_CATALYST[@]} -output "${CURRENTPATH}/lib/libcrypto-Catalyst.a"
fi
# Build iOS library if selected for build # Build iOS library if selected for build
if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then
echo "Build library for iOS..." echo "Build library for iOS..."
@ -544,6 +569,9 @@ if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then
*_macos_i386.h) *_macos_i386.h)
DEFINE_CONDITION="TARGET_OS_OSX && TARGET_CPU_X86" DEFINE_CONDITION="TARGET_OS_OSX && TARGET_CPU_X86"
;; ;;
*_catalyst_x86_64.h)
DEFINE_CONDITION="(TARGET_OS_MACCATALYST || (TARGET_OS_IOS && TARGET_OS_SIMULATOR)) && TARGET_CPU_X86_64"
;;
*_ios_x86_64.h) *_ios_x86_64.h)
DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64" DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64"
;; ;;

View File

@ -164,4 +164,19 @@ my %targets = ();
inherit_from => [ "darwin-i386-cc", "macos-base" ], inherit_from => [ "darwin-i386-cc", "macos-base" ],
sys_id => "macOS", sys_id => "macOS",
}, },
## Catalyst
# Based on
"mac-catalyst-base" => {
inherit_from => [ "all-base" ],
template => 1,
# cflags => add(sub { defined($ENV{'CATALYST_MIN_SDK_VERSION'}) ? '-mmacosx-version-min=$(CATALYST_MIN_SDK_VERSION)' : '-mmacosx-version-min=10.15'; }),
},
## Catalyst (armv7s)
"mac-catalyst-x86_64" => {
inherit_from => [ "darwin64-x86_64-cc", "mac-catalyst-base" ],
cflags => add("-target x86_64-apple-ios13.0-macabi"),
sys_id => "MacOSX",
},
); );

View File

@ -21,7 +21,7 @@ if [ -d $FWROOT ]; then
rm -rf $FWROOT rm -rf $FWROOT
fi fi
ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX" "WatchOS") ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX" "Catalyst" "WatchOS")
function check_bitcode() { function check_bitcode() {
local FWDIR=$1 local FWDIR=$1
@ -132,10 +132,6 @@ if [ $FWTYPE == "dynamic" ]; then
echo "Assembling .dylib for $PLATFORM $SDKVERSION ($ARCH)" echo "Assembling .dylib for $PLATFORM $SDKVERSION ($ARCH)"
CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
SDK="${CROSS_TOP}/SDKs/${CROSS_SDK}"
MIN_SDK_VERSION=$(get_min_sdk "${TARGETDIR}/lib/libcrypto.a") MIN_SDK_VERSION=$(get_min_sdk "${TARGETDIR}/lib/libcrypto.a")
if [[ $PLATFORM == AppleTVSimulator* ]]; then if [[ $PLATFORM == AppleTVSimulator* ]]; then
MIN_SDK="-tvos_simulator_version_min $MIN_SDK_VERSION" MIN_SDK="-tvos_simulator_version_min $MIN_SDK_VERSION"
@ -143,6 +139,9 @@ if [ $FWTYPE == "dynamic" ]; then
MIN_SDK="-tvos_version_min $MIN_SDK_VERSION" MIN_SDK="-tvos_version_min $MIN_SDK_VERSION"
elif [[ $PLATFORM == MacOSX* ]]; then elif [[ $PLATFORM == MacOSX* ]]; then
MIN_SDK="-macosx_version_min $MIN_SDK_VERSION" MIN_SDK="-macosx_version_min $MIN_SDK_VERSION"
elif [[ $PLATFORM == Catalyst* ]]; then
MIN_SDK="-platform_version mac-catalyst 13.0 $MIN_SDK_VERSION"
PLATFORM="MacOSX"
elif [[ $PLATFORM == iPhoneSimulator* ]]; then elif [[ $PLATFORM == iPhoneSimulator* ]]; then
MIN_SDK="-ios_simulator_version_min $MIN_SDK_VERSION" MIN_SDK="-ios_simulator_version_min $MIN_SDK_VERSION"
elif [[ $PLATFORM == WatchOS* ]]; then elif [[ $PLATFORM == WatchOS* ]]; then
@ -153,6 +152,10 @@ if [ $FWTYPE == "dynamic" ]; then
MIN_SDK="-ios_version_min $MIN_SDK_VERSION" MIN_SDK="-ios_version_min $MIN_SDK_VERSION"
fi fi
CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
SDK="${CROSS_TOP}/SDKs/${CROSS_SDK}"
#cd $TARGETDIR #cd $TARGETDIR
#libtool -dynamic -lSystem $MIN_SDK -syslibroot $SDK -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib #libtool -dynamic -lSystem $MIN_SDK -syslibroot $SDK -install_name $INSTALL_NAME -compatibility_version $COMPAT_VERSION -current_version $CURRENT_VERSION lib/*.a -o $FWNAME.dylib

View File

@ -26,6 +26,8 @@ do
SDKVERSION="${TVOS_SDKVERSION}" SDKVERSION="${TVOS_SDKVERSION}"
elif [[ "${TARGET}" == macos* ]]; then elif [[ "${TARGET}" == macos* ]]; then
SDKVERSION="${MACOS_SDKVERSION}" SDKVERSION="${MACOS_SDKVERSION}"
elif [[ "${TARGET}" == mac-catalyst-* ]]; then
SDKVERSION="${CATALYST_SDKVERSION}"
elif [[ "${TARGET}" == watchos* ]]; then elif [[ "${TARGET}" == watchos* ]]; then
SDKVERSION="${WATCHOS_SDKVERSION}" SDKVERSION="${WATCHOS_SDKVERSION}"
else else
@ -35,6 +37,7 @@ do
# These variables are used in the configuration file # These variables are used in the configuration file
export SDKVERSION export SDKVERSION
export MACOS_MIN_SDK_VERSION export MACOS_MIN_SDK_VERSION
export CATALYST_MIN_SDK_VERSION
export IOS_MIN_SDK_VERSION export IOS_MIN_SDK_VERSION
export TVOS_MIN_SDK_VERSION export TVOS_MIN_SDK_VERSION
export WATCHOS_MIN_SDK_VERSION export WATCHOS_MIN_SDK_VERSION
@ -49,6 +52,8 @@ do
PLATFORM="AppleTVOS" PLATFORM="AppleTVOS"
elif [[ "${TARGET}" == "macos"* ]]; then elif [[ "${TARGET}" == "macos"* ]]; then
PLATFORM="MacOSX" PLATFORM="MacOSX"
elif [[ "${TARGET}" == "mac-catalyst-"* ]]; then
PLATFORM="MacOSX"
elif [[ "${TARGET}" == "watchos-sim-cross"* ]]; then elif [[ "${TARGET}" == "watchos-sim-cross"* ]]; then
PLATFORM="WatchSimulator" PLATFORM="WatchSimulator"
elif [[ "${TARGET}" == "watchos"* ]]; then elif [[ "${TARGET}" == "watchos"* ]]; then
@ -66,6 +71,10 @@ do
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
# Prepare TARGETDIR and SOURCEDIR # Prepare TARGETDIR and SOURCEDIR
PLATFORM="${PLATFORM}"
if [[ "${TARGET}" == "mac-catalyst-"* ]]; then
PLATFORM="Catalyst"
fi
prepare_target_source_dirs prepare_target_source_dirs
## Determine config options ## Determine config options
@ -79,6 +88,12 @@ do
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} enable-ec_nistp_64_gcc_128" LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} enable-ec_nistp_64_gcc_128"
fi fi
# openssl-1.1.1 tries to use an unguarded fork(), affecting AppleTVOS and WatchOS.
# Luckily this is only present in the testing suite and can be built without it.
if [[ $PLATFORM == "AppleTV"* || $PLATFORM == "Watch"* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} no-tests"
fi
# Run Configure # Run Configure
run_configure run_configure