Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#993, #1002: Add flexibility for iOS building. Adds command line args… #1004

Merged
merged 2 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Build_iOS/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# iOS folders that dependencies get stored in
boostoniphone/
boost
boost.framework/
ios-cmake/
openssl/
Expand Down
54 changes: 38 additions & 16 deletions Build_iOS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}"
)


Expand All @@ -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}")
67 changes: 63 additions & 4 deletions Build_iOS/configure.sh
Original file line number Diff line number Diff line change
@@ -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!
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ TastenTrick
Christian Deneke (chris0x44)

leetal

Benjamin Lee (mobileben)