build_in_travis_ci.sh 1.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
if [ -z "$PURPOSE" ]; then
    echo "PURPOSE must be set"
    exit 1
fi
if [ -z "$CXX" ]; then
    echo "CXX must be set"
    exit 1
fi
if [ -z "$CC" ]; then
    echo "CC must be set"
    exit 1
fi
13

14
runcmd(){
15 16 17 18 19 20 21
    eval $@
    [[ $? != 0 ]] && {
        exit 1
    }
    return 0
}

22
echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC"
23 24

if [ "$PURPOSE" = "compile-with-bazel" ]; then
donghuixu's avatar
donghuixu committed
25
    runcmd "bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //..."
26 27
    exit 0
fi
28

29 30 31 32 33 34
# The default env in travis-ci is Ubuntu.
if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC; then
    echo "Fail to configure brpc"
    exit 1
fi
if [ "$PURPOSE" = "compile" ]; then
zhujiashun's avatar
zhujiashun committed
35
    make -j4 && sh tools/make_all_examples
36
elif [ "$PURPOSE" = "unittest" ]; then
37 38
    # pass the unittest from default Makefile to accelerate build process
    :
39 40 41
else
    echo "Unknown purpose=\"$PURPOSE\""
fi
42 43 44

echo "start building by cmake"
rm -rf build && mkdir build && cd build
zhujiashun's avatar
zhujiashun committed
45
if [ "$PURPOSE" = "compile" ]; then
46
    if ! cmake ..; then
zhujiashun's avatar
zhujiashun committed
47 48 49
        echo "Fail to generate Makefile by cmake"
        exit 1
    fi
zhujiashun's avatar
zhujiashun committed
50 51
    make -j4
elif [ "$PURPOSE" = "unittest" ]; then
52
    if ! cmake -DBUILD_UNIT_TESTS=ON ..; then
zhujiashun's avatar
zhujiashun committed
53 54 55
        echo "Fail to generate Makefile by cmake"
        exit 1
    fi
zhujiashun's avatar
zhujiashun committed
56
    make -j4 && cd test && sh ./run_tests.sh && cd ../
zhujiashun's avatar
zhujiashun committed
57 58 59
else
    echo "Unknown purpose=\"$PURPOSE\""
fi