-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeps_build.sh
126 lines (100 loc) · 2.35 KB
/
deps_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
#!/bin/bash
echo "*********************************************"
echo "***** QUICLY-GO DEPENDENCIES BUILD *****"
echo "*********************************************"
echo
function assert_errorcode() {
if [[ ! "$?" -eq "0" ]]; then
echo "********************************"
echo "**** RESULT: FAILURE ****"
echo "********************************"
exit 1
fi
}
function prerequisites_check() {
echo [Prerequisites check: GO]
go version
assert_errorcode
echo [Prerequisites check: cmake]
cmake --version
assert_errorcode
echo [Prerequisites check: git]
git version
assert_errorcode
}
function prepare() {
echo [Init submodules]
git submodule init deps/openssl
git submodule init deps/quicly
git submodule init deps/c-for-go
echo [Update submodules]
git submodule update --init --recursive
echo [Create gen directories]
mkdir -p gen_openssl
mkdir -p gen_quicly
}
function build_openssl() {
echo [Build OpenSSL]
pushd gen_openssl
cmake ../deps/openssl -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BASEDIR/internal/deps -DCMAKE_BUILD_TYPE=$BUILD
assert_errorcode
cmake --build .
assert_errorcode
cmake --build . --target install
assert_errorcode
popd
}
function build_quicly() {
echo [Build Quicly]
pushd gen_quicly
cmake ../deps/quicly -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BASEDIR/internal/deps -DOPENSSL_ROOT_DIR=$BASEDIR/internal/deps/include \
-DCMAKE_BUILD_TYPE=$BUILD -DWITH_EXAMPLE=OFF
assert_errorcode
cmake --build .
assert_errorcode
cmake --build . --target install
assert_errorcode
popd
}
function reset() {
cd $BASEDIR
go clean -cache -x || true
git reset --hard || true
git clean -f -d || true
exit 0
}
BASEDIR=$(dirname "$(realpath $0)")
BUILD="Release"
if [[ "$1" -eq "--help" ]]; then
printf "Usage: build.bat [--debug][--clean]"
exit 1
fi
if [[ "$1" -eq "--quic" ]]; then
build_quicly
exit 0
fi
if [[ "$1" -eq "--clean" ]]; then
reset
exit 0
fi
if [[ "$2" -eq "--clean" ]]; then
reset
exit 0
fi
if [[ "$1" -eq "--debug" ]]; then
BUILD="Debug"
fi
prerequisites_check
assert_errorcode
prepare
assert_errorcode
build_openssl
assert_errorcode
build_quicly
assert_errorcode
echo
echo "***************************"
echo "**** RESULT: SUCCESS ****"
echo "***************************"
cd $BASEDIR
exit 0