Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	Gemfile.lock
#	Package.swift
  • Loading branch information
yangyubo committed Jul 12, 2024
2 parents 911ae08 + 8aa1a61 commit 23429a3
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 200 deletions.
9 changes: 2 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ let package = Package(
targets: [
.binaryTarget(
name: "openssl",
url: "https://codinn.com/download/openssl.xcframework.zip",
checksum: "db6fce0262b9d6cc10f2312b8c88c08d9127ff083953d02a84b544d73732bc5c"
url: "https://github.com/codinn/OpenSSL/releases/download/3.0.14/openssl.xcframework.zip",
checksum: "d63947127ead98512975e52f08a7b55c8ac17726c614096862b2953f00d4f7b9"
),
.target(name: "OpenSSL",
dependencies: ["openssl"])
]
)

/*
xcframework successfully written out to: frameworks/openssl.xcframework
db6fce0262b9d6cc10f2312b8c88c08d9127ff083953d02a84b544d73732bc5c
*/
27 changes: 11 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# OpenSSL-Apple

![iOS support](https://img.shields.io/badge/iOS-12+-blue.svg)
![macOS support](https://img.shields.io/badge/macOS-10.15+-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)
![macOS support](https://img.shields.io/badge/macOS-10.14+-blue.svg)
![macOS Catalyst support](https://img.shields.io/badge/macOS%20Catalyst-10.14+-blue.svg)
![watchOS support](https://img.shields.io/badge/watchOS-4+-blue.svg)
![tvOS support](https://img.shields.io/badge/tvOS-12+-blue.svg)
![OpenSSL version](https://img.shields.io/badge/OpenSSL-1.1.1l-green.svg)
![xrOS support](https://img.shields.io/badge/xrOS-1+-blue.svg)
![OpenSSL version](https://img.shields.io/badge/OpenSSL-3.2.0-green.svg)
[![license](https://img.shields.io/badge/license-Apache%202.0-lightgrey.svg)](LICENSE)

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.
Expand All @@ -14,16 +15,16 @@ However, this repository focuses more on framework-based setups and also adds ma

# Compile library

Compile OpenSSL 1.1.1l for all targets:
Compile OpenSSL 3.2.0 for all targets:

```
./build-libssl.sh --version=1.1.1l
./build-libssl.sh --version=3.2.0
```

Compile OpenSSL 1.1.1l for specific targets:
Compile OpenSSL 3.2.0 for specific targets:

```
./build-libssl.sh --version=1.1.1l --targets="ios64-cross-arm64 macos64-x86_64 macos64-arm64"
./build-libssl.sh --version=3.2.0 --targets="ios64-cross-arm64 macos64-x86_64 macos64-arm64"
```

For all options see:
Expand All @@ -34,16 +35,10 @@ For all options see:

# Generate frameworks

Statically linked:
Generate dynamically linked frameworks and a compound XCFramework:

```
./create-openssl-framework.sh static
```

Dynamically linked:

```
./create-openssl-framework.sh dynamic
./create-openssl-framework.sh
```

# Original project
Expand Down
53 changes: 40 additions & 13 deletions build-libssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,25 @@ set -u
# SCRIPT DEFAULTS

# Default version in case no version is specified
DEFAULTVERSION="1.1.1l"
DEFAULTVERSION="3.2.0"

# Default (=full) set of targets (OpenSSL >= 1.1.1) to build
DEFAULTTARGETS=`cat <<TARGETS
ios-sim-cross-x86_64 ios-sim-cross-arm64 ios64-cross-arm64 ios64-cross-arm64e
macos64-x86_64 macos64-arm64
mac-catalyst-x86_64 mac-catalyst-arm64
watchos-cross-armv7k watchos-cross-arm64_32 watchos-sim-cross-x86_64 watchos-sim-cross-i386 watchos-sim-cross-arm64
tvos-sim-cross-x86_64 tvos64-cross-arm64
tvos-sim-cross-x86_64 tvos-sim-cross-arm64 tvos-cross-arm64
xros-sim-cross-arm64 xros-cross-arm64
TARGETS`
# Minimum iOS/tvOS SDK version to build for
IOS_MIN_SDK_VERSION="12.0"
MACOS_MIN_SDK_VERSION="10.15"
CATALYST_MIN_SDK_VERSION="10.15"
MACOS_MIN_SDK_VERSION="10.14"
CATALYST_MIN_SDK_VERSION="10.14"
WATCHOS_MIN_SDK_VERSION="4.0"
TVOS_MIN_SDK_VERSION="12.0"
XROS_MIN_SDK_VERSION="1.0"
# Init optional env variables (use available variable or default to empty string)
CURL_OPTIONS="${CURL_OPTIONS:-}"
Expand All @@ -60,12 +62,12 @@ echo_help()
echo " --catalyst-sdk=SDKVERSION Override macOS SDK version for Catalyst"
echo " --watchos-sdk=SDKVERSION Override watchOS SDK version"
echo " --tvos-sdk=SDKVERSION Override tvOS SDK version"
echo " --xros-sdk=SDKVERSION Override xrOS SDK version"
echo " --min-ios-sdk=SDKVERSION Set minimum iOS SDK version (default: $IOS_MIN_SDK_VERSION)"
echo " --min-macos-sdk=SDKVERSION Set minimum macOS SDK version (default: $MACOS_MIN_SDK_VERSION)"
echo " --min-watchos-sdk=SDKVERSION Set minimum watchOS SDK version (default: $WATCHOS_MIN_SDK_VERSION)"
echo " --min-tvos-sdk=SDKVERSION Set minimum tvOS SDK version (default: $TVOS_MIN_SDK_VERSION)"
echo " --noparallel Disable running make with parallel jobs (make -j)"
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})"
Expand Down Expand Up @@ -181,6 +183,14 @@ finish_build_loop()
else
OPENSSLCONF_SUFFIX="ios_${ARCH}"
fi
elif [[ "${PLATFORM}" == XR* ]]; then
LIBSSL_XROS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_XROS+=("${TARGETDIR}/lib/libcrypto.a")
if [[ "${PLATFORM}" == XRSimulator* ]]; then
OPENSSLCONF_SUFFIX="xros_sim_${ARCH}"
else
OPENSSLCONF_SUFFIX="xros_${ARCH}"
fi
elif [[ "${PLATFORM}" == Watch* ]]; then
LIBSSL_WATCHOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_WATCHOS+=("${TARGETDIR}/lib/libcrypto.a")
Expand Down Expand Up @@ -237,13 +247,14 @@ ARCHS=""
BRANCH=""
CLEANUP=""
CONFIG_ENABLE_EC_NISTP_64_GCC_128=""
CONFIG_DISABLE_BITCODE=""
CONFIG_DISABLE_BITCODE="true"
CONFIG_NO_DEPRECATED=""
IOS_SDKVERSION=""
MACOS_SDKVERSION=""
CATALYST_SDKVERSION=""
WATCHOS_SDKVERSION=""
TVOS_SDKVERSION=""
XROS_SDKVERSION=""
LOG_VERBOSE=""
PARALLEL=""
TARGETS=""
Expand All @@ -266,9 +277,6 @@ case $i in
--ec-nistp-64-gcc-128)
CONFIG_ENABLE_EC_NISTP_64_GCC_128="true"
;;
--disable-bitcode)
CONFIG_DISABLE_BITCODE="true"
;;
-h|--help)
echo_help
exit
Expand Down Expand Up @@ -309,6 +317,10 @@ case $i in
TVOS_MIN_SDK_VERSION="${i#*=}"
shift
;;
--min-xros-sdk=*)
XROS_MIN_SDK_VERSION="${i#*=}"
shift
;;
--noparallel)
PARALLEL="false"
;;
Expand Down Expand Up @@ -396,6 +408,9 @@ fi
if [ ! -n "${TVOS_SDKVERSION}" ]; then
TVOS_SDKVERSION=$(xcrun -sdk appletvos --show-sdk-version)
fi
if [ ! -n "${XROS_SDKVERSION}" ]; then
XROS_SDKVERSION=$(xcrun -sdk xros --show-sdk-version)
fi
# Truncate to minor version
MINOR_VERSION=(${MACOS_SDKVERSION//./ })
Expand Down Expand Up @@ -450,6 +465,7 @@ echo " macOS SDK: ${MACOS_SDKVERSION} (min ${MACOS_MIN_SDK_VERSION})"
echo " macOS SDK (Catalyst): ${CATALYST_SDKVERSION} (min ${CATALYST_MIN_SDK_VERSION})"
echo " watchOS SDK: ${WATCHOS_SDKVERSION} (min ${WATCHOS_MIN_SDK_VERSION})"
echo " tvOS SDK: ${TVOS_SDKVERSION} (min ${TVOS_MIN_SDK_VERSION})"
echo " xrOS SDK: ${XROS_SDKVERSION} (min ${XROS_MIN_SDK_VERSION})"
if [ "${CONFIG_DISABLE_BITCODE}" == "true" ]; then
echo " Bitcode embedding disabled"
fi
Expand All @@ -472,14 +488,14 @@ if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then
# Check whether file exists here (this is the location of the latest version for each branch)
# -s be silent, -f return non-zero exit status on failure, -I get header (do not download)
curl ${CURL_OPTIONS} -sfI "${OPENSSL_ARCHIVE_URL}" > /dev/null
curl ${CURL_OPTIONS} -sfIL "${OPENSSL_ARCHIVE_URL}" > /dev/null
# If unsuccessful, update the URL for older versions and try again.
if [ $? -ne 0 ]; then
BRANCH=$(echo "${VERSION}" | grep -Eo '^[0-9]\.[0-9]\.[0-9]')
OPENSSL_ARCHIVE_URL="https://www.openssl.org/source/old/${BRANCH}/${OPENSSL_ARCHIVE_FILE_NAME}"
curl ${CURL_OPTIONS} -sfI "${OPENSSL_ARCHIVE_URL}" > /dev/null
curl ${CURL_OPTIONS} -sfIL "${OPENSSL_ARCHIVE_URL}" > /dev/null
fi
# Both attempts failed, so report the error
Expand All @@ -491,9 +507,9 @@ if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then
# Archive was found, so proceed with download.
# -O Use server-specified filename for download
curl ${CURL_OPTIONS} -O "${OPENSSL_ARCHIVE_URL}"
curl ${CURL_OPTIONS} -LO "${OPENSSL_ARCHIVE_URL}"
# also download the gpg signature from the same location
curl ${CURL_OPTIONS} -O "${OPENSSL_ARCHIVE_URL}${OPENSSL_ARCHIVE_SIGNATURE_FILE_EXT}"
curl ${CURL_OPTIONS} -LO "${OPENSSL_ARCHIVE_URL}${OPENSSL_ARCHIVE_SIGNATURE_FILE_EXT}"
else
echo "Using ${OPENSSL_ARCHIVE_FILE_NAME}"
Expand Down Expand Up @@ -551,6 +567,8 @@ LIBSSL_WATCHOS=()
LIBCRYPTO_WATCHOS=()
LIBSSL_TVOS=()
LIBCRYPTO_TVOS=()
LIBSSL_XROS=()
LIBCRYPTO_XROS=()
source "${SCRIPTDIR}/scripts/build-loop-targets.sh"
Expand Down Expand Up @@ -617,9 +635,18 @@ if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then
*_tvos_arm64.h)
DEFINE_CONDITION="TARGET_OS_TV && TARGET_OS_EMBEDDED && TARGET_CPU_ARM64"
;;
*_tvos_sim_arm64.h)
DEFINE_CONDITION="TARGET_OS_TV && TARGET_OS_SIMULATOR && TARGET_CPU_ARM64"
;;
*_tvos_sim_x86_64.h)
DEFINE_CONDITION="TARGET_OS_TV && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64"
;;
*_xros_sim_arm64.h)
DEFINE_CONDITION="TARGET_OS_VISION && TARGET_OS_SIMULATOR && TARGET_CPU_ARM64"
;;
*_xros_arm64.h)
DEFINE_CONDITION="TARGET_OS_VISION && TARGET_CPU_ARM64"
;;
*)
# Don't run into unexpected cases by setting the default condition to false
DEFINE_CONDITION="0"
Expand Down
Loading

0 comments on commit 23429a3

Please sign in to comment.