2018-12-23 21:27:54 +01:00
|
|
|
#!/bin/sh
|
2021-12-08 17:43:21 +01:00
|
|
|
cd $(dirname $0)
|
2018-10-29 23:26:22 +01:00
|
|
|
td_path=$(grealpath ../..)
|
2018-02-14 11:19:12 +01:00
|
|
|
|
|
|
|
rm -rf build
|
|
|
|
mkdir -p build
|
|
|
|
cd build
|
|
|
|
|
2021-09-03 08:25:14 +02:00
|
|
|
set_cmake_options () {
|
|
|
|
# Set CMAKE options depending on platform passed $1
|
|
|
|
openssl_path=$(grealpath ../third_party/openssl/$1)
|
2018-02-14 22:41:26 +01:00
|
|
|
echo "OpenSSL path = ${openssl_path}"
|
|
|
|
openssl_crypto_library="${openssl_path}/lib/libcrypto.a"
|
|
|
|
openssl_ssl_library="${openssl_path}/lib/libssl.a"
|
2021-09-03 08:25:14 +02:00
|
|
|
options=""
|
2018-02-14 11:19:12 +01:00
|
|
|
options="$options -DOPENSSL_FOUND=1"
|
2018-02-14 22:41:26 +01:00
|
|
|
options="$options -DOPENSSL_CRYPTO_LIBRARY=${openssl_crypto_library}"
|
2019-10-17 21:09:17 +02:00
|
|
|
options="$options -DOPENSSL_SSL_LIBRARY=${openssl_ssl_library}"
|
2018-02-14 11:19:12 +01:00
|
|
|
options="$options -DOPENSSL_INCLUDE_DIR=${openssl_path}/include"
|
2018-02-14 22:41:26 +01:00
|
|
|
options="$options -DOPENSSL_LIBRARIES=${openssl_crypto_library};${openssl_ssl_library}"
|
2018-02-14 11:19:12 +01:00
|
|
|
options="$options -DCMAKE_BUILD_TYPE=Release"
|
2021-09-03 08:25:14 +02:00
|
|
|
}
|
|
|
|
|
2024-03-11 18:47:04 +01:00
|
|
|
platforms="macOS iOS watchOS tvOS visionOS"
|
2021-09-03 08:25:14 +02:00
|
|
|
#platforms="watchOS"
|
|
|
|
for platform in $platforms;
|
|
|
|
do
|
|
|
|
echo "Platform = ${platform}"
|
2018-02-14 11:19:12 +01:00
|
|
|
if [[ $platform = "macOS" ]]; then
|
2021-09-06 09:37:58 +02:00
|
|
|
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
|
|
|
|
if [[ $platform = "watchOS" ]]; then
|
|
|
|
ios_platform="WATCH"
|
|
|
|
elif [[ $platform = "tvOS" ]]; then
|
|
|
|
ios_platform="TV"
|
2024-03-11 18:47:04 +01:00
|
|
|
elif [[ $platform = "visionOS" ]]; then
|
|
|
|
ios_platform="VISION"
|
2021-09-06 09:37:58 +02:00
|
|
|
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}"
|
2021-09-24 12:41:22 +02:00
|
|
|
other_options="-DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake"
|
2021-09-06 09:37:58 +02:00
|
|
|
fi
|
|
|
|
|
2021-09-03 08:25:14 +02:00
|
|
|
set_cmake_options $platform
|
2018-02-14 11:19:12 +01:00
|
|
|
build="build-${platform}"
|
|
|
|
install="install-${platform}"
|
|
|
|
rm -rf $build
|
|
|
|
mkdir -p $build
|
|
|
|
mkdir -p $install
|
|
|
|
cd $build
|
2021-09-06 09:37:58 +02:00
|
|
|
cmake $td_path $options $other_options -DCMAKE_INSTALL_PREFIX=../${install}
|
2018-02-14 11:19:12 +01:00
|
|
|
make -j3 install || exit
|
|
|
|
cd ..
|
2021-09-06 09:37:58 +02:00
|
|
|
install_name_tool -id @rpath/libtdjson.dylib ${install}/lib/libtdjson.dylib
|
2021-09-03 08:25:14 +02:00
|
|
|
mkdir -p ../tdjson/${platform}/include
|
|
|
|
rsync --recursive ${install}/include/ ../tdjson/${platform}/include/
|
|
|
|
mkdir -p ../tdjson/${platform}/lib
|
2021-09-06 09:37:58 +02:00
|
|
|
cp ${install}/lib/libtdjson.dylib ../tdjson/${platform}/lib/
|
|
|
|
done
|
2018-02-14 11:19:12 +01:00
|
|
|
done
|
2021-09-03 08:25:14 +02:00
|
|
|
|
|
|
|
produced_dylibs=(install-*/lib/libtdjson.dylib)
|
|
|
|
xcodebuild_frameworks=()
|
|
|
|
|
|
|
|
for dylib in "${produced_dylibs[@]}";
|
|
|
|
do
|
|
|
|
xcodebuild_frameworks+=(-library $(grealpath "${dylib}"))
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make xcframework
|
|
|
|
xcodebuild -create-xcframework \
|
|
|
|
"${xcodebuild_frameworks[@]}" \
|
|
|
|
-output "libtdjson.xcframework"
|
|
|
|
|
2021-09-06 09:37:58 +02:00
|
|
|
rsync --recursive libtdjson.xcframework ../tdjson/
|