From f79223e2acf1c749f1d8d319886f9d35b04a0354 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 6 Sep 2021 10:37:58 +0300 Subject: [PATCH] Simplify ios/build.sh. --- example/ios/Python-Apple-support.patch | 12 ++-- example/ios/README.md | 4 +- example/ios/build.sh | 88 +++++++++++--------------- 3 files changed, 42 insertions(+), 62 deletions(-) diff --git a/example/ios/Python-Apple-support.patch b/example/ios/Python-Apple-support.patch index 13d56ada8..65845102c 100644 --- a/example/ios/Python-Apple-support.patch +++ b/example/ios/Python-Apple-support.patch @@ -6,16 +6,12 @@ index 695be54..4efe5e5 100644 # - iOS - build everything for iOS # - tvOS - build everything for tvOS # - watchOS - build everything for watchOS --# - OpenSSL-macOS - build OpenSSL for macOS --# - OpenSSL-iOS - build OpenSSL for iOS --# - OpenSSL-tvOS - build OpenSSL for tvOS --# - OpenSSL-watchOS - build OpenSSL for watchOS -+# - OpenSSL-macOS - build OpenSSL for macOS -+# - OpenSSL-iOS - build OpenSSL for iOS + # - OpenSSL-macOS - build OpenSSL for macOS + # - OpenSSL-iOS - build OpenSSL for iOS +# - OpenSSL-iOS-simulator - build OpenSSL for iOS-simulator -+# - OpenSSL-tvOS - build OpenSSL for tvOS + # - OpenSSL-tvOS - build OpenSSL for tvOS +# - OpenSSL-tvOS-simulator - build OpenSSL for tvOS-simulator -+# - OpenSSL-watchOS - build OpenSSL for watchOS + # - OpenSSL-watchOS - build OpenSSL for watchOS +# - OpenSSL-watchOS-simulator - build OpenSSL for watchOS-simulator # - BZip2-macOS - build BZip2 for macOS # - BZip2-iOS - build BZip2 for iOS diff --git a/example/ios/README.md b/example/ios/README.md index e8aa403fc..aeedb6563 100644 --- a/example/ios/README.md +++ b/example/ios/README.md @@ -2,7 +2,7 @@ Below are instructions for building TDLib for iOS, watchOS, tvOS, and also macOS. -If you need only a macOS build, take a look at our build instructions for [macOS](https://github.com/tdlib/td#macos). +If you need only a macOS build for the current architecture, take a look at our build instructions for [macOS](https://github.com/tdlib/td#macos). For example of usage take a look at our [Swift example](https://github.com/tdlib/td/tree/master/example/swift). @@ -36,7 +36,7 @@ cd /example/ios ./build.sh ``` This may take a while, because TDLib will be built about 10 times. -Resulting library for iOS will work on any architecture (armv7, armv7s, arm64) and even on a simulator (Intel, Apple Silicon). +Resulting library will work on any architecture (armv7, armv7s, arm64) and even on a simulator (Intel, Apple Silicon). We use [CMake/iOS.cmake](https://github.com/tdlib/td/blob/master/CMake/iOS.cmake) toolchain, other toolchains may work too. Built libraries will be stored in `tdjson` directory. diff --git a/example/ios/build.sh b/example/ios/build.sh index e554b5b18..5f9372dc8 100755 --- a/example/ios/build.sh +++ b/example/ios/build.sh @@ -26,6 +26,37 @@ for platform in $platforms; do echo "Platform = ${platform}" if [[ $platform = "macOS" ]]; then + simulators="0" + else + simulators="0 1" + fi + + for simulator in $simulators; + do + if [[ $platform = "macOS" ]]; then + other_options="-DCMAKE_OSX_ARCHITECTURES='x86_64;arm64'" + else + watchos="" + if [[ $platform = "watchOS" ]]; then + ios_platform="WATCH" + watchos="-DTD_EXPERIMENTAL_WATCH_OS=ON" + elif [[ $platform = "tvOS" ]]; then + ios_platform="TV" + else + ios_platform="" + fi + + if [[ $simulator = "1" ]]; then + platform="${platform}-simulator" + ios_platform="${ios_platform}SIMULATOR" + else + ios_platform="${ios_platform}OS" + fi + + echo "iOS platform = ${ios_platform}" + other_options="${watchos} -DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake" + fi + set_cmake_options $platform build="build-${platform}" install="install-${platform}" @@ -33,62 +64,15 @@ do mkdir -p $build mkdir -p $install cd $build - cmake $td_path $options -DCMAKE_INSTALL_PREFIX=../${install} -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" + cmake $td_path $options $other_options -DCMAKE_INSTALL_PREFIX=../${install} make -j3 install || exit cd .. - mkdir -p $platform - cp $build/libtdjson.dylib $platform/libtdjson.dylib - install_name_tool -id @rpath/libtdjson.dylib $platform/libtdjson.dylib - + install_name_tool -id @rpath/libtdjson.dylib ${install}/lib/libtdjson.dylib mkdir -p ../tdjson/${platform}/include rsync --recursive ${install}/include/ ../tdjson/${platform}/include/ mkdir -p ../tdjson/${platform}/lib - cp ${platform}/libtdjson.dylib ../tdjson/${platform}/lib/ - else - simulators="0 1" - for simulator in $simulators; - do - build="build-${platform}" - install="install-${platform}" - if [[ $simulator = "1" ]]; then - build="${build}-simulator" - install="${install}-simulator" - platform_path="${platform}-simulator" - ios_platform="SIMULATOR" - lib="${install}/lib/libtdjson.dylib" - set_cmake_options ${platform_path} - else - platform_path=${platform} - ios_platform="OS" - lib="${install}/lib/libtdjson.dylib" - set_cmake_options ${platform_path} - fi - watchos="" - if [[ $platform = "watchOS" ]]; then - ios_platform="WATCH${ios_platform}" - watchos="-DTD_EXPERIMENTAL_WATCH_OS=ON" - fi - if [[ $platform = "tvOS" ]]; then - ios_platform="TV${ios_platform}" - fi - echo $ios_platform - rm -rf $build - mkdir -p $build - mkdir -p $install - cd $build - cmake $td_path $options $watchos -DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake -DCMAKE_INSTALL_PREFIX=../${install} - make -j3 install || exit - cd .. - - install_name_tool -id @rpath/libtdjson.dylib $lib - - mkdir -p ../tdjson/${platform_path}/include - rsync --recursive ${install}/include/ ../tdjson/${platform_path}/include/ - mkdir -p ../tdjson/${platform_path}/lib - cp ${lib} ../tdjson/${platform_path}/lib/ - done - fi - + cp ${install}/lib/libtdjson.dylib ../tdjson/${platform}/lib/ + done done produced_dylibs=(install-*/lib/libtdjson.dylib) @@ -104,4 +88,4 @@ xcodebuild -create-xcframework \ "${xcodebuild_frameworks[@]}" \ -output "libtdjson.xcframework" -rsync --recursive libtdjson.xcframework ../tdjson/ \ No newline at end of file +rsync --recursive libtdjson.xcframework ../tdjson/