build_in_travis_ci.sh 1.23 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
init_make_config() {
25
EXTRA_BUILD_OPTS=""
26 27 28
if [ "$USE_MESALINK" = "yes" ]; then
    EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink"
fi
29

30
# The default env in travis-ci is Ubuntu.
31
if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS $1 ; then
32 33 34
    echo "Fail to configure brpc"
    exit 1
fi
35
}
36 37

if [ "$PURPOSE" = "compile" ]; then
38
    # In order to run thrift example, we need to add the corresponding flag
39
    init_make_config "--with-thrift" && make -j4 && sh tools/make_all_examples
40
elif [ "$PURPOSE" = "unittest" ]; then
41
    init_make_config && cd test && make -j4 && sh ./run_tests.sh
zhujiashun's avatar
zhujiashun committed
42 43
elif [ "$PURPOSE" = "compile-with-cmake" ]; then
    rm -rf bld && mkdir bld && cd bld && cmake .. && make -j4
44 45
elif [ "$PURPOSE" = "compile-with-bazel" ]; then
    bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //...
zhujiashun's avatar
zhujiashun committed
46 47 48
else
    echo "Unknown purpose=\"$PURPOSE\""
fi