Skip to content

Commit

Permalink
Enable build for iOS in Pipelines. (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal committed Oct 17, 2018
1 parent a2d2d3c commit 14b439c
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 318 deletions.
11 changes: 6 additions & 5 deletions .gitignore
@@ -1,4 +1,4 @@
#Visual Studio files
# Visual Studio files
*.o
*.d
*.so
Expand Down Expand Up @@ -38,7 +38,7 @@
*~
ipch/
obj/
#OSX files
# OSX files
*.xccheckout
*.pbxuser
*.mode1v3
Expand Down Expand Up @@ -67,7 +67,8 @@ Intermediate/
# Ignore cmake building directories
build.*/
docs/
# ignore NuGet artifacts
# Ignore NuGet artifacts
.nuget/

Generated Files/
Generated Files/
# Ignore iOS temp build directories
Build_iOS/Apple-Boost-BuildScript
61 changes: 15 additions & 46 deletions Build_iOS/CMakeLists.txt
@@ -1,73 +1,45 @@
project(casablanca-ios NONE)
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.1)

enable_testing()

if (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)
set (ENV{CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET} ${CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET})
endif()

set(TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/iOS.cmake")

set(SIM_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build.i386" CACHE INTERNAL "")
set(SIM_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Release" CACHE INTERNAL "")
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(ARM_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build.arm" CACHE INTERNAL "")
set(ARM_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 "")
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}
)

file(MAKE_DIRECTORY ${SIM_BINARY_DIR})
execute_process(WORKING_DIRECTORY ${SIM_BINARY_DIR}
COMMAND ${CMAKE_COMMAND}
-GXcode
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}
-DIOS_PLATFORM=SIMULATOR
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CLANG_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CLANG_CXX_COMPILER}
"${SIM_SOURCE_DIR}"
)

file(MAKE_DIRECTORY ${SIM64_BINARY_DIR})
execute_process(WORKING_DIRECTORY ${SIM64_BINARY_DIR}
COMMAND ${CMAKE_COMMAND}
-GXcode
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}
-DIOS_PLATFORM=SIMULATOR64
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CLANG_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CLANG_CXX_COMPILER}
"${SIM64_SOURCE_DIR}"
)

file(MAKE_DIRECTORY ${ARM_BINARY_DIR})
execute_process(WORKING_DIRECTORY ${ARM_BINARY_DIR}
file(MAKE_DIRECTORY ${ARM64_BINARY_DIR})
execute_process(WORKING_DIRECTORY ${ARM64_BINARY_DIR}
COMMAND ${CMAKE_COMMAND}
-GXcode
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}
-DIOS_PLATFORM=OS
-DIOS_PLATFORM=OS64
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CLANG_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CLANG_CXX_COMPILER}
"${ARM_SOURCE_DIR}"
"${ARM64_SOURCE_DIR}"
)


## Simulator i386 version
add_custom_target(sim
COMMAND ${CMAKE_COMMAND}
--build ${SIM_BINARY_DIR}
--config ${CMAKE_BUILD_TYPE}
COMMENT "Building for i386 (simulator)"
VERBATIM
)

## Simulator x86_64 version
add_custom_target(sim64
COMMAND ${CMAKE_COMMAND}
Expand All @@ -77,12 +49,12 @@ add_custom_target(sim64
VERBATIM
)

## ARM version
add_custom_target(arm
## ARM64 version
add_custom_target(arm64
COMMAND ${CMAKE_COMMAND}
--build ${ARM_BINARY_DIR}
--build ${ARM64_BINARY_DIR}
--config ${CMAKE_BUILD_TYPE}
COMMENT "Building for armv7, armv7s, arm64"
COMMENT "Building for arm64"
VERBATIM
)

Expand All @@ -91,16 +63,13 @@ add_custom_command(
OUTPUT ${LIB_CPPREST}
COMMAND lipo -create
-output "${CMAKE_CURRENT_BINARY_DIR}/${LIB_CPPREST}"
${SIM_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}
${SIM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}
${ARM_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}
${ARM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}
DEPENDS
sim
sim64
arm
"${SIM_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}"
arm64
"${SIM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}"
"${ARM_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}"
"${ARM64_BINARY_DIR}/Binaries/${CMAKE_BUILD_TYPE}/${LIB_CPPREST}"
VERBATIM
)

Expand Down
68 changes: 39 additions & 29 deletions Build_iOS/configure.sh
Expand Up @@ -2,42 +2,52 @@
set -e

if [ ! -e boost.framework ]
then
git clone -n https://github.com/faithfracture/Apple-Boost-BuildScript Apple-Boost-BuildScript
pushd Apple-Boost-BuildScript
git checkout 86f7570fceaef00846cc75f59c61474758fc65cb
BOOST_LIBS="thread chrono filesystem regex system random" ./boost.sh
popd
mv Apple-Boost-BuildScript/build/boost/1.63.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
then
git clone https://github.com/faithfracture/Apple-Boost-BuildScript Apple-Boost-BuildScript
pushd ./Apple-Boost-BuildScript
git checkout 1b94ec2e2b5af1ee036d9559b96e70c113846392
BOOST_LIBS="thread chrono filesystem regex system random" ./boost.sh -ios -tvos
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
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-libssl.sh
popd
mkdir -p openssl/lib
cp -r OpenSSL-for-iPhone/bin/iPhoneOS9.2-armv7.sdk/include openssl
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
then
git clone --depth=1 https://github.com/x2on/OpenSSL-for-iPhone.git
pushd OpenSSL-for-iPhone
git checkout 10019638e80e8a8a5fc19642a840d8a69fac7349
./build-libssl.sh
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 ]
then
cp -r OpenSSL-for-iPhone/bin/iPhoneOS12.0-arm64.sdk/include 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
fi

if [ ! -e ios-cmake/toolchain/iOS.cmake ]
then
git clone https://github.com/cristeab/ios-cmake.git
pushd ios-cmake
git apply ../fix_ios_cmake_compiler.patch
popd
if [ ! -e ios-cmake/ios.toolchain.cmake ]
then
git clone https://github.com/leetal/ios-cmake
pushd ios-cmake
git checkout 6b30f4cfeab5567041d38e79507e642056fb9fd4
popd
fi

mkdir -p build.ios
pushd build.ios
cmake .. -DCMAKE_BUILD_TYPE=Release
mkdir -p build.release.ios
pushd build.release.ios
cmake -DCMAKE_BUILD_TYPE=Release ..
make
popd
echo "===="
Expand Down
13 changes: 0 additions & 13 deletions Build_iOS/fix_boost_building_script.patch

This file was deleted.

0 comments on commit 14b439c

Please sign in to comment.