-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhost-build.sh
executable file
·76 lines (64 loc) · 2.06 KB
/
host-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
#!/usr/bin/env bash
#
# © 2024 AO Kaspersky Lab
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PROJECT_NAME=gRPC
KOS_DIR="$(dirname "$(realpath "${0}")")"
ROOT_DIR="$(dirname "${KOS_DIR}")"
BUILD="${ROOT_DIR}/build/host"
INSTALL="${ROOT_DIR}/install/host"
JOBS=`nproc`
PrintHelp () {
cat<<HELP
Script for building and installing ${PROJECT_NAME} for a host.
USAGE:
${0} [OPTIONS]
OPTIONS:
-h, --help
Help text.
-i, --install PATH
Path to directory where ${PROJECT_NAME} for the host will be installed.
If not specified, the default path ${INSTALL} will be used.
The value specified in the -i option takes precedence over the value of the INSTALL_PREFIX environment variable.
-j, --jobs N
Number of jobs for parallel build.
If not specified, the default value ${JOBS} will be used.
HELP
}
# Parse command line options.
while [ -n "${1}" ]; do
case "${1}" in
-h | --help) PrintHelp
exit 0;;
-i | --install) INSTALL_PREFIX="${2}"
shift ;;
-j | --jobs) JOBS="${2}"
shift ;;
*) echo "Unknown option -'${1}'."
PrintHelp
exit 1;;
esac
shift
done
if [ -z "${INSTALL_PREFIX}" ]; then
INSTALL_PREFIX="${INSTALL}"
fi
# Build protobuf on the host to use it as part of the toolchain.
cmake -B "${BUILD}" \
-D CMAKE_BUILD_TYPE:STRING=Debug \
-D CMAKE_INSTALL_PREFIX:STRING="${INSTALL_PREFIX}" \
-D gRPC_INSTALL=ON \
-D gRPC_BUILD_TESTS=OFF \
-D ABSL_PROPAGATE_CXX_STD=ON \
"${ROOT_DIR}" && \
cmake --build "${BUILD}" -j${JOBS} --target install