-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.sh
executable file
·155 lines (134 loc) · 3.98 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/sh
fold_start() {
echo -e "travis_fold:start:$1\033[33;1m$2\033[0m"
}
fold_end() {
echo -e "\ntravis_fold:end:$1\r"
}
show_progress() {
PID=$!
i=1
sp="/-\|"
echo -n ' '
while kill -0 $PID 2> /dev/null
do
printf "\b${sp:i++%${#sp}:1}"
sleep 60
done
}
fold_start td_checkout "Checkout td at tag ${$TRAVIS_TAG}"
git clone https://github.com/tdlib/td
cd td
# git checkout tags/$TRAVIS_TAG
git checkout tags/v1.6.0
cd ..
fold_end td_checkout
td_path=$(pwd)/td
build_path=$(pwd)/build
rm -rf build
mkdir -p build
cd build
set_options() {
platform=$1
echo "Platform: ${platform} arg: $1"
openssl_path=$(pwd)/../third_party/openssl/${platform}
openssl_crypto_library="${openssl_path}/lib/libcrypto.a"
openssl_ssl_library="${openssl_path}/lib/libssl.a"
options="$options -DOPENSSL_FOUND=1"
options="$options -DOPENSSL_CRYPTO_LIBRARY=${openssl_crypto_library}"
# options="$options -OPENSSL_ROOT_DIR='/usr/local/opt/openssl/'" # /${openssl_ssl_library}"
# options="$options -OPENSSL_ROOT_DIR=${openssl_ssl_library}"
options="$options -DOPENSSL_SSL_LIBRARY=${openssl_ssl_library}"
options="$options -DOPENSSL_INCLUDE_DIR=${openssl_path}/include"
options="$options -DOPENSSL_LIBRARIES=${openssl_ssl_library};${openssl_crypto_library}"
options="$options -DCMAKE_BUILD_TYPE=Release"
# options="$options -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang"
# options="$options -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++"
}
make_lipo() {
platform=$1
fold_start td_lipo "Lipo td for ${platform}"
cd $build_path
mkdir -p $platform
libs="libtdclient.a libtdsqlite.a libtdcore.a libtdactor.a libtdutils.a libtdjson_private.a libtddb.a libtdjson_static.a libtdnet.a"
for lib_path in $libs;
do
lib="install-${platform}/lib/${lib_path}"
lib_simulator="install-${platform}-simulator/lib/${lib_path}"
lipo -create $lib $lib_simulator -o $platform/$lib_path
done
fold_end td_lipo
}
copy_installs() {
platform = $1
fold_start td_copy "Copying libs to destination for ${platform}"
mkdir -p $platform/include
rsync --recursive install-${platform}/include/ ${platform}/include/
fold_end td_copy
}
build_macos() {
set_options "macOS"
fold_start td_build "Building td for ${platform}"
platform="macOS"
build="build-${platform}"
install="install-${platform}"
rm -rf $build
mkdir -p $build
mkdir -p $install
cd $build
echo "cmake $td_path $options -DCMAKE_INSTALL_PREFIX=../${install}"
cmake $td_path $options -DCMAKE_INSTALL_PREFIX=../${install}
# cmake --build . --target prepare_cross_compiling
make -j4 install || exit
cd ..
fold_end td_build
copy_installs "macOS"
}
build_ios() {
set_options "iOS"
simulator=$1
platform=$2
fold_start td_build "Building td for ${platform} (sim=${simulator})"
build="build-${platform}"
install="install-${platform}"
if [[ $simulator = "1" ]]; then
build="${build}-simulator"
install="${install}-simulator"
ios_platform="SIMULATOR"
else
ios_platform="OS"
fi
if [[ $platform = "watchOS" ]]; then
ios_platform="WATCH${ios_platform}"
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
echo "cmake $td_path $options -DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake -DIOS_DEPLOYMENT_TARGET=10.0 -DCMAKE_INSTALL_PREFIX=../${install}"
cmake $td_path $options -DIOS_PLATFORM=${ios_platform} -DCMAKE_TOOLCHAIN_FILE=${td_path}/CMake/iOS.cmake -DIOS_DEPLOYMENT_TARGET=10.0 -DCMAKE_INSTALL_PREFIX=../${install}
make -j4 install || exit
cd ..
fold_end td_build
}
build_macos
# exit
build_ios "0" "iOS" # & & wait
build_ios "1" "iOS"
make_lipo "iOS"
copy_installs "iOS"
cd ..
rm -rf lib/*
rm -rf include/
cp build/iOS/*.a lib/
cp -r build/iOS/include include
cp third_party/openssl/iOS/lib/* lib/
cp td/td/generate/scheme/td_api.tl .
# rm -rf td
# rm -rf third_party
# rm -rf Python-Apple-Support
# rm -rf build