├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── FUNDING.yml
├── LICENSE
├── README.md
├── openssl-iosx.podspec
└── scripts
├── 15-ios.conf.patch
└── build.sh
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: Build OpenSSL
2 | on:
3 | release:
4 | types: [published]
5 | push:
6 | tags:
7 | - 3.5.0**
8 | workflow_dispatch:
9 | jobs:
10 | Build:
11 | runs-on: macos-latest
12 | timeout-minutes: 120
13 | steps:
14 | - uses: actions/checkout@v3
15 | - name: Build
16 | run: |
17 | scripts/build.sh -p=macosx-both,ios,iossim-both,catalyst-both,xros,xrossim-both,watchos,watchossim-both,tvos,tvossim-both
18 | for i in frameworks/*.xcframework/; do cd frameworks && zip -9 -r -r "$(basename -- $i).zip" $(basename -- $i) & done; wait
19 | cd frameworks
20 | mv Headers include
21 | zip -9 -r include.zip include
22 | wait
23 | - name: Release
24 | uses: softprops/action-gh-release@v1
25 | if: startsWith(github.ref, 'refs/tags/')
26 | with:
27 | files: |
28 | frameworks/*.zip
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.DS_STORE
2 | scripts/.DS_Store
3 | /OpenSSL_1_1_1*
4 | /build
5 | /frameworks
6 |
--------------------------------------------------------------------------------
/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # repo: apotocki/openssl-iosx
2 | # filename: FUNDING.YML
3 |
4 | github: apotocki
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | LICENSE ISSUES
3 | ==============
4 |
5 | The OpenSSL toolkit stays under a double license, i.e. both the conditions of
6 | the OpenSSL License and the original SSLeay license apply to the toolkit.
7 | See below for the actual license texts.
8 |
9 | OpenSSL License
10 | ---------------
11 |
12 | /* ====================================================================
13 | * Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
14 | *
15 | * Redistribution and use in source and binary forms, with or without
16 | * modification, are permitted provided that the following conditions
17 | * are met:
18 | *
19 | * 1. Redistributions of source code must retain the above copyright
20 | * notice, this list of conditions and the following disclaimer.
21 | *
22 | * 2. Redistributions in binary form must reproduce the above copyright
23 | * notice, this list of conditions and the following disclaimer in
24 | * the documentation and/or other materials provided with the
25 | * distribution.
26 | *
27 | * 3. All advertising materials mentioning features or use of this
28 | * software must display the following acknowledgment:
29 | * "This product includes software developed by the OpenSSL Project
30 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
31 | *
32 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
33 | * endorse or promote products derived from this software without
34 | * prior written permission. For written permission, please contact
35 | * openssl-core@openssl.org.
36 | *
37 | * 5. Products derived from this software may not be called "OpenSSL"
38 | * nor may "OpenSSL" appear in their names without prior written
39 | * permission of the OpenSSL Project.
40 | *
41 | * 6. Redistributions of any form whatsoever must retain the following
42 | * acknowledgment:
43 | * "This product includes software developed by the OpenSSL Project
44 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
45 | *
46 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
47 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
50 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
57 | * OF THE POSSIBILITY OF SUCH DAMAGE.
58 | * ====================================================================
59 | *
60 | * This product includes cryptographic software written by Eric Young
61 | * (eay@cryptsoft.com). This product includes software written by Tim
62 | * Hudson (tjh@cryptsoft.com).
63 | *
64 | */
65 |
66 | Original SSLeay License
67 | -----------------------
68 |
69 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
70 | * All rights reserved.
71 | *
72 | * This package is an SSL implementation written
73 | * by Eric Young (eay@cryptsoft.com).
74 | * The implementation was written so as to conform with Netscapes SSL.
75 | *
76 | * This library is free for commercial and non-commercial use as long as
77 | * the following conditions are aheared to. The following conditions
78 | * apply to all code found in this distribution, be it the RC4, RSA,
79 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation
80 | * included with this distribution is covered by the same copyright terms
81 | * except that the holder is Tim Hudson (tjh@cryptsoft.com).
82 | *
83 | * Copyright remains Eric Young's, and as such any Copyright notices in
84 | * the code are not to be removed.
85 | * If this package is used in a product, Eric Young should be given attribution
86 | * as the author of the parts of the library used.
87 | * This can be in the form of a textual message at program startup or
88 | * in documentation (online or textual) provided with the package.
89 | *
90 | * Redistribution and use in source and binary forms, with or without
91 | * modification, are permitted provided that the following conditions
92 | * are met:
93 | * 1. Redistributions of source code must retain the copyright
94 | * notice, this list of conditions and the following disclaimer.
95 | * 2. Redistributions in binary form must reproduce the above copyright
96 | * notice, this list of conditions and the following disclaimer in the
97 | * documentation and/or other materials provided with the distribution.
98 | * 3. All advertising materials mentioning features or use of this software
99 | * must display the following acknowledgement:
100 | * "This product includes cryptographic software written by
101 | * Eric Young (eay@cryptsoft.com)"
102 | * The word 'cryptographic' can be left out if the rouines from the library
103 | * being used are not cryptographic related :-).
104 | * 4. If you include any Windows specific code (or a derivative thereof) from
105 | * the apps directory (application code) you must include an acknowledgement:
106 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
107 | *
108 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
109 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
110 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
111 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
112 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
113 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
114 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
115 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
116 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
117 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
118 | * SUCH DAMAGE.
119 | *
120 | * The licence and distribution terms for any publically available version or
121 | * derivative of this code cannot be changed. i.e. this code cannot simply be
122 | * copied and put under another distribution licence
123 | * [including the GNU Public Licence.]
124 | */
125 |
126 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## OpenSSL for iOS, watchOS, tvOS, visionOS, macOS, Catalyst, Simulators - Intel(x86_64) / Apple Silicon(arm64)
3 |
4 | Supported 3.5.X versions: 3.5.0
5 |
6 | Supported 3.4.X versions: 3.4.1, 3.4.0
7 |
8 | Supported 3.3.X versions: 3.3.3, 3.3.2, 3.3.1, 3.3.0
9 |
10 | Supported 3.2.X versions: 3.2.4, 3.2.3, 3.2.2, 3.2.1, 3.2.0
11 |
12 | Supported 3.1.X versions: 3.1.8, 3.1.7, 3.1.6, 3.1.5, 3.1.4, 3.1.3, 3.1.2, 3.1.1, 3.1.0
13 |
14 | Supported 3.0.X versions: 3.0.16, 3.0.15, 3.0.14, 3.0.13, 3.0.12, 3.0.11, 3.0.10, 3.0.9, 3.0.8, 3.0.8, 3.0.7
15 |
16 | Supported 1.1.1X versions: 1.1.1w, 1.1.1v, 1.1.1u, 1.1.1t, 1.1.1s, 1.1.1q, 1.1.1p, 1.1.1o, 1.1.1n, 1.1.1m, 1.1.1l, 1.1.1k, 1.1.1j, 1.1.1i
17 |
18 |
19 | Use the appropriate tag or branch to choose a version.
20 |
21 | This repository provides a universal script for building static OpenSSL libraries for use in iOS, watchOS, tvOS, visionOS, and macOS & Catalyst applications.
22 | The actual library version is taken from https://github.com/openssl/openssl with an appropriate tag like 'OpenSSL_1_1_1w' or 'openssl-3.2.1'
23 |
24 | # Prerequisites
25 |
26 | 1. **Install Xcode**: Ensure Xcode is installed, as `xcodebuild` is required to create `xcframeworks`.
27 |
28 | 2. **Verify Xcode Developer Directory**:
29 | - The `xcode-select -p` command must point to the Xcode app's developer directory (e.g., `/Applications/Xcode.app/Contents/Developer`).
30 | - If it points to the CommandLineTools directory, reset it using one of the following commands:
31 | ```bash
32 | sudo xcode-select --reset
33 | ```
34 | or
35 | ```bash
36 | sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
37 | ```
38 |
39 | 3. **Install Required SDKs**: To build for tvOS, watchOS, visionOS, and their simulators, make sure the corresponding SDKs are installed in the folder:
40 | ```
41 | /Applications/Xcode.app/Contents/Developer/Platforms
42 | ```
43 |
44 | # Build Manually
45 | ```
46 | # clone the repo
47 | git clone https://github.com/apotocki/openssl-iosx
48 |
49 | # build libraries
50 | cd openssl-iosx
51 | scripts/build.sh
52 |
53 | # have fun, the result artifacts will be located in 'frameworks' folder.
54 | ```
55 | ## Selecting Platforms and Architectures
56 |
57 | build.sh without arguments builds xcframeworks for iOS, macOS, Catalyst and also for watchOS, tvOS, visionOS if their SDKs are installed on the system. It also builds xcframeworks for their simulators with the architecture (arm64 or x86_64) depending on the current host.
58 | If you are interested in a specific set of platforms and architectures, you can specify them explicitly using the -p argument, for example:
59 | ```
60 | scripts/build.sh -p=ios,iossim-x86_64
61 | # builts xcframeworks only for iOS and iOS Simulator with x86_64 architecture
62 | ```
63 | Here is a list of all possible values for '-p' option:
64 | ```
65 | macosx,macosx-arm64,macosx-x86_64,macosx-both,ios,iossim,iossim-arm64,iossim-x86_64,iossim-both,catalyst,catalyst-arm64,catalyst-x86_64,catalyst-both,xros,xrossim,xrossim-arm64,xrossim-x86_64,xrossim-both,tvos,tvossim,tvossim-arm64,tvossim-x86_64,tvossim-both,watchos,watchossim,watchossim-arm64,watchossim-x86_64,watchossim-both
66 | ```
67 | Suffix '-both' means that xcframeworks will be built for both arm64 and x86_64 architectures.
68 | The platform names for macosx and simulators without an architecture suffix (e.g. macosx, iossim, tvossim) mean that xcframeworks are only built for the current host architecture.
69 |
70 | ## Rebuild option
71 | To rebuild the libraries without using the results of previous builds, use the --rebuild option
72 | ```
73 | scripts/build.sh -p=ios,iossim-x86_64 --rebuild
74 |
75 | ```
76 |
77 | # Build Using Cocoapods.
78 |
79 | Add the following lines into your project's Podfile:
80 | ```
81 | use_frameworks!
82 | pod 'openssl-iosx', '~> 3.5.0'
83 | # or optionally more precisely
84 | # pod 'openssl-iosx', :git => 'https://github.com/apotocki/openssl-iosx', :tag => '3.5.0.1'
85 | ```
86 | install new dependency:
87 | ```
88 | pod install --verbose
89 | ```
90 |
91 | ## As an advertisement…
92 | Please check out my iOS application on the App Store:
93 |
94 | [
]()
95 |
96 | This application is designed to view and edit files at the byte or character level; calculate different hashes, encode/decode, and compress/decompress desired byte regions.
97 |
98 | You can support my open-source development by trying the [App](https://apps.apple.com/us/app/potohex/id1620963302).
99 |
100 | Feedback is welcome!
--------------------------------------------------------------------------------
/openssl-iosx.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = "openssl-iosx"
3 | s.version = "3.5.0.1"
4 | s.summary = "OpenSSL libraries for macOS, iOS, and visionOS, including both arm64 and x86_64 builds for macOS, Mac Catalyst, iOS Simulator, and visionOS Simulator."
5 | s.homepage = "https://github.com/apotocki/openssl-iosx"
6 | s.license = "Apache"
7 | s.author = { "Alexander Pototskiy" => "alex.a.potocki@gmail.com" }
8 | s.social_media_url = "https://www.linkedin.com/in/alexander-pototskiy"
9 | s.ios.deployment_target = "13.4"
10 | s.osx.deployment_target = "11.0"
11 | s.tvos.deployment_target = "13.0"
12 | s.watchos.deployment_target = "11.0"
13 | s.visionos.deployment_target = "1.0"
14 | s.ios.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
15 | s.osx.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
16 | s.tvos.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
17 | s.watchos.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
18 | s.visionos.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
19 | s.ios.user_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
20 | s.osx.user_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
21 | s.tvos.user_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
22 | s.watchos.user_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
23 | s.visionos.user_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }
24 | s.static_framework = true
25 | s.prepare_command = "sh scripts/build.sh"
26 | s.source = { :git => "https://github.com/apotocki/openssl-iosx.git", :tag => "#{s.version}" }
27 |
28 | s.header_mappings_dir = "frameworks/Headers"
29 | s.public_header_files = "frameworks/Headers/**/*.{h,H,c}"
30 | s.source_files = "frameworks/Headers/**/*.{h,H,c}"
31 | s.vendored_frameworks = "frameworks/ssl.xcframework", "frameworks/crypto.xcframework", "frameworks/apps.xcframework"
32 |
33 | #s.preserve_paths = "frameworks/**/*"
34 | end
35 |
--------------------------------------------------------------------------------
/scripts/15-ios.conf.patch:
--------------------------------------------------------------------------------
1 | @@ -34,6 +34,60 @@
2 | inherit_from => [ "ios-common" ],
3 | CC => "xcrun -sdk iphonesimulator cc",
4 | },
5 | + "xros-common" => {
6 | + template => 1,
7 | + inherit_from => [ "darwin-common" ],
8 | + sys_id => "visionOS",
9 | + disable => [ "shared", "async" ],
10 | + },
11 | + "xros-xcrun" => {
12 | + inherit_from => [ "xros-common" ],
13 | + CC => "xcrun -sdk xros cc",
14 | + cflags => add("-arch arm64 -fno-common"),
15 | + bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
16 | + asm_arch => 'aarch64',
17 | + perlasm_scheme => "ios64",
18 | + },
19 | + "xrossimulator-xcrun" => {
20 | + inherit_from => [ "xros-common" ],
21 | + CC => "xcrun -sdk xrsimulator cc",
22 | + },
23 | + "tvos-common" => {
24 | + template => 1,
25 | + inherit_from => [ "darwin-common" ],
26 | + sys_id => "tvOS",
27 | + disable => [ "engine", "async" ],
28 | + },
29 | + "tvos-xcrun" => {
30 | + inherit_from => [ "tvos-common" ],
31 | + CC => "xcrun -sdk appletvos cc",
32 | + cflags => add("-arch arm64 -fno-common"),
33 | + bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
34 | + asm_arch => 'aarch64',
35 | + perlasm_scheme => "ios64",
36 | + },
37 | + "tvossimulator-xcrun" => {
38 | + inherit_from => [ "tvos-common" ],
39 | + CC => "xcrun -sdk appletvsimulator cc",
40 | + },
41 | + "watchos-common" => {
42 | + template => 1,
43 | + inherit_from => [ "darwin-common" ],
44 | + sys_id => "watchOS",
45 | + disable => [ "engine", "async" ],
46 | + },
47 | + "watchos-xcrun" => {
48 | + inherit_from => [ "watchos-common" ],
49 | + CC => "xcrun -sdk watchos cc",
50 | + cflags => add("-arch arm64 -fno-common"),
51 | + bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
52 | + asm_arch => 'aarch64',
53 | + perlasm_scheme => "ios64",
54 | + },
55 | + "watchossimulator-xcrun" => {
56 | + inherit_from => [ "watchos-common" ],
57 | + CC => "xcrun -sdk watchsimulator cc",
58 | + },
59 | # It takes three prior-set environment variables to make it work:
60 | #
61 | # CROSS_COMPILE=/where/toolchain/is/usr/bin/ [note ending slash]
62 |
--------------------------------------------------------------------------------
/scripts/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -euo pipefail
3 |
4 | ################## SETUP BEGIN
5 | # brew install git git-lfs
6 | THREAD_COUNT=$(sysctl hw.ncpu | awk '{print $2}')
7 | HOST_ARC=$( uname -m )
8 | XCODE_ROOT=$( xcode-select -print-path )
9 | OPENSSL_VER=openssl-3.5.0
10 | MACOSX_VERSION_ARM=12.3
11 | MACOSX_VERSION_X86_64=10.13
12 | IOS_VERSION=13.4
13 | IOS_SIM_VERSION=13.4
14 | CATALYST_VERSION=13.4
15 | TVOS_VERSION=13.0
16 | TVOS_SIM_VERSION=13.0
17 | WATCHOS_VERSION=11.0
18 | WATCHOS_SIM_VERSION=11.0
19 | ################## SETUP END
20 |
21 | IOSSYSROOT=$XCODE_ROOT/Platforms/iPhoneOS.platform/Developer
22 | IOSSIMSYSROOT=$XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer
23 | MACSYSROOT=$XCODE_ROOT/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
24 | XROSSYSROOT=$XCODE_ROOT/Platforms/XROS.platform/Developer
25 | XROSSIMSYSROOT=$XCODE_ROOT/Platforms/XRSimulator.platform/Developer
26 | TVOSSYSROOT=$XCODE_ROOT/Platforms/AppleTVOS.platform/Developer
27 | TVOSSIMSYSROOT=$XCODE_ROOT/Platforms/AppleTVSimulator.platform/Developer
28 | WATCHOSSYSROOT=$XCODE_ROOT/Platforms/WatchOS.platform/Developer
29 | WATCHOSSIMSYSROOT=$XCODE_ROOT/Platforms/WatchSimulator.platform/Developer
30 |
31 | BUILD_PLATFORMS_ALL="macosx,macosx-arm64,macosx-x86_64,macosx-both,ios,iossim,iossim-arm64,iossim-x86_64,iossim-both,catalyst,catalyst-arm64,catalyst-x86_64,catalyst-both,xros,xrossim,xrossim-arm64,xrossim-x86_64,xrossim-both,tvos,tvossim,tvossim-both,tvossim-arm64,tvossim-x86_64,watchos,watchossim,watchossim-both,watchossim-arm64,watchossim-x86_64"
32 |
33 | BUILD_DIR="$( cd "$( dirname "./" )" >/dev/null 2>&1 && pwd )"
34 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
35 |
36 | if [ "$HOST_ARC" = "arm64" ]; then
37 | FOREIGN_ARC=x86_64
38 | FOREIGN_BUILD_FLAGS="" && [ ! -z "${MACOSX_VERSION_X86_64}" ] && FOREIGN_BUILD_FLAGS="-mmacosx-version-min=$MACOSX_VERSION_X86_64"
39 | NATIVE_BUILD_FLAGS="" && [ ! -z "${MACOSX_VERSION_ARM}" ] && NATIVE_BUILD_FLAGS="-mmacosx-version-min=$MACOSX_VERSION_ARM"
40 | else
41 | FOREIGN_ARC=arm64
42 | FOREIGN_BUILD_FLAGS="" && [ ! -z "${MACOSX_VERSION_ARM}" ] && FOREIGN_BUILD_FLAGS="-mmacosx-version-min=$MACOSX_VERSION_ARM"
43 | NATIVE_BUILD_FLAGS="" && [ ! -z "${MACOSX_VERSION_X86_64}" ] && NATIVE_BUILD_FLAGS="-mmacosx-version-min=$MACOSX_VERSION_X86_64"
44 | fi
45 |
46 | BUILD_PLATFORMS="macosx,ios,iossim,catalyst"
47 | [[ -d $XROSSYSROOT/SDKs/XROS.sdk ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,xros"
48 | [[ -d $XROSSIMSYSROOT/SDKs/XRSimulator.sdk ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,xrossim"
49 | [[ -d $TVOSSYSROOT/SDKs/AppleTVOS.sdk ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,tvos"
50 | [[ -d $TVOSSIMSYSROOT/SDKs/AppleTVSimulator.sdk ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,tvossim"
51 | [[ -d $WATCHOSSYSROOT/SDKs/WatchOS.sdk ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,watchos"
52 | [[ -d $WATCHOSSIMSYSROOT/SDKs/WatchSimulator.sdk ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,watchossim-both"
53 |
54 | REBUILD=false
55 |
56 | # parse command line
57 | for i in "$@"; do
58 | case $i in
59 | -p=*|--platforms=*)
60 | BUILD_PLATFORMS="${i#*=},"
61 | shift # past argument=value
62 | ;;
63 | --rebuild)
64 | REBUILD=true
65 | shift # past argument with no value
66 | ;;
67 | -*|--*)
68 | echo "Unknown option $i"
69 | exit 1
70 | ;;
71 | *)
72 | ;;
73 | esac
74 | done
75 |
76 | [[ "$BUILD_PLATFORMS" == *"macosx-both"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,macosx-arm64,macosx-x86_64"
77 | [[ "$BUILD_PLATFORMS" == *"iossim-both"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,iossim-arm64,iossim-x86_64"
78 | [[ "$BUILD_PLATFORMS" == *"catalyst-both"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,catalyst-arm64,catalyst-x86_64"
79 | [[ "$BUILD_PLATFORMS" == *"xrossim-both"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,xrossim-arm64,xrossim-x86_64"
80 | [[ "$BUILD_PLATFORMS" == *"tvossim-both"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,tvossim-arm64,tvossim-x86_64"
81 | [[ "$BUILD_PLATFORMS" == *"watchossim-both"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,watchossim-arm64,watchossim-x86_64"
82 | [[ "$BUILD_PLATFORMS," == *"macosx,"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,macosx-$HOST_ARC"
83 | [[ "$BUILD_PLATFORMS," == *"iossim,"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,iossim-$HOST_ARC"
84 | [[ "$BUILD_PLATFORMS," == *"catalyst,"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,catalyst-$HOST_ARC"
85 | [[ "$BUILD_PLATFORMS," == *"xrossim,"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,xrossim-$HOST_ARC"
86 | [[ "$BUILD_PLATFORMS," == *"tvossim,"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,tvossim-$HOST_ARC"
87 | [[ "$BUILD_PLATFORMS," == *"watchossim,"* ]] && BUILD_PLATFORMS="$BUILD_PLATFORMS,watchossim-$HOST_ARC"
88 |
89 | BUILD_PLATFORMS=" ${BUILD_PLATFORMS//,/ } "
90 |
91 | for i in $BUILD_PLATFORMS; do :;
92 | if [[ ! ",$BUILD_PLATFORMS_ALL," == *",$i,"* ]]; then
93 | echo "Unknown platform '$i'"
94 | exi1 1
95 | fi
96 | done
97 |
98 | if [[ ! -d $OPENSSL_VER ]]; then
99 | echo downloading $OPENSSL_VER ...
100 | git clone --depth 1 -b $OPENSSL_VER https://github.com/openssl/openssl $OPENSSL_VER
101 | fi
102 |
103 | echo patching openssl...
104 | if [[ ! -f $OPENSSL_VER/Configurations/15-ios.conf.orig ]]; then
105 | cp -f $OPENSSL_VER/Configurations/15-ios.conf $OPENSSL_VER/Configurations/15-ios.conf.orig
106 | else
107 | cp -f $OPENSSL_VER/Configurations/15-ios.conf.orig $OPENSSL_VER/Configurations/15-ios.conf
108 | fi
109 | patch $OPENSSL_VER/Configurations/15-ios.conf $SCRIPT_DIR/15-ios.conf.patch
110 |
111 | function arc()
112 | {
113 | if [[ $1 == arm* ]]; then
114 | echo "arm"
115 | elif [[ $1 == x86* ]]; then
116 | echo "x86"
117 | else
118 | echo "unknown"
119 | fi
120 | }
121 |
122 | LIBS_TO_BUILD="ssl crypto apps"
123 | build_libs()
124 | {
125 | [[ -d $BUILD_DIR/build.$1 ]] && rm -rf $BUILD_DIR/build.$1
126 | mkdir -p $BUILD_DIR/build.$1
127 |
128 | if [[ "$BUILD_PLATFORMS" == *$1-arm64* ]]; then
129 | if [[ "$BUILD_PLATFORMS" == *$1-x86_64* ]]; then
130 | for i in $LIBS_TO_BUILD; do :;
131 | lipo -create $BUILD_DIR/build.$1.arm64/lib$i.a $BUILD_DIR/build.$1.x86_64/lib$i.a -output $BUILD_DIR/build.$1/lib$i.a
132 | done
133 | else
134 | for i in $LIBS_TO_BUILD; do :;
135 | cp $BUILD_DIR/build.$1.arm64/lib$i.a $BUILD_DIR/build.$1/
136 | done
137 | fi
138 | elif [[ "$BUILD_PLATFORMS" == *$1-x86_64* ]]; then
139 | for i in $LIBS_TO_BUILD; do :;
140 | cp $BUILD_DIR/build.$1.x86_64/lib$i.a $BUILD_DIR/build.$1/
141 | done
142 | fi
143 | }
144 |
145 | # (type, arc, c, cflags)
146 | generic_build()
147 | {
148 | if [[ $REBUILD == true ]] || [[ ! -f $BUILD_DIR/build.$1.$2.success ]] || [[ ! -f $BUILD_DIR/build.$1.$2/libssl.a ]] || [[ ! -f $BUILD_DIR/build.$1.$2/libcrypto.a ]] || [[ ! -f $BUILD_DIR/build.$1.$2/libapps.a ]]; then
149 | [[ -f $BUILD_DIR/build.$1.$2.success ]] && rm $BUILD_DIR/build.$1.$2.success
150 | [[ -d $BUILD_DIR/build.$1.$2 ]] && rm -rf $BUILD_DIR/build.$1.$2
151 | mkdir $BUILD_DIR/build.$1.$2
152 | pushd $BUILD_DIR/build.$1.$2
153 | ../$OPENSSL_VER/Configure --openssldir="$BUILD_DIR/build.$1.$2/ssl" no-shared $3 CFLAGS="${4:-}"
154 | #remove 'fork()' dependence
155 | if [[ "$1" == *tvos* ]] || [[ "$1" == *watchos* ]]; then
156 | sed -i '' '/apps\/lib\/libapps-lib-http_server.o \\/d' Makefile
157 | sed -i '' 's/apps\/lib\/libapps-lib-http_server.o '//g Makefile
158 | fi
159 | make -j$THREAD_COUNT build_libs
160 | mv apps/libapps.a ./
161 | popd
162 | touch $BUILD_DIR/build.$1.$2.success
163 | fi
164 | }
165 |
166 | # (type, cc, cflags)
167 | generic_double_build()
168 | {
169 | [[ "$BUILD_PLATFORMS" == *$1-arm64* ]] && generic_build $1 arm64 $2 "-arch arm64 ${3:-}"
170 | [[ "$BUILD_PLATFORMS" == *$1-x86_64* ]] && generic_build $1 x86_64 $2 "-arch x86_64 ${3:-}"
171 | build_libs $1
172 | }
173 |
174 | build_catalyst_libs()
175 | {
176 | CFLAGS="-isysroot $MACSYSROOT --target=apple-ios$CATALYST_VERSION-macabi"
177 | [[ "$BUILD_PLATFORMS" == *catalyst-arm64* ]] && generic_build catalyst arm64 darwin64-arm64-cc "$CFLAGS"
178 | [[ "$BUILD_PLATFORMS" == *catalyst-x86_64* ]] && generic_build catalyst x86_64 darwin64-x86_64-cc "$CFLAGS"
179 | build_libs catalyst
180 | }
181 |
182 | build_iossim_libs()
183 | {
184 | generic_double_build iossim iossimulator-xcrun "-mios-simulator-version-min=$IOS_SIM_VERSION"
185 | }
186 |
187 | build_xrossim_libs()
188 | {
189 | generic_double_build xrossim xrossimulator-xcrun
190 | }
191 |
192 | build_tvossim_libs()
193 | {
194 | generic_double_build tvossim tvossimulator-xcrun "-target arm64-apple-tvos$TVOS_SIM_VERSION-simulator"
195 | }
196 |
197 | build_watchossim_libs()
198 | {
199 | generic_double_build watchossim watchossimulator-xcrun "-target arm64-apple-watchos$WATCHOS_SIM_VERSION-simulator"
200 | }
201 |
202 | # (arc, cflags)
203 | macosx_build()
204 | {
205 | if [[ $REBUILD == true ]] || [[ ! -f $BUILD_DIR/build.macosx.$1.success ]] || [[ ! -f $BUILD_DIR/build.macosx.$1/libssl.a ]] || [[ ! -f $BUILD_DIR/build.macosx.$1/libcrypto.a ]] || [[ ! -f $BUILD_DIR/build.macosx.$1/libapps.a ]]; then
206 | [[ -f $BUILD_DIR/build.macosx.$1.success ]] && rm $BUILD_DIR/build.macosx.$1.success
207 | [[ -d $BUILD_DIR/build.macosx.$1 ]] && rm -rf $BUILD_DIR/build.macosx.$1
208 | mkdir $BUILD_DIR/build.macosx.$1
209 | pushd $BUILD_DIR/build.macosx.$1
210 | ../$OPENSSL_VER/Configure --prefix="$BUILD_DIR/macosx-native" --openssldir="$BUILD_DIR/build.macosx.$1/ssl" no-shared darwin64-$1-cc CFLAGS="$2"
211 | make -j$THREAD_COUNT
212 | mv apps/libapps.a ./
213 | popd
214 | touch $BUILD_DIR/build.macosx.$1.success
215 | fi
216 | }
217 |
218 |
219 | ################### BUILD FOR MAC OSX
220 | macosx_build $HOST_ARC "$NATIVE_BUILD_FLAGS"
221 | if [[ ! -d $BUILD_DIR/macosx-native ]]; then
222 | pushd $BUILD_DIR/build.macosx.$HOST_ARC
223 | make install
224 | popd
225 | fi
226 |
227 | [[ "$BUILD_PLATFORMS" == *macosx-$FOREIGN_ARC* ]] && macosx_build $FOREIGN_ARC "$FOREIGN_BUILD_FLAGS"
228 | [[ "$BUILD_PLATFORMS" == *macosx* ]] && build_libs macosx
229 |
230 | [[ "$BUILD_PLATFORMS" == *catalyst* ]] && build_catalyst_libs
231 | [[ "$BUILD_PLATFORMS" == *iossim* ]] && build_iossim_libs
232 | [[ "$BUILD_PLATFORMS" == *xrossim* ]] && build_xrossim_libs
233 | [[ "$BUILD_PLATFORMS" == *tvossim* ]] && build_tvossim_libs
234 | [[ "$BUILD_PLATFORMS" == *watchossim* ]] && build_watchossim_libs
235 |
236 | [[ "$BUILD_PLATFORMS" == *"ios "* ]] && generic_build ios arm64 ios64-xcrun "-fembed-bitcode -mios-version-min=$IOS_VERSION"
237 | [[ "$BUILD_PLATFORMS" == *"xros "* ]] && generic_build xros arm64 xros-xcrun "-fembed-bitcode"
238 | [[ "$BUILD_PLATFORMS" == *"tvos "* ]] && generic_build tvos arm64 tvos-xcrun "-fembed-bitcode -target arm64-apple-tvos$TVOS_VERSION"
239 | [[ "$BUILD_PLATFORMS" == *"watchos "* ]] && generic_build watchos arm64 watchos-xcrun "-fembed-bitcode -target arm64-apple-watchos$WATCHOS_VERSION"
240 |
241 | build_xcframework()
242 | {
243 | LIBARGS=
244 | [[ "$BUILD_PLATFORMS" == *macosx* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.macosx/lib$1.a"
245 | [[ "$BUILD_PLATFORMS" == *catalyst* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.catalyst/lib$1.a"
246 | [[ "$BUILD_PLATFORMS" == *iossim* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.iossim/lib$1.a"
247 | [[ "$BUILD_PLATFORMS" == *xrossim* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.xrossim/lib$1.a"
248 | [[ "$BUILD_PLATFORMS" == *tvossim* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.tvossim/lib$1.a"
249 | [[ "$BUILD_PLATFORMS" == *watchossim* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.watchossim/lib$1.a"
250 | [[ "$BUILD_PLATFORMS" == *"ios "* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.ios.arm64/lib$1.a"
251 | [[ "$BUILD_PLATFORMS" == *"xros "* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.xros.arm64/lib$1.a"
252 | [[ "$BUILD_PLATFORMS" == *"tvos "* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.tvos.arm64/lib$1.a"
253 | [[ "$BUILD_PLATFORMS" == *"watchos "* ]] && LIBARGS="$LIBARGS -library $BUILD_DIR/build.watchos.arm64/lib$1.a"
254 |
255 | xcodebuild -create-xcframework $LIBARGS -output $BUILD_DIR/frameworks/$1.xcframework
256 | }
257 |
258 | [[ -d $BUILD_DIR/frameworks ]] && rm -rf $BUILD_DIR/frameworks
259 | mkdir -p $BUILD_DIR/frameworks
260 | for i in $LIBS_TO_BUILD; do :;
261 | build_xcframework $i
262 | done
263 |
264 | cp -R $BUILD_DIR/build.macosx.$HOST_ARC/include $BUILD_DIR/frameworks/Headers
265 |
--------------------------------------------------------------------------------