Skip to content

Commit 00f4843

Browse files
mobilebenBillyONeal
authored andcommitted
#993, #1002: Add flexibility for iOS building. Adds command line args… (#1004)
* #993, #1002: Add flexibility for iOS building. Adds command line args to configure.sh to allow more customization of iOS lib * Add mobileben to CONTRIBUTORS.txt
1 parent 62af5c0 commit 00f4843

File tree

4 files changed

+104
-20
lines changed

4 files changed

+104
-20
lines changed

Build_iOS/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# iOS folders that dependencies get stored in
22
boostoniphone/
3+
boost
34
boost.framework/
45
ios-cmake/
56
openssl/

Build_iOS/CMakeLists.txt

+38-16
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,23 @@ set(TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ios-cmake/ios.toolchain.cmake")
1212
set(SIM64_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build.x86_64" CACHE INTERNAL "")
1313
set(SIM64_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Release" CACHE INTERNAL "")
1414

15-
set(ARM64_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build.arm64" CACHE INTERNAL "")
16-
set(ARM64_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Release" CACHE INTERNAL "")
15+
set(ARM_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build.arm" CACHE INTERNAL "")
16+
set(ARM_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Release" CACHE INTERNAL "")
17+
18+
if (DISABLE_BITCODE)
19+
set (ENABLE_BITCODE_ARG -DENABLE_BITCODE=OFF)
20+
endif()
21+
22+
if (INCLUDE_32BIT)
23+
set (IOS_PLATFORM_VALUE OS)
24+
else()
25+
set (IOS_PLATFORM_VALUE OS64)
26+
endif()
27+
28+
if (DEPLOYMENT_TARGET)
29+
set (DEPLOYMENT_TARGET -DIOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET})
30+
endif()
31+
1732
add_test(NAME ios_runner
1833
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../Release/tests/common/testrunner/ios
1934
COMMAND xcodebuild test -project ios_runner.xcodeproj -configuration=${CMAKE_BUILD_TYPE} -scheme ios_runner -destination "platform=iOS Simulator,name=iPhone 6" LIBRARY_SEARCH_PATH=${SIM_BINARY_DIR}
@@ -26,17 +41,20 @@ execute_process(WORKING_DIRECTORY ${SIM64_BINARY_DIR}
2641
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}
2742
-DIOS_PLATFORM=SIMULATOR64
2843
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
44+
"${DEPLOYMENT_TARGET}"
2945
"${SIM64_SOURCE_DIR}"
3046
)
3147

32-
file(MAKE_DIRECTORY ${ARM64_BINARY_DIR})
33-
execute_process(WORKING_DIRECTORY ${ARM64_BINARY_DIR}
48+
file(MAKE_DIRECTORY ${ARM_BINARY_DIR})
49+
execute_process(WORKING_DIRECTORY ${ARM_BINARY_DIR}
3450
COMMAND ${CMAKE_COMMAND}
3551
-GXcode
3652
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}
37-
-DIOS_PLATFORM=OS64
53+
-DIOS_PLATFORM=${IOS_PLATFORM_VALUE}
3854
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
39-
"${ARM64_SOURCE_DIR}"
55+
"${DEPLOYMENT_TARGET}"
56+
"${ENABLE_BITCODE_ARG}"
57+
"${ARM_SOURCE_DIR}"
4058
)
4159

4260

@@ -49,28 +67,32 @@ add_custom_target(sim64
4967
VERBATIM
5068
)
5169

52-
## ARM64 version
53-
add_custom_target(arm64
70+
## ARM version
71+
add_custom_target(arm
5472
COMMAND ${CMAKE_COMMAND}
55-
--build ${ARM64_BINARY_DIR}
73+
--build ${ARM_BINARY_DIR}
5674
--config ${CMAKE_BUILD_TYPE}
57-
COMMENT "Building for arm64"
75+
COMMENT "Building for arm"
5876
VERBATIM
5977
)
6078

6179
set(LIB_CPPREST libcpprest.a)
80+
set(LIB_CPPREST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib")
81+
6282
add_custom_command(
63-
OUTPUT ${LIB_CPPREST}
83+
OUTPUT ${LIB_CPPREST_LIB_DIR}/${LIB_CPPREST}
84+
COMMAND mkdir -p "${LIB_CPPREST_LIB_DIR}"
6485
COMMAND lipo -create
65-
-output "${CMAKE_CURRENT_BINARY_DIR}/${LIB_CPPREST}"
86+
-output "${LIB_CPPREST_LIB_DIR}/${LIB_CPPREST}"
6687
${SIM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}
67-
${ARM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}
88+
${ARM_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}
89+
COMMAND cp -R "${CMAKE_CURRENT_SOURCE_DIR}/../Release/include" "${CMAKE_CURRENT_BINARY_DIR}"
6890
DEPENDS
6991
sim64
70-
arm64
92+
arm
7193
"${SIM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}"
72-
"${ARM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}"
94+
"${ARM_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}"
7395
VERBATIM
7496
)
7597

76-
add_custom_target(cpprest ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LIB_CPPREST})
98+
add_custom_target(cpprest ALL DEPENDS "${LIB_CPPREST_LIB_DIR}/${LIB_CPPREST}")

Build_iOS/configure.sh

+63-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/usr/bin/env bash
22
set -e
33

4+
usage() {
5+
echo "Usage: configure.sh [-build_type type] [-deployment_target version] [-config_only] [-include_32bit] [-no_bitcode]"
6+
echo " -build_type defines the CMAKE_BUILD_TYPE used. Defaults to Release."
7+
echo " -deployment_target defines minimum iOS Deployment Target. The default is dependent on ios.toolchain.cmake and currently defaults to 8.0"
8+
echo " -config_only only configures cmake (no make invoked)."
9+
echo " -include_32bit includes the 32-bit arm architectures."
10+
echo " -no_bitcode disables bitcode"
11+
}
12+
413
ABS_PATH="`dirname \"$0\"`" # relative
514
ABS_PATH="`( cd \"${ABS_PATH}\" && pwd )`" # absolutized and normalized
615
# Make sure that the path to this file exists and can be retrieved!
@@ -9,6 +18,54 @@ if [ -z "${ABS_PATH}" ]; then
918
exit 1
1019
fi
1120

21+
CONFIG_ONLY=0
22+
INCLUDE_32BIT=""
23+
DISABLE_BITCODE=""
24+
DEPLOYMENT_TARGET=""
25+
26+
# Command line argument parsing
27+
while (( "$#" )); do
28+
case "$1" in
29+
-build_type)
30+
if [ "$#" -lt 2 ] || [[ "$2" == -* ]] ; then
31+
usage
32+
echo "Error: argument $1 expecting a value to follow."
33+
exit 1
34+
fi
35+
36+
CPPRESTSDK_BUILD_TYPE=$2
37+
shift 2
38+
;;
39+
-deployment_target)
40+
if [ "$#" -lt 2 ] || [[ "$2" == -* ]] ; then
41+
usage
42+
echo "Error: argument $1 expecting a value to follow."
43+
exit 1
44+
fi
45+
46+
DEPLOYMENT_TARGET="-DDEPLOYMENT_TARGET=$2"
47+
shift 2
48+
;;
49+
-config_only)
50+
CONFIG_ONLY=1
51+
shift 1
52+
;;
53+
-include_32bit)
54+
INCLUDE_32BIT="-DINCLUDE_32BIT=ON"
55+
shift 1
56+
;;
57+
-no_bitcode)
58+
DISABLE_BITCODE="-DDISABLE_BITCODE=ON"
59+
shift 1
60+
;;
61+
*)
62+
usage
63+
echo "Error: unsupported argument $1"
64+
exit 1
65+
;;
66+
esac
67+
done
68+
1269
## Configuration
1370
DEFAULT_BOOST_VERSION=1.67.0
1471
DEFAULT_OPENSSL_VERSION=1.0.2o
@@ -28,7 +85,7 @@ git submodule update --init
2885

2986
## Build Boost
3087

31-
if [ ! -e $ABS_PATH/boost.framework ]; then
88+
if [ ! -e $ABS_PATH/boost.framework ] && [ ! -d $ABS_PATH/boost ]; then
3289
if [ ! -d "${ABS_PATH}/Apple-Boost-BuildScript" ]; then
3390
git clone https://github.com/faithfracture/Apple-Boost-BuildScript ${ABS_PATH}/Apple-Boost-BuildScript
3491
fi
@@ -80,9 +137,11 @@ fi
80137

81138
mkdir -p ${ABS_PATH}/build.${CPPRESTSDK_BUILD_TYPE}.ios
82139
pushd ${ABS_PATH}/build.${CPPRESTSDK_BUILD_TYPE}.ios
83-
cmake -DCMAKE_BUILD_TYPE=${CPPRESTSDK_BUILD_TYPE} ..
84-
make
140+
cmake -DCMAKE_BUILD_TYPE=${CPPRESTSDK_BUILD_TYPE} .. ${INCLUDE_32BIT} ${DISABLE_BITCODE} ${DEPLOYMENT_TARGET}
141+
if [ "$CONFIG_ONLY" -eq 0 ]; then
142+
make
143+
fi
85144
popd
86145
printf "\n\n===================================================================================\n"
87-
echo ">>>> The final library is available in 'build.${CPPRESTSDK_BUILD_TYPE}.ios/libcpprest.a'"
146+
echo ">>>> The final library is available in 'build.${CPPRESTSDK_BUILD_TYPE}.ios/lib/libcpprest.a'"
88147
printf "===================================================================================\n\n"

CONTRIBUTORS.txt

+2
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ TastenTrick
5151
Christian Deneke (chris0x44)
5252

5353
leetal
54+
55+
Benjamin Lee (mobileben)

0 commit comments

Comments
 (0)