Merge branch 'feature/macos-support'

This commit is contained in:
Davide De Rosa 2018-02-08 16:47:57 +01:00
commit 92fd548dc6
6 changed files with 98 additions and 12 deletions

24
assets/MacOSX/Info.plist Normal 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>10.11</string>
</dict>
</plist>

View File

@ -28,10 +28,11 @@ set -u
DEFAULTVERSION="1.0.2l"
# Default (=full) set of architectures (OpenSSL <= 1.0.2) or targets (OpenSSL >= 1.1.0) to build
DEFAULTARCHS="x86_64 i386 arm64 armv7s armv7 tv_x86_64 tv_arm64"
DEFAULTTARGETS="ios-sim-cross-x86_64 ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 tvos-sim-cross-x86_64 tvos64-cross-arm64"
DEFAULTARCHS="ios_x86_64 ios_i386 ios_arm64 ios_armv7s ios_armv7 tv_x86_64 tv_arm64 mac_x86_64 mac_i386"
DEFAULTTARGETS="ios-sim-cross-x86_64 ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 tvos-sim-cross-x86_64 tvos64-cross-arm64 macos64-x86_64 macos-i386"
# Minimum iOS/tvOS SDK version to build for
MACOS_MIN_SDK_VERSION="10.11"
IOS_MIN_SDK_VERSION="7.0"
TVOS_MIN_SDK_VERSION="9.0"
@ -47,6 +48,7 @@ echo_help()
echo " --cleanup Clean up build directories (bin, include/openssl, lib, src) before starting build"
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 " --macos-sdk=SDKVERSION Override macOS SDK version"
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"
@ -168,10 +170,14 @@ finish_build_loop()
LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="tvos_${ARCH}"
else
elif [[ "${PLATFORM}" == iPhone* ]]; then
LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="ios_${ARCH}"
else
LIBSSL_MACOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_MACOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="macos_${ARCH}"
fi
# Copy opensslconf.h to bin directory and add to array
@ -192,6 +198,7 @@ CLEANUP=""
CONFIG_ENABLE_EC_NISTP_64_GCC_128=""
CONFIG_DISABLE_BITCODE=""
CONFIG_NO_DEPRECATED=""
MACOS_SDKVERSION=""
IOS_SDKVERSION=""
LOG_VERBOSE=""
PARALLEL=""
@ -227,6 +234,10 @@ case $i in
echo_help
exit
;;
--macos-sdk=*)
MACOS_SDKVERSION="${i#*=}"
shift
;;
--ios-sdk=*)
IOS_SDKVERSION="${i#*=}"
shift
@ -327,6 +338,9 @@ else
fi
# Determine SDK versions
if [ ! -n "${MACOS_SDKVERSION}" ]; then
MACOS_SDKVERSION=$(xcrun -sdk macosx --show-sdk-version)
fi
if [ ! -n "${IOS_SDKVERSION}" ]; then
IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version)
fi
@ -380,6 +394,7 @@ if [ "${BUILD_TYPE}" == "archs" ]; then
else
echo " Targets: ${TARGETS}"
fi
echo " macOS SDK: ${MACOS_SDKVERSION}"
echo " iOS SDK: ${IOS_SDKVERSION}"
echo " tvOS SDK: ${TVOS_SDKVERSION}"
if [ "${CONFIG_DISABLE_BITCODE}" == "true" ]; then
@ -458,6 +473,8 @@ mkdir -p "${CURRENTPATH}/src"
# Init vars for library references
INCLUDE_DIR=""
OPENSSLCONF_ALL=()
LIBSSL_MACOS=()
LIBCRYPTO_MACOS=()
LIBSSL_IOS=()
LIBCRYPTO_IOS=()
LIBSSL_TVOS=()
@ -470,6 +487,13 @@ else
source "${SCRIPTDIR}/scripts/build-loop-targets.sh"
fi
# 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"
lipo -create ${LIBCRYPTO_MACOS[@]} -output "${CURRENTPATH}/lib/libcrypto-MacOSX.a"
fi
# Build iOS library if selected for build
if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then
echo "Build library for iOS..."
@ -505,6 +529,12 @@ if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then
# Determine define condition
case "${OPENSSLCONF_CURRENT}" in
*_macos_x86_64.h)
DEFINE_CONDITION="TARGET_OS_OSX && TARGET_CPU_X86_64"
;;
*_macos_i386.h)
DEFINE_CONDITION="TARGET_OS_OSX && TARGET_CPU_X86"
;;
*_ios_x86_64.h)
DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64"
;;

View File

@ -1,12 +1,11 @@
## -*- mode: perl; -*-
## iOS configuration targets
%targets = (
## Base settings for iOS-tvOS cross-compile
## Base settings for cross-compile
# Based on 10-main.conf: iphoneos-cross
# Add generic compiler flags
# Add embed-bitcode option if SDK version is 9 or higher
"ios-tvos-cross-base" => {
"all-base" => {
template => 1,
cflags => combine('-isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK) -fno-common',
sub { ((!defined($ENV{'CONFIG_DISABLE_BITCODE'}) || $ENV{'CONFIG_DISABLE_BITCODE'} ne 'true') && defined($ENV{'SDKVERSION'}) && $ENV{'SDKVERSION'} =~ /^(9|[1-9][0-9]+)\./ && $disabled{shared})
@ -16,7 +15,7 @@
## Base settings for iOS
"ios-cross-base" => {
inherit_from => [ "ios-tvos-cross-base" ],
inherit_from => [ "all-base" ],
template => 1,
cflags => add(sub { defined($ENV{'IOS_MIN_SDK_VERSION'}) ? '-mios-version-min=$(IOS_MIN_SDK_VERSION)' : '-mios-version-min=7.0'; }),
},
@ -24,12 +23,19 @@
## Base settings for tvOS
# Defines to skip functionality that uses unsupported functions
"tvos-cross-base" => {
inherit_from => [ "ios-tvos-cross-base" ],
inherit_from => [ "all-base" ],
template => 1,
cflags => add(sub { defined($ENV{'TVOS_MIN_SDK_VERSION'}) ? '-mtvos-version-min=$(TVOS_MIN_SDK_VERSION)' : '-mtvos-version-min=9.0'; }),
defines => [ "HAVE_FORK=0" ],
},
## Base settings for macOS
"macos-base" => {
inherit_from => [ "all-base" ],
template => 1,
cflags => add(sub { defined($ENV{'MACOS_MIN_SDK_VERSION'}) ? '-mmacosx-version-min=$(MACOS_MIN_SDK_VERSION)' : '-mmacosx-version-min=10.11'; }),
},
## Apple iOS simulator (x86_64)
# Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc
"ios-sim-cross-x86_64" => {
@ -88,4 +94,16 @@
perlasm_scheme => "ios64",
sys_id => "tvOS",
},
## Apple macOS (x86_64)
"macos64-x86_64" => {
inherit_from => [ "darwin64-x86_64-cc", "macos-base" ],
sys_id => "macOS",
},
## Apple macOS (i386)
"macos-i386" => {
inherit_from => [ "darwin-i386-cc", "macos-base" ],
sys_id => "macOS",
},
);

View File

@ -21,7 +21,7 @@ if [ -d $FWROOT ]; then
rm -rf $FWROOT
fi
ALL_SYSTEMS=("iPhone" "AppleTV")
ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX")
function check_bitcode() {
local FWDIR=$1
@ -64,6 +64,8 @@ if [ $FWTYPE == "dynamic" ]; then
if [[ $PLATFORM == "AppleTV"* ]]; then
MIN_SDK="-tvos_version_min 9.0"
elif [[ $PLATFORM == MacOSX* ]]; then
MIN_SDK="-macosx_version_min 10.11"
else
MIN_SDK="-ios_version_min 8.0"
fi

View File

@ -24,23 +24,28 @@ do
# Determine relevant SDK version
if [[ "$ARCH" == tv* ]]; then
SDKVERSION=${TVOS_SDKVERSION}
elif [[ "$ARCH" == mac* ]]; then
SDKVERSION=${MACOS_SDKVERSION}
else
SDKVERSION=${IOS_SDKVERSION}
fi
# Determine platform, override arch for tvOS builds
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
if [[ "${ARCH}" == "ios_x86_64" || "${ARCH}" == "ios_i386" ]]; then
PLATFORM="iPhoneSimulator"
elif [ "${ARCH}" == "tv_x86_64" ]; then
ARCH="x86_64"
PLATFORM="AppleTVSimulator"
elif [ "${ARCH}" == "tv_arm64" ]; then
ARCH="arm64"
PLATFORM="AppleTVOS"
elif [[ "${ARCH}" == "mac_x86_64" || "${ARCH}" == "mac_i386" ]]; then
PLATFORM="MacOSX"
else
PLATFORM="iPhoneOS"
fi
# Extract ARCH from pseudo ARCH (part after first underscore)
ARCH=$(echo "${ARCH}" | sed -E 's|^[^_]*_(.+)$|\1|g')
# Set env vars for Configure
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
@ -72,6 +77,8 @@ 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}" == MacOSX* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -mmacosx-version-min=${MACOS_MIN_SDK_VERSION}"
else
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -miphoneos-version-min=${IOS_MIN_SDK_VERSION}"
fi

View File

@ -24,12 +24,15 @@ do
# Determine relevant SDK version
if [[ "${TARGET}" == tvos* ]]; then
SDKVERSION="${TVOS_SDKVERSION}"
elif [[ "${TARGET}" == macos* ]]; then
SDKVERSION="${MACOS_SDKVERSION}"
else
SDKVERSION="${IOS_SDKVERSION}"
fi
# These variables are used in the configuration file
export SDKVERSION
export MACOS_MIN_SDK_VERSION
export IOS_MIN_SDK_VERSION
export TVOS_MIN_SDK_VERSION
export CONFIG_DISABLE_BITCODE
@ -41,6 +44,8 @@ do
PLATFORM="AppleTVSimulator"
elif [[ "${TARGET}" == "tvos64-cross-"* ]]; then
PLATFORM="AppleTVOS"
elif [[ "${TARGET}" == "macos"* ]]; then
PLATFORM="MacOSX"
else
PLATFORM="iPhoneOS"
fi