-
Notifications
You must be signed in to change notification settings - Fork 0
/
09_build_grpc_armhf.sh
82 lines (65 loc) · 2.22 KB
/
09_build_grpc_armhf.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
#!/bin/bash
# build gRPC for Raspberry Pi (armhf)
### initialise
# check if all required environment variables are set
source utils.sh
check_env_var BASE_DIR
check_env_var GUEST_INSTALL_PREFIX
check_env_var SYSROOT_PREFIX
check_env_var TOOLCHAIN_FILE
check_env_var GRPC_CPACK_CONFIG_FILE
check_env_var GRPC_PACKAGE_VERSION
check_env_var GRPC_SOURCE_DIR
check_env_var GRPC_SYSROOT_PACKAGE_NAME
check_env_var GRPC_GUEST_PACKAGE_NAME
check_env_var GRPC_GUEST_DEBIAN_PACKAGE_NAME
check_env_var GRPC_GUEST_BUILD_DIR
set -ex
### build for host
# create build directory
mkdir -p ${GRPC_GUEST_BUILD_DIR}
pushd ${GRPC_GUEST_BUILD_DIR}
rm -Rf *
# set up cross-compilation for host installation
cmake \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=${SYSROOT_PREFIX} \
-DgRPC_ZLIB_PROVIDER=package \
-DgRPC_INSTALL=ON \
${GRPC_SOURCE_DIR}
# compile and preinstall for packaging
make -j8 preinstall
# package to TGZ (for use outside CI)
cpack \
--config ${GRPC_CPACK_CONFIG_FILE} \
-D CPACK_GENERATOR="TGZ" \
-D CPACK_PACKAGE_VERSION=${GRPC_PACKAGE_VERSION} \
-D CPACK_PACKAGE_FILE_NAME=${GRPC_SYSROOT_PACKAGE_NAME} \
-D CPACK_INSTALL_CMAKE_PROJECTS="$(pwd);grpc;ALL;/" \
-D CPACK_PACKAGING_INSTALL_PREFIX=${SYSROOT_PREFIX}
# copy TGZ package to base directory
cp ${GRPC_SYSROOT_PACKAGE_NAME}.tar.gz ${BASE_DIR}
# set up cross-compilation for guest installation
cmake \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=${GUEST_INSTALL_PREFIX} \
-DgRPC_ZLIB_PROVIDER=package \
-DgRPC_INSTALL=ON \
${GRPC_SOURCE_DIR}
# package to TGZ and DEB for guest
cpack \
--config ${GRPC_CPACK_CONFIG_FILE} \
-D CPACK_PACKAGE_VERSION=${GRPC_PACKAGE_VERSION} \
-D CPACK_PACKAGE_FILE_NAME=${GRPC_GUEST_PACKAGE_NAME} \
-D CPACK_INSTALL_CMAKE_PROJECTS="$(pwd);grpc;ALL;/" \
-D CPACK_PACKAGING_INSTALL_PREFIX=${GUEST_INSTALL_PREFIX} \
-D CPACK_DEBIAN_PACKAGE_ARCHITECTURE="armhf" \
-D CPACK_DEBIAN_FILE_NAME=${GRPC_GUEST_DEBIAN_PACKAGE_NAME}
# copy DEB and TGZ package to base directory
cp ${GRPC_GUEST_PACKAGE_NAME}.tar.gz ${BASE_DIR}
cp ${GRPC_GUEST_DEBIAN_PACKAGE_NAME} ${BASE_DIR}
popd