-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.sh
executable file
·86 lines (77 loc) · 2.51 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
td_path=$(grealpath ../..)
rm -rf build
mkdir -p build
cd build
set_cmake_options () {
# Set CMAKE options depending on platform passed $1
openssl_path=$(grealpath ../third_party/openssl/$1)
echo "OpenSSL path = ${openssl_path}"
openssl_crypto_library="${openssl_path}/lib/libcrypto.a"
openssl_ssl_library="${openssl_path}/lib/libssl.a"
options=""
options="$options -DOPENSSL_FOUND=1"
options="$options -DOPENSSL_CRYPTO_LIBRARY=${openssl_crypto_library}"
options="$options -DOPENSSL_SSL_LIBRARY=${openssl_ssl_library}"
options="$options -DOPENSSL_INCLUDE_DIR=${openssl_path}/include"
options="$options -DOPENSSL_LIBRARIES=${openssl_crypto_library};${openssl_ssl_library}"
options="$options -DCMAKE_BUILD_TYPE=Release"
if command -v ccache &> /dev/null
then
echo "ccache available, setting compiler options. Don't trust what cmake says, caching will work. https://t.me/tdlibchat/108338"
options="$options -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
else
echo "ccache is not available"
fi
}
platform="$1"
minimum_deployment_version="$2"
# Parse platform and strip simulator
if [[ $platform == *"-simulator" ]]; then
simulator="1"
else
simulator="0"
fi
if [[ $platform == "iOS"* ]]; then
platform="iOS"
elif [[ $platform == "macOS" ]]; then
platform="macOS"
elif [[ $platform == "watchOS"* ]]; then
platform="watchOS"
elif [[ $platform == "tvOS"* ]]; then
platform="tvOS"
elif [[ $platform == "visionOS"* ]]; then
platform="visionOS"
fi
echo "Platform = ${platform}"
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"
elif [[ $platform = "visionOS" ]]; then
ios_platform="VISION"
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}. Minimum OS version ${minimum_deployment_version}"
other_options="-DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake -DIOS_DEPLOYMENT_TARGET=${minimum_deployment_version}"
fi
set_cmake_options $platform
build="build-${platform}"
install="install-${platform}"
rm -rf $build
mkdir -p $build
mkdir -p $install
cd $build
cmake $td_path $options $other_options -DCMAKE_INSTALL_PREFIX=../${install}
make -j3 install || exit
cd ..