diff --git a/Build_iOS/.gitignore b/Build_iOS/.gitignore index 525689cf70..93f4744bb6 100644 --- a/Build_iOS/.gitignore +++ b/Build_iOS/.gitignore @@ -1,5 +1,6 @@ # iOS folders that dependencies get stored in boostoniphone/ +boost boost.framework/ ios-cmake/ openssl/ diff --git a/Build_iOS/CMakeLists.txt b/Build_iOS/CMakeLists.txt index 3c1e37c130..048a49a575 100644 --- a/Build_iOS/CMakeLists.txt +++ b/Build_iOS/CMakeLists.txt @@ -12,8 +12,23 @@ set(TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ios-cmake/ios.toolchain.cmake") set(SIM64_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build.x86_64" CACHE INTERNAL "") set(SIM64_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Release" CACHE INTERNAL "") -set(ARM64_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build.arm64" CACHE INTERNAL "") -set(ARM64_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Release" CACHE INTERNAL "") +set(ARM_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build.arm" CACHE INTERNAL "") +set(ARM_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Release" CACHE INTERNAL "") + +if (DISABLE_BITCODE) + set (ENABLE_BITCODE_ARG -DENABLE_BITCODE=OFF) +endif() + +if (INCLUDE_32BIT) + set (IOS_PLATFORM_VALUE OS) +else() + set (IOS_PLATFORM_VALUE OS64) +endif() + +if (DEPLOYMENT_TARGET) + set (DEPLOYMENT_TARGET -DIOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET}) +endif() + add_test(NAME ios_runner WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../Release/tests/common/testrunner/ios 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} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} -DIOS_PLATFORM=SIMULATOR64 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + "${DEPLOYMENT_TARGET}" "${SIM64_SOURCE_DIR}" ) -file(MAKE_DIRECTORY ${ARM64_BINARY_DIR}) -execute_process(WORKING_DIRECTORY ${ARM64_BINARY_DIR} +file(MAKE_DIRECTORY ${ARM_BINARY_DIR}) +execute_process(WORKING_DIRECTORY ${ARM_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -GXcode -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} - -DIOS_PLATFORM=OS64 + -DIOS_PLATFORM=${IOS_PLATFORM_VALUE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - "${ARM64_SOURCE_DIR}" + "${DEPLOYMENT_TARGET}" + "${ENABLE_BITCODE_ARG}" + "${ARM_SOURCE_DIR}" ) @@ -49,28 +67,32 @@ add_custom_target(sim64 VERBATIM ) -## ARM64 version -add_custom_target(arm64 +## ARM version +add_custom_target(arm COMMAND ${CMAKE_COMMAND} - --build ${ARM64_BINARY_DIR} + --build ${ARM_BINARY_DIR} --config ${CMAKE_BUILD_TYPE} - COMMENT "Building for arm64" + COMMENT "Building for arm" VERBATIM ) set(LIB_CPPREST libcpprest.a) +set(LIB_CPPREST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib") + add_custom_command( - OUTPUT ${LIB_CPPREST} + OUTPUT ${LIB_CPPREST_LIB_DIR}/${LIB_CPPREST} + COMMAND mkdir -p "${LIB_CPPREST_LIB_DIR}" COMMAND lipo -create - -output "${CMAKE_CURRENT_BINARY_DIR}/${LIB_CPPREST}" + -output "${LIB_CPPREST_LIB_DIR}/${LIB_CPPREST}" ${SIM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST} - ${ARM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST} + ${ARM_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST} + COMMAND cp -R "${CMAKE_CURRENT_SOURCE_DIR}/../Release/include" "${CMAKE_CURRENT_BINARY_DIR}" DEPENDS sim64 - arm64 + arm "${SIM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}" - "${ARM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}" + "${ARM_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}" VERBATIM ) -add_custom_target(cpprest ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LIB_CPPREST}) +add_custom_target(cpprest ALL DEPENDS "${LIB_CPPREST_LIB_DIR}/${LIB_CPPREST}") diff --git a/Build_iOS/configure.sh b/Build_iOS/configure.sh index 5560adfd52..5f7285edfe 100755 --- a/Build_iOS/configure.sh +++ b/Build_iOS/configure.sh @@ -1,6 +1,15 @@ #!/usr/bin/env bash set -e +usage() { + echo "Usage: configure.sh [-build_type type] [-deployment_target version] [-config_only] [-include_32bit] [-no_bitcode]" + echo " -build_type defines the CMAKE_BUILD_TYPE used. Defaults to Release." + echo " -deployment_target defines minimum iOS Deployment Target. The default is dependent on ios.toolchain.cmake and currently defaults to 8.0" + echo " -config_only only configures cmake (no make invoked)." + echo " -include_32bit includes the 32-bit arm architectures." + echo " -no_bitcode disables bitcode" +} + 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! @@ -9,6 +18,54 @@ if [ -z "${ABS_PATH}" ]; then exit 1 fi +CONFIG_ONLY=0 +INCLUDE_32BIT="" +DISABLE_BITCODE="" +DEPLOYMENT_TARGET="" + +# Command line argument parsing +while (( "$#" )); do + case "$1" in + -build_type) + if [ "$#" -lt 2 ] || [[ "$2" == -* ]] ; then + usage + echo "Error: argument $1 expecting a value to follow." + exit 1 + fi + + CPPRESTSDK_BUILD_TYPE=$2 + shift 2 + ;; + -deployment_target) + if [ "$#" -lt 2 ] || [[ "$2" == -* ]] ; then + usage + echo "Error: argument $1 expecting a value to follow." + exit 1 + fi + + DEPLOYMENT_TARGET="-DDEPLOYMENT_TARGET=$2" + shift 2 + ;; + -config_only) + CONFIG_ONLY=1 + shift 1 + ;; + -include_32bit) + INCLUDE_32BIT="-DINCLUDE_32BIT=ON" + shift 1 + ;; + -no_bitcode) + DISABLE_BITCODE="-DDISABLE_BITCODE=ON" + shift 1 + ;; + *) + usage + echo "Error: unsupported argument $1" + exit 1 + ;; + esac +done + ## Configuration DEFAULT_BOOST_VERSION=1.67.0 DEFAULT_OPENSSL_VERSION=1.0.2o @@ -28,7 +85,7 @@ git submodule update --init ## Build Boost -if [ ! -e $ABS_PATH/boost.framework ]; then +if [ ! -e $ABS_PATH/boost.framework ] && [ ! -d $ABS_PATH/boost ]; then if [ ! -d "${ABS_PATH}/Apple-Boost-BuildScript" ]; then git clone https://github.com/faithfracture/Apple-Boost-BuildScript ${ABS_PATH}/Apple-Boost-BuildScript fi @@ -80,9 +137,11 @@ fi 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 +cmake -DCMAKE_BUILD_TYPE=${CPPRESTSDK_BUILD_TYPE} .. ${INCLUDE_32BIT} ${DISABLE_BITCODE} ${DEPLOYMENT_TARGET} +if [ "$CONFIG_ONLY" -eq 0 ]; then + make +fi popd printf "\n\n===================================================================================\n" -echo ">>>> The final library is available in 'build.${CPPRESTSDK_BUILD_TYPE}.ios/libcpprest.a'" +echo ">>>> The final library is available in 'build.${CPPRESTSDK_BUILD_TYPE}.ios/lib/libcpprest.a'" printf "===================================================================================\n\n" diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 8563fe4072..0dc78ed38f 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -51,3 +51,5 @@ TastenTrick Christian Deneke (chris0x44) leetal + +Benjamin Lee (mobileben)