-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathbuild_dependencies.sh
executable file
·99 lines (88 loc) · 2.59 KB
/
build_dependencies.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
#!/bin/bash
set -o errexit
cd `dirname $0`
VERSION=$(cat VERSION)
echo "const char* version = \"$VERSION\";" > ./cxx/src/kafka/util/version.cc
# init and download submodules
git submodule init
git submodule update
SOURCE_DIR="$PWD/cxx/thirdparts"
INSTALL_DIR="$SOURCE_DIR/local"
build_rdkafka() {
cd "$SOURCE_DIR/librdkafka"
./configure --prefix="$INSTALL_DIR"
make
make install
cd -
}
build_log4cplus() {
cd "$SOURCE_DIR/log4cplus"
./scripts/fix-timestamps.sh
CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" ./configure --prefix="$INSTALL_DIR" --enable-static --with-pic
make
make install
cd -
}
build_boost_1_70() {
pushd "$SOURCE_DIR"
if [[ ! -f boost_1_70_0.tar.gz ]]; then
wget https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.tar.gz
fi
tar zxf boost_1_70_0.tar.gz
pushd boost_1_70_0
./bootstrap.sh --prefix="$INSTALL_DIR" --with-libraries=regex,system
./b2 cxxflags="-D_GLIBCXX_USE_CXX11_ABI=0 -fPIC" install
popd
popd
}
build_protobuf_2_6() {
pushd "$SOURCE_DIR"
if [[ ! -f protobuf-2.6.1.tar.gz ]]; then
wget https://github.com/protocolbuffers/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
fi
tar zxf protobuf-2.6.1.tar.gz
pushd protobuf-2.6.1
CXX=g++ CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 -fPIC" ./configure --prefix="$INSTALL_DIR"
make
make install
popd
popd
}
build_pulsar() {
PROTOC_PATH="$INSTALL_DIR/bin/protoc"
PULSAR_CPP_DIR="$SOURCE_DIR/pulsar/pulsar-client-cpp"
# Use our own CMakeLists.txt to compile libpulsar.a only
cp ./pulsar-client-cpp/CMakeLists.txt "$PULSAR_CPP_DIR"
cp ./pulsar-client-cpp/lib/CMakeLists.txt "$PULSAR_CPP_DIR/lib"
pushd $PULSAR_CPP_DIR
mkdir -p _builds
pushd _builds
CXX=g++ cmake .. \
-DPROTOC_PATH="$PROTOC_PATH" \
-DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR"
# Here we use multiple threads to compile because it take long to compile with a single thread
make -j4
make install
pushd $PULSAR_CPP_DIR
git checkout -- .
popd
popd
popd
}
if [[ ! -f $INSTALL_DIR/lib/librdkafka.a ]]; then
build_rdkafka
fi
if [[ ! -f $INSTALL_DIR/lib/liblog4cplus.a ]]; then
build_log4cplus
fi
if [[ ! -f $INSTALL_DIR/lib/libboost_regex.a ]] || [[ ! -f $INSTALL_DIR/lib/libboost_system.a ]]; then
build_boost_1_70
fi
if [[ ! -f $INSTALL_DIR/lib/libprotobuf-lite.a ]]; then
build_protobuf_2_6
fi
if [[ ! -f $INSTALL_DIR/lib/libpulsar.a ]]; then
build_pulsar
fi