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 25 26 27 28 29
# 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
30
    make -j4 && sh tools/make_all_examples
31
elif [ "$PURPOSE" = "unittest" ]; then
32 33
    # pass the unittest from default Makefile to accelerate build process
    :
34 35 36
else
    echo "Unknown purpose=\"$PURPOSE\""
fi
37 38 39

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