Skip to content

Commit 7222fa2

Browse files
leetalBillyONeal
authored andcommitted
Fixes iOS builds and makes it more future proof (#961)
* Fixed builds for iOS to be more future proof * Added possibility to change OpenSSL version * Add leetal to CONTRIBUTORS.txt
1 parent 0864365 commit 7222fa2

File tree

3 files changed

+74
-41
lines changed

3 files changed

+74
-41
lines changed

Build_iOS/configure.sh

Lines changed: 68 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,88 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -e
33

4-
if [ ! -e boost.framework ]
5-
then
6-
git clone https://github.com/faithfracture/Apple-Boost-BuildScript Apple-Boost-BuildScript
7-
pushd ./Apple-Boost-BuildScript
4+
ABS_PATH="`dirname \"$0\"`" # relative
5+
ABS_PATH="`( cd \"${ABS_PATH}\" && pwd )`" # absolutized and normalized
6+
# Make sure that the path to this file exists and can be retrieved!
7+
if [ -z "${ABS_PATH}" ]; then
8+
echo "Could not fetch the ABS_PATH."
9+
exit 1
10+
fi
11+
12+
## Configuration
13+
DEFAULT_BOOST_VERSION=1.67.0
14+
DEFAULT_OPENSSL_VERSION=1.0.2o
15+
BOOST_VERSION=${BOOST_VERSION:-${DEFAULT_BOOST_VERSION}}
16+
OPENSSL_VERSION=${OPENSSL_VERSION:-${DEFAULT_OPENSSL_VERSION}}
17+
CPPRESTSDK_BUILD_TYPE=${CPPRESTSDK_BUILD_TYPE:-Release}
18+
19+
############################ No need to edit anything below this line
20+
21+
## Set some needed variables
22+
IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
23+
24+
## Buildsteps below
25+
26+
## Fetch submodules just in case
27+
git submodule update --init
28+
29+
## Build Boost
30+
31+
if [ ! -e $ABS_PATH/boost.framework ]; then
32+
if [ ! -d "${ABS_PATH}/Apple-Boost-BuildScript" ]; then
33+
git clone https://github.com/faithfracture/Apple-Boost-BuildScript ${ABS_PATH}/Apple-Boost-BuildScript
34+
fi
35+
pushd ${ABS_PATH}/Apple-Boost-BuildScript
836
git checkout 1b94ec2e2b5af1ee036d9559b96e70c113846392
9-
BOOST_LIBS="thread chrono filesystem regex system random" ./boost.sh -ios -tvos
37+
BOOST_LIBS="thread chrono filesystem regex system random" ./boost.sh -ios -tvos --boost-version $BOOST_VERSION
1038
popd
11-
mv Apple-Boost-BuildScript/build/boost/1.67.0/ios/framework/boost.framework .
12-
mv boost.framework/Versions/A/Headers boost.headers
13-
mkdir -p boost.framework/Versions/A/Headers
14-
mv boost.headers boost.framework/Versions/A/Headers/boost
39+
mv ${ABS_PATH}/Apple-Boost-BuildScript/build/boost/${BOOST_VERSION}/ios/framework/boost.framework ${ABS_PATH}
40+
mv ${ABS_PATH}/boost.framework/Versions/A/Headers ${ABS_PATH}/boost.headers
41+
mkdir -p ${ABS_PATH}/boost.framework/Versions/A/Headers
42+
mv ${ABS_PATH}/boost.headers ${ABS_PATH}/boost.framework/Versions/A/Headers/boost
1543
fi
1644

17-
if [ ! -e openssl/lib/libcrypto.a ]
18-
then
19-
git clone --depth=1 https://github.com/x2on/OpenSSL-for-iPhone.git
20-
pushd OpenSSL-for-iPhone
45+
## Build OpenSSL
46+
47+
if [ ! -e ${ABS_PATH}/openssl/lib/libcrypto.a ]; then
48+
if [ ! -d "${ABS_PATH}/OpenSSL-for-iPhone" ]; then
49+
git clone --depth=1 https://github.com/x2on/OpenSSL-for-iPhone.git ${ABS_PATH}/OpenSSL-for-iPhone
50+
fi
51+
pushd ${ABS_PATH}/OpenSSL-for-iPhone
2152
git checkout 10019638e80e8a8a5fc19642a840d8a69fac7349
22-
./build-libssl.sh
53+
./build-libssl.sh --version=${OPENSSL_VERSION}
2354
popd
24-
mkdir -p openssl/lib
25-
if [ -e OpenSSL-for-iPhone/bin/iPhoneOS11.4-arm64.sdk/include ]
26-
then
27-
cp -r OpenSSL-for-iPhone/bin/iPhoneOS11.4-arm64.sdk/include openssl
28-
elif [ -e OpenSSL-for-iPhone/bin/iPhoneOS12.0-arm64.sdk/include ]
55+
mkdir -p ${ABS_PATH}/openssl/lib
56+
if [ -e ${ABS_PATH}/OpenSSL-for-iPhone/bin/iPhoneOS${IOS_SDK_VERSION}-arm64.sdk/include ]
2957
then
30-
cp -r OpenSSL-for-iPhone/bin/iPhoneOS12.0-arm64.sdk/include openssl
58+
cp -r ${ABS_PATH}/OpenSSL-for-iPhone/bin/iPhoneOS${IOS_SDK_VERSION}-arm64.sdk/include ${ABS_PATH}/openssl
3159
else
3260
echo 'Could not find OpenSSL for iPhone'
3361
exit 1
3462
fi
35-
cp OpenSSL-for-iPhone/include/LICENSE openssl
36-
lipo -create -output openssl/lib/libssl.a OpenSSL-for-iPhone/bin/iPhone*/lib/libssl.a
37-
lipo -create -output openssl/lib/libcrypto.a OpenSSL-for-iPhone/bin/iPhone*/lib/libcrypto.a
63+
cp ${ABS_PATH}/OpenSSL-for-iPhone/include/LICENSE ${ABS_PATH}/openssl
64+
lipo -create -output ${ABS_PATH}/openssl/lib/libssl.a ${ABS_PATH}/OpenSSL-for-iPhone/bin/iPhone*/lib/libssl.a
65+
lipo -create -output ${ABS_PATH}/openssl/lib/libcrypto.a ${ABS_PATH}/OpenSSL-for-iPhone/bin/iPhone*/lib/libcrypto.a
3866
fi
3967

40-
if [ ! -e ios-cmake/ios.toolchain.cmake ]
41-
then
42-
git clone https://github.com/leetal/ios-cmake
43-
pushd ios-cmake
44-
git checkout 6b30f4cfeab5567041d38e79507e642056fb9fd4
68+
## Fetch CMake toolchain
69+
70+
if [ ! -e ${ABS_PATH}/ios-cmake/ios.toolchain.cmake ]; then
71+
if [ ! -d "${ABS_PATH}/ios-cmake" ]; then
72+
git clone https://github.com/leetal/ios-cmake ${ABS_PATH}/ios-cmake
73+
fi
74+
pushd ${ABS_PATH}/ios-cmake
75+
git checkout 2.1.2
4576
popd
4677
fi
4778

48-
mkdir -p build.release.ios
49-
pushd build.release.ios
50-
cmake -DCMAKE_BUILD_TYPE=Release ..
79+
## Build CPPRestSDK
80+
81+
mkdir -p ${ABS_PATH}/build.${CPPRESTSDK_BUILD_TYPE}.ios
82+
pushd ${ABS_PATH}/build.${CPPRESTSDK_BUILD_TYPE}.ios
83+
cmake -DCMAKE_BUILD_TYPE=${CPPRESTSDK_BUILD_TYPE} ..
5184
make
5285
popd
53-
echo "===="
54-
echo "The final library is available in 'build.ios/libcpprest.a'"
86+
printf "\n\n===================================================================================\n"
87+
echo ">>>> The final library is available in 'build.${CPPRESTSDK_BUILD_TYPE}.ios/libcpprest.a'"
88+
printf "===================================================================================\n\n"

CONTRIBUTORS.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Contributors should submit an update to this file with a commit in order to receive recognition. Thank you for your contributions.
1+
Contributors should submit an update to this file with a commit in order to receive recognition. Thank you for your contributions.
22

33

44
List of Contributors
@@ -17,7 +17,7 @@ intercommiura
1717
halex2005
1818
simonlep
1919
jracle
20-
gandziej
20+
gandziej
2121
adish
2222
LeonidCSIT
2323
kreuzerkrieg
@@ -48,4 +48,6 @@ Tim Boundy (gigaplex)
4848
Rami Abughazaleh (icnocop)
4949

5050
TastenTrick
51-
Christian Deneke (chris0x44)
51+
Christian Deneke (chris0x44)
52+
53+
leetal

Release/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ set(WARNINGS)
116116
set(ANDROID_LIBS)
117117

118118
# Platform (not compiler) specific settings
119-
if(IOS)
120-
# The cxx_flags must be reset here, because the ios-cmake toolchain file unfortunately sets "-headerpad_max_install_names" which is not a valid clang flag.
121-
set(CMAKE_CXX_FLAGS "-fvisibility=hidden")
122-
elseif(ANDROID)
119+
if(ANDROID)
123120
# These are used in the shared library case
124121
set(ANDROID_LIBS atomic dl)
125122
elseif(UNIX) # This includes OSX

0 commit comments

Comments
 (0)