-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
0864365
commit 7222fa2
Showing
3 changed files
with
74 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,88 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
if [ ! -e boost.framework ] | ||
then | ||
git clone https://github.com/faithfracture/Apple-Boost-BuildScript Apple-Boost-BuildScript | ||
pushd ./Apple-Boost-BuildScript | ||
ABS_PATH="`dirname \"$0\"`" # relative | ||
ABS_PATH="`( cd \"${ABS_PATH}\" && pwd )`" # absolutized and normalized | ||
# Make sure that the path to this file exists and can be retrieved! | ||
if [ -z "${ABS_PATH}" ]; then | ||
echo "Could not fetch the ABS_PATH." | ||
exit 1 | ||
fi | ||
|
||
## Configuration | ||
DEFAULT_BOOST_VERSION=1.67.0 | ||
DEFAULT_OPENSSL_VERSION=1.0.2o | ||
BOOST_VERSION=${BOOST_VERSION:-${DEFAULT_BOOST_VERSION}} | ||
OPENSSL_VERSION=${OPENSSL_VERSION:-${DEFAULT_OPENSSL_VERSION}} | ||
CPPRESTSDK_BUILD_TYPE=${CPPRESTSDK_BUILD_TYPE:-Release} | ||
|
||
############################ No need to edit anything below this line | ||
|
||
## Set some needed variables | ||
IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version` | ||
|
||
## Buildsteps below | ||
|
||
## Fetch submodules just in case | ||
git submodule update --init | ||
|
||
## Build Boost | ||
|
||
if [ ! -e $ABS_PATH/boost.framework ]; then | ||
if [ ! -d "${ABS_PATH}/Apple-Boost-BuildScript" ]; then | ||
git clone https://github.com/faithfracture/Apple-Boost-BuildScript ${ABS_PATH}/Apple-Boost-BuildScript | ||
fi | ||
pushd ${ABS_PATH}/Apple-Boost-BuildScript | ||
git checkout 1b94ec2e2b5af1ee036d9559b96e70c113846392 | ||
BOOST_LIBS="thread chrono filesystem regex system random" ./boost.sh -ios -tvos | ||
BOOST_LIBS="thread chrono filesystem regex system random" ./boost.sh -ios -tvos --boost-version $BOOST_VERSION | ||
popd | ||
mv Apple-Boost-BuildScript/build/boost/1.67.0/ios/framework/boost.framework . | ||
mv boost.framework/Versions/A/Headers boost.headers | ||
mkdir -p boost.framework/Versions/A/Headers | ||
mv boost.headers boost.framework/Versions/A/Headers/boost | ||
mv ${ABS_PATH}/Apple-Boost-BuildScript/build/boost/${BOOST_VERSION}/ios/framework/boost.framework ${ABS_PATH} | ||
mv ${ABS_PATH}/boost.framework/Versions/A/Headers ${ABS_PATH}/boost.headers | ||
mkdir -p ${ABS_PATH}/boost.framework/Versions/A/Headers | ||
mv ${ABS_PATH}/boost.headers ${ABS_PATH}/boost.framework/Versions/A/Headers/boost | ||
fi | ||
|
||
if [ ! -e openssl/lib/libcrypto.a ] | ||
then | ||
git clone --depth=1 https://github.com/x2on/OpenSSL-for-iPhone.git | ||
pushd OpenSSL-for-iPhone | ||
## Build OpenSSL | ||
|
||
if [ ! -e ${ABS_PATH}/openssl/lib/libcrypto.a ]; then | ||
if [ ! -d "${ABS_PATH}/OpenSSL-for-iPhone" ]; then | ||
git clone --depth=1 https://github.com/x2on/OpenSSL-for-iPhone.git ${ABS_PATH}/OpenSSL-for-iPhone | ||
fi | ||
pushd ${ABS_PATH}/OpenSSL-for-iPhone | ||
git checkout 10019638e80e8a8a5fc19642a840d8a69fac7349 | ||
./build-libssl.sh | ||
./build-libssl.sh --version=${OPENSSL_VERSION} | ||
popd | ||
mkdir -p openssl/lib | ||
if [ -e OpenSSL-for-iPhone/bin/iPhoneOS11.4-arm64.sdk/include ] | ||
then | ||
cp -r OpenSSL-for-iPhone/bin/iPhoneOS11.4-arm64.sdk/include openssl | ||
elif [ -e OpenSSL-for-iPhone/bin/iPhoneOS12.0-arm64.sdk/include ] | ||
mkdir -p ${ABS_PATH}/openssl/lib | ||
if [ -e ${ABS_PATH}/OpenSSL-for-iPhone/bin/iPhoneOS${IOS_SDK_VERSION}-arm64.sdk/include ] | ||
then | ||
cp -r OpenSSL-for-iPhone/bin/iPhoneOS12.0-arm64.sdk/include openssl | ||
cp -r ${ABS_PATH}/OpenSSL-for-iPhone/bin/iPhoneOS${IOS_SDK_VERSION}-arm64.sdk/include ${ABS_PATH}/openssl | ||
else | ||
echo 'Could not find OpenSSL for iPhone' | ||
exit 1 | ||
fi | ||
cp OpenSSL-for-iPhone/include/LICENSE openssl | ||
lipo -create -output openssl/lib/libssl.a OpenSSL-for-iPhone/bin/iPhone*/lib/libssl.a | ||
lipo -create -output openssl/lib/libcrypto.a OpenSSL-for-iPhone/bin/iPhone*/lib/libcrypto.a | ||
cp ${ABS_PATH}/OpenSSL-for-iPhone/include/LICENSE ${ABS_PATH}/openssl | ||
lipo -create -output ${ABS_PATH}/openssl/lib/libssl.a ${ABS_PATH}/OpenSSL-for-iPhone/bin/iPhone*/lib/libssl.a | ||
lipo -create -output ${ABS_PATH}/openssl/lib/libcrypto.a ${ABS_PATH}/OpenSSL-for-iPhone/bin/iPhone*/lib/libcrypto.a | ||
fi | ||
|
||
if [ ! -e ios-cmake/ios.toolchain.cmake ] | ||
then | ||
git clone https://github.com/leetal/ios-cmake | ||
pushd ios-cmake | ||
git checkout 6b30f4cfeab5567041d38e79507e642056fb9fd4 | ||
## Fetch CMake toolchain | ||
|
||
if [ ! -e ${ABS_PATH}/ios-cmake/ios.toolchain.cmake ]; then | ||
if [ ! -d "${ABS_PATH}/ios-cmake" ]; then | ||
git clone https://github.com/leetal/ios-cmake ${ABS_PATH}/ios-cmake | ||
fi | ||
pushd ${ABS_PATH}/ios-cmake | ||
git checkout 2.1.2 | ||
popd | ||
fi | ||
|
||
mkdir -p build.release.ios | ||
pushd build.release.ios | ||
cmake -DCMAKE_BUILD_TYPE=Release .. | ||
## Build CPPRestSDK | ||
|
||
mkdir -p ${ABS_PATH}/build.${CPPRESTSDK_BUILD_TYPE}.ios | ||
pushd ${ABS_PATH}/build.${CPPRESTSDK_BUILD_TYPE}.ios | ||
cmake -DCMAKE_BUILD_TYPE=${CPPRESTSDK_BUILD_TYPE} .. | ||
make | ||
popd | ||
echo "====" | ||
echo "The final library is available in 'build.ios/libcpprest.a'" | ||
printf "\n\n===================================================================================\n" | ||
echo ">>>> The final library is available in 'build.${CPPRESTSDK_BUILD_TYPE}.ios/libcpprest.a'" | ||
printf "===================================================================================\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters