Simplify ios/build.sh.

This commit is contained in:
levlam 2021-09-06 10:37:58 +03:00
parent 73290dcda8
commit f79223e2ac
3 changed files with 42 additions and 62 deletions

View File

@ -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

View File

@ -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 <path to TDLib sources>/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.

View File

@ -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/
rsync --recursive libtdjson.xcframework ../tdjson/