forked from alibaba/xquic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xqc_build.sh
executable file
·174 lines (147 loc) · 4.48 KB
/
xqc_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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Copyright (c) 2022, Alibaba Group Holding Limited
#!/bin/sh
android_archs=(armeabi-v7a arm64-v8a)
ios_archs=(armv7 arm64 x86_64)
cur_dir=$(cd "$(dirname "$0")";pwd)
cp -f $cur_dir/cmake/CMakeLists.txt $cur_dir/CMakeLists.txt
platform=$1
build_dir=$2
artifact_dir=$3
# boringssl is used as default
ssl_type="boringssl"
ssl_path=$4
# if ssl_path is not defined, try to use the default path
if [ -z "$ssl_path" ] ; then
ssl_path="`pwd`/third_party/boringssl"
echo "use default ssl path: $ssl_path"
fi
if [ ! -d "$ssl_path" ] ; then
echo "ssl environment not exists"
exit 0
fi
create_dir_force() {
if [ x"$2" == x ] ; then
echo "$1 MUST NOT be empty"
exit 1
fi
if [ -d $2 ] ; then
rm -rf $2
fi
mkdir $2
echo "create $1 directory($2) suc"
}
platform=$(echo $platform | tr A-Z a-z )
if [ x"$platform" == xios ] ; then
if [ x"$IOS_CMAKE_TOOLCHAIN" == x ] ; then
echo "IOS_CMAKE_TOOLCHAIN MUST be defined"
exit 0
fi
archs=${ios_archs[@]}
configures="-DSSL_TYPE=${ssl_type}
-DSSL_PATH=${ssl_path}
-DBORINGSSL_PREFIX=bs
-DBORINGSSL_PREFIX_SYMBOLS=$cur_dir/bssl_symbols.txt
-DDEPLOYMENT_TARGET=10.0
-DCMAKE_BUILD_TYPE=Minsizerel
-DXQC_ENABLE_TESTING=OFF
-DXQC_BUILD_SAMPLE=OFF
-DGCOV=OFF
-DCMAKE_TOOLCHAIN_FILE=${IOS_CMAKE_TOOLCHAIN}
-DENABLE_BITCODE=0
-DXQC_NO_SHARED=1
-DXQC_COMPAT_GENERATE_SR_PKT=1
-DXQC_ENABLE_RENO=1
-DXQC_ENABLE_BBR2=1
-DXQC_ENABLE_COPA=1
-DXQC_ENABLE_UNLIMITED=0
-DXQC_ENABLE_MP_INTEROP=0"
elif [ x"$platform" == xandroid ] ; then
if [ x"$ANDROID_NDK" == x ] ; then
echo "ANDROID_NDK MUST be defined"
exit 0
fi
archs=${android_archs[@]}
configures="-DSSL_TYPE=${ssl_type}
-DSSL_PATH=${ssl_path}
-DCMAKE_BUILD_TYPE=Minsizerel
-DXQC_ENABLE_TESTING=OFF
-DXQC_BUILD_SAMPLE=OFF
-DGCOV=OFF
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake
-DANDROID_STL=c++_shared
-DANDROID_NATIVE_API_LEVEL=android-19
-DXQC_ENABLE_RENO=OFF
-DXQC_ENABLE_BBR2=ON
-DXQC_ENABLE_COPA=OFF
-DXQC_ENABLE_UNLIMITED=OFF
-DXQC_ENABLE_MP_INTEROP=OFF
-DXQC_DISABLE_LOG=OFF
-DXQC_ONLY_ERROR_LOG=ON
-DXQC_COMPAT_GENERATE_SR_PKT=ON"
else
echo "no support platform"
exit 0
fi
generate_plat_spec() {
plat_spec=
if [ x"$platform" == xios ] ; then
plat_spec="-DARCHS=$1"
if [ x"$1" == xx86_64 ] ; then
plat_spec="$plat_spec -DPLATFORM=SIMULATOR64"
elif [ x"$1" == xi386 ] ; then
plat_spec="$plat_spec -DPLATFORM=SIMULATOR"
fi
else
plat_spec="-DANDROID_ABI=$1"
fi
echo $plat_spec
}
create_dir_force build $build_dir
# to absoulute path
build_dir=$cur_dir/$build_dir
create_dir_force artifact $artifact_dir
artifact_dir=$cur_dir/$artifact_dir
cd $build_dir
for i in ${archs[@]} ;
do
rm -f CMakeCache.txt
rm -rf CMakeFiles
rm -rf Makefile
rm -rf cmake_install.cmake
rm -rf include
rm -rf outputs
rm -rf third_party
echo "compiling xquic on $i arch"
cmake $configures $(generate_plat_spec $i ) -DLIBRARY_OUTPUT_PATH=`pwd`/outputs/ ..
make -j 4
if [ $? != 0 ] ; then
exit 0
fi
if [ ! -d ${artifact_dir}/$i ] ; then
mkdir -p ${artifact_dir}/$i
fi
cp -f `pwd`/outputs/*.a ${artifact_dir}/$i/
cp -f `pwd`/outputs/*.so ${artifact_dir}/$i/
done
make_fat() {
script="lipo -create"
for i in ${archs[@]} ;
do
script="$script -arch $i $artifact_dir/$i/$1 "
done
script="$script -output $cur_dir/ios/xquic/xquic/Libs/$1"
$($script)
}
if [ x"$platform" == xios ] ; then
if [ ! -d $cur_dir/ios/xquic/xquic/Headers ] ; then
mkdir -p $cur_dir/ios/xquic/xquic/Headers
fi
if [ ! -d $cur_dir/ios/xquic/xquic/Libs ] ; then
mkdir -p $cur_dir/ios/xquic/xquic/Libs
fi
make_fat libxquic.a
make_fat libcrypto.a
make_fat libssl.a
cp -f $cur_dir/include/xquic/* $cur_dir/ios/xquic/xquic/Headers/
cp -f $build_dir/include/xquic/* $cur_dir/ios/xquic/xquic/Headers/
fi