-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_grpc.sh
142 lines (127 loc) · 4.32 KB
/
build_grpc.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
#!/bin/bash
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "installing cmake"
sudo apt install -y cmake
echo "installing build-essential autoconf libtool pkg-config"
sudo apt install -y build-essential autoconf libtool pkg-config
fi
display_usage() {
echo "This script builds grpc in static and shared mode."
echo "It can receive one optional arguments."
echo -e "\nUsage: \$0 [build with SSL - default='boringssl' (internal boringssl) or 'openssl' with a conan openssl 1.1.1k version] \n"
}
# check whether user had supplied -h or --help . If yes display usage
if [[ ( $1 == "--help") || $1 == "-h" ]]
then
display_usage
exit 0
fi
GRPCVERSION=1.37.1
REMAKENGRPCROOT=grpc/${GRPCVERSION}
SSL_BUILD=boringssl
if [ $# -eq 1 ]; then
SSL_BUILD=$1
fi
SSL_MODE=module
if [[ "${SSL_BUILD}" == "openssl" ]]; then
SSL_MODE=package
REMAKENGRPCROOT=grpc-${SSL_BUILD}/${GRPCVERSION}
fi
echo "GRPC ssl mode is : ${SSL_MODE}"
git clone --recurse-submodules -b v${GRPCVERSION} https://github.com/grpc/grpc
function buildGrpcShared {
LINKMODE=$(echo "$1" | tr '[:upper:]' '[:lower:]')
if [[ "${SSL_MODE}" == "package" ]]; then
conan install ./conanfile_openssl.txt -s arch=x86_64 -s compiler.cppstd=17 -s build_type=$1 --build=missing -if ./_build_openssl
fi
BUILDFOLDER=.build/build_shared_${SSL_BUILD}/$1
INSTFOLDER=$HOME/.local/shared/${LINKMODE}/${REMAKENGRPCROOT}/install
pushd grpc
mkdir -p $INSTFOLDER
# export PATH="$PATH:$INSTFOLDER/bin"
mkdir -p $BUILDFOLDER
pushd $BUILDFOLDER
cmake -DCMAKE_CXX_STANDARD=17 \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=$INSTFOLDER \
-DBUILD_SHARED_LIBS=ON \
-DgRPC_INSTALL=ON \
-DABSL_ENABLE_INSTALL=ON \
-DCMAKE_BUILD_TYPE=$1 \
-DgRPC_ABSL_PROVIDER=module \
-DgRPC_CARES_PROVIDER=module \
-DgRPC_PROTOBUF_PROVIDER=module \
-DgRPC_RE2_PROVIDER=module \
-DgRPC_SSL_PROVIDER=${SSL_MODE} \
-DgRPC_ZLIB_PROVIDER=module \
../../../..
make
make install
popd
popd
pushd $HOME/.local/shared/${LINKMODE}/${REMAKENGRPCROOT}
mkdir -p interfaces
mkdir -p bin/x86_64/shared/${LINKMODE}
mkdir -p lib/x86_64/shared/${LINKMODE}
rm -rf install/lib/cmake
rm -rf install/lib/pkgconfig
mv -f install/bin/* bin/x86_64/shared/${LINKMODE}/
mv -f install/lib/* lib/x86_64/shared/${LINKMODE}/
mv -f install/include/* interfaces
rm -rf install
popd
# rm -rf $BUILDFOLDER
}
function buildGrpcStatic {
LINKMODE=$(echo "$1" | tr '[:upper:]' '[:lower:]')
if [[ "${SSL_MODE}" == "package" ]]; then
conan install ./conanfile_openssl.txt -s arch=x86_64 -s compiler.cppstd=17 -s build_type=$1 --build=missing -if ./_build_openssl
fi
BUILDFOLDER=.build/build_static_${SSL_BUILD}/$1
INSTFOLDER=$HOME/.local/static/${LINKMODE}/${REMAKENGRPCROOT}/install
pushd grpc
mkdir -p $INSTFOLDER
# export PATH="$PATH:$INSTFOLDER/bin"
mkdir -p $BUILDFOLDER
pushd $BUILDFOLDER
cmake -DCMAKE_CXX_STANDARD=17 \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=$INSTFOLDER \
-DBUILD_SHARED_LIBS=OFF \
-DgRPC_INSTALL=ON \
-DABSL_ENABLE_INSTALL=ON \
-DCMAKE_BUILD_TYPE=$1 \
-DgRPC_ABSL_PROVIDER=module \
-DgRPC_CARES_PROVIDER=module \
-DgRPC_PROTOBUF_PROVIDER=module \
-DgRPC_RE2_PROVIDER=module \
-DgRPC_SSL_PROVIDER=${SSL_MODE} \
-DgRPC_ZLIB_PROVIDER=module \
../../../..
make
make install
popd
popd
pushd $HOME/.local/static/${LINKMODE}/${REMAKENGRPCROOT}
mkdir -p interfaces
mkdir -p bin/x86_64/static/${LINKMODE}
mkdir -p lib/x86_64/static/${LINKMODE}
rm -rf install/lib/cmake
rm -rf install/lib/pkgconfig
mv -f install/bin/* bin/x86_64/static/${LINKMODE}/
mv -f install/lib/* lib/x86_64/static/${LINKMODE}/
mv -f install/include/* interfaces
rm -rf install
popd
rm -rf $BUILDFOLDER
}
buildGrpcShared Release
buildGrpcShared Debug
buildGrpcStatic Release
buildGrpcStatic Debug
# ajout define WITHREMOTING dans sample.pro
# ajout openssl.pc
# ajout var PKG_CONFIG_PATH dans SOLARNATURAL build pointant sur racine package grpc pour autres .pc (voir pour aggrégat des .pc, pas évident avec link static cares
# copie libcares.a dans shared/debug