-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·93 lines (72 loc) · 2.85 KB
/
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
#!/bin/bash
DATA_PRE=$(date +%Y-%m-%d-%H-%M)
log_info ()
{
[ $# == 0 ] && echo "log_info should have args"
echo "[INFO] [${DATA_PRE}] ["${1}"]"
}
log_error ()
{
[ $# == 0 ] && echo "log_error should have args"
echo "[ERROR] [${DATA_PRE}] ["${1}"]"
}
# export environment
export PLAYER_ROOT=$PWD
export THIRDPARTY_DIR=${PLAYER_ROOT}/3rd
export BUILD_PATH=${PLAYER_ROOT}/build
export INSTALL_PATH=${BUILD_PATH}/install
export INSTALL_BIN_PATH=${INSTALL_PATH}/bin
export INSTALL_INCLUDE_PATH=${INSTALL_PATH}/include
export INSTALL_LIB_PATH=${INSTALL_PATH}/lib
# print environment
log_info "PLAYER_ROOT=${PLAYER_ROOT}"
# Environment Init
[ ! -d ${BUILD_PATH} ] && mkdir -p ${BUILD_PATH}
[ ! -d ${INSTALL_PATH} ] && mkdir -p ${INSTALL_PATH}
[ ! -d ${INSTALL_BIN_PATH} ] && mkdir -p ${INSTALL_BIN_PATH}
[ ! -d ${INSTALL_INCLUDE_PATH} ] && mkdir -p ${INSTALL_INCLUDE_PATH}
[ ! -d ${INSTALL_LIB_PATH} ] && mkdir -p ${INSTALL_LIB_PATH}
cd ${THIRDPARTY_DIR}
git clone https://github.com/grpc/grpc.git
git clone https://github.com/protocolbuffers/protobuf.git
git clone https://github.com/google/glog.git
git clone https://github.com/gflags/gflags.git
git clone https://github.com/nlohmann/json.git
git submodule update --init
# glog compile
log_info "start to compile glog"
GLOG_SRC_PATH=${THIRDPARTY_DIR}/glog
GLOG_BUILD_PATH=${BUILD_PATH}/glog
cd ${GLOG_SRC_PATH} && git submodule update --init
cd ${GLOG_SRC_PATH} && bash autogen.sh
[ ! -d ${GLOG_BUILD_PATH} ] && mkdir -p ${GLOG_BUILD_PATH}
cd ${GLOG_BUILD_PATH} && ${GLOG_SRC_PATH}/configure --prefix=${INSTALL_PATH} && make -j2 && make install
log_info "compile glog success"
# gflags compile
log_info "start to compile gflags"
GFLAGS_SRC_PATH=${THIRDPARTY_DIR}/gflags
GFLAGS_BUILD_PATH=${BUILD_PATH}/gflags
cd ${GFLAGS_SRC_PATH} && git submodule update --init
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} ${GFLAGS_SRC_PATH} && make -j2
log_info "compile gflags success"
# # protobuf compile
log_info "start to compile protobuf"
PROTOBUF_SRC_PATH=${THIRDPARTY_DIR}/protobuf
PROTOBUF_BUILD_PATH=${BUILD_PATH}/protobuf
cd ${PROTOBUF_SRC_PATH} && git submodule update --init
[ ! -d ${PROTOBUF_BUILD_PATH} ] && mkdir -p ${PROTOBUF_BUILD_PATH}
cd ${PROTOBUF_SRC_PATH} && bash autogen.sh
cd ${PROTOBUF_BUILD_PATH} && ${PROTOBUF_SRC_PATH}/configure --prefix=${INSTALL_PATH} && make -j2 && make install
log_info "compile protobuf success"
# compile grpc
log_info "start to compile grpc"
GRPC_SRC_PATH=${THIRDPARTY_DIR}/grpc
GRPC_BUILD_PATH=${BUILD_PATH}/grpc
git submodule update --init --recursive
[ ! -d ${GRPC_SRC_PATH} ] && git submodule update --init
[ ! -d ${GRPC_BUILD_PATH} ] && mkdir -p ${GRPC_BUILD_PATH}
cd ${GRPC_SRC_PATH} && make -j2
cp -r ${GRPC_SRC_PATH}/bins/* ${INSTALL_BIN_PATH}
cp -r ${GRPC_SRC_PATH}/include/* ${INSTALL_INCLUDE_PATH}
cp -r ${GRPC_SRC_PATH}/libs/opt/* ${INSTALL_LIB_PATH}
log_info "compile grpc success"