Commit 72a7748b authored by gejun's avatar gejun

perfer dynamically linking gperftools and glog to avoid explicit deps on…

perfer dynamically linking gperftools and glog to avoid explicit deps on libunwind and liblzma; built UT in travis-ci
parent 0f32c1fd
......@@ -3,10 +3,11 @@ language: cpp
sudo: required
install:
- sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev
- sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev
- sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd -
- sh config_brpc.sh --headers=/usr/include --libs=/usr/lib
- make -sj8
- cd test && make -sj8
script:
- cd example/echo_c++
- make
- cd test && sh ./run_tests.sh
......@@ -17,7 +17,7 @@ else
LDD=ldd
fi
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog:,nodebugsymbols -n 'config_brpc' -- "$@"`
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,nodebugsymbols -n 'config_brpc' -- "$@"`
WITH_GLOG=0
DEBUGSYMBOLS=-g
......@@ -243,14 +243,6 @@ else
fi
append_to_output "endif"
# Check libunwind (required by tcmalloc and glog)
UNWIND_LIB=$(find_dir_of_lib unwind)
HAS_STATIC_UNWIND=""
if [ -f $UNWIND_LIB/libunwind.a ]; then
HAS_STATIC_UNWIND="yes"
fi
REQUIRE_UNWIND=""
OLD_HDRS=$HDRS
OLD_LIBS=$LIBS
append_to_output "ifeq (\$(NEED_GPERFTOOLS), 1)"
......@@ -260,76 +252,27 @@ if [ -z "$TCMALLOC_LIB" ]; then
append_to_output " \$(error \"Fail to find gperftools\")"
else
append_to_output_libs "$TCMALLOC_LIB" " "
if [ -f $TCMALLOC_LIB/libtcmalloc_and_profiler.a ]; then
if [ -f $TCMALLOC_LIB/libtcmalloc.$SO ]; then
$LDD $TCMALLOC_LIB/libtcmalloc.$SO > libtcmalloc.deps
if grep -q libunwind libtcmalloc.deps; then
TCMALLOC_REQUIRE_UNWIND="yes"
REQUIRE_UNWIND="yes"
fi
fi
if [ -z "$TCMALLOC_REQUIRE_UNWIND" ]; then
append_to_output " STATIC_LINKINGS+=-ltcmalloc_and_profiler"
elif [ ! -z "$HAS_STATIC_UNWIND" ]; then
append_to_output " STATIC_LINKINGS+=-ltcmalloc_and_profiler -lunwind"
if grep -q liblzma libtcmalloc.deps; then
LZMA_LIB=$(find_dir_of_lib lzma)
if [ ! -z "$LZMA_LIB" ]; then
append_to_output_linkings $LZMA_LIB lzma " "
fi
fi
else
append_to_output " DYNAMIC_LINKINGS+=-ltcmalloc_and_profiler"
fi
rm -f libtcmalloc.deps
else
if [ -f $TCMALLOC_LIB/libtcmalloc.$SO ]; then
append_to_output " DYNAMIC_LINKINGS+=-ltcmalloc_and_profiler"
else
append_to_output " STATIC_LINKINGS+=-ltcmalloc_and_profiler"
fi
fi
append_to_output "endif"
if [ $WITH_GLOG != 0 ]; then
GLOG_LIB=$(find_dir_of_lib glog)
GLOG_LIB=$(find_dir_of_lib_or_die glog)
GLOG_HDR=$(find_dir_of_header_or_die glog/logging.h windows/glog/logging.h)
append_to_output_headers "$GLOG_HDR" " "
if [ -z "$GLOG_LIB" ]; then
append_to_output " \$(error \"Fail to find glog\")"
append_to_output_libs "$GLOG_LIB"
append_to_output_headers "$GLOG_HDR"
if [ -f "$GLOG_LIB/libglog.$SO" ]; then
append_to_output "DYNAMIC_LINKINGS+=-lglog"
else
append_to_output_libs "$GLOG_LIB" " "
if [ -f $GLOG_LIB/libglog.a ]; then
if [ -f "$GLOG_LIB/libglog.$SO" ]; then
$LDD $GLOG_LIB/libglog.$SO > libglog.deps
if grep -q libunwind libglog.deps; then
GLOG_REQUIRE_UNWIND="yes"
REQUIRE_UNWIND="yes"
fi
fi
if [ -z "$GLOG_REQUIRE_UNWIND" ]; then
append_to_output "STATIC_LINKINGS+=-lglog"
elif [ ! -z "$HAS_STATIC_UNWIND" ]; then
append_to_output "STATIC_LINKINGS+=-lglog -lunwind"
if grep -q liblzma libglog.deps; then
LZMA_LIB=$(find_dir_of_lib lzma)
if [ ! -z "$LZMA_LIB" ]; then
append_to_output_linkings $LZMA_LIB lzma
fi
fi
else
append_to_output "DYNAMIC_LINKINGS+=-lglog"
fi
else
append_to_output "DYNAMIC_LINKINGS+=-lglog"
fi
rm -f libglog.deps
append_to_output "STATIC_LINKINGS+=-lglog"
fi
fi
append_to_output "CPPFLAGS+=-DBRPC_WITH_GLOG=$WITH_GLOG -DGFLAGS_NS=$GFLAGS_NS $DEBUGSYMBOLS"
if [ ! -z "$REQUIRE_UNWIND" ]; then
append_to_output_libs "$UNWIND_LIB" " "
fi
# required by UT
#gtest
GTEST_LIB=$(find_dir_of_lib gtest)
......
......@@ -52,8 +52,7 @@ To run examples with cpu/heap profilers, install `libgoogle-perftools-dev` and r
Install and compile libgtest-dev (which is not compiled yet):
```shell
sudo apt-get install libgtest-dev
cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libgtest* /usr/lib/
sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd -
```
The directory of gtest source code may be changed, try `/usr/src/googletest/googletest` if `/usr/src/gtest` is not there.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment