build_in_travis_ci.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. if [ -z "$PURPOSE" ]; then
  2. echo "PURPOSE must be set"
  3. exit 1
  4. fi
  5. if [ -z "$CXX" ]; then
  6. echo "CXX must be set"
  7. exit 1
  8. fi
  9. if [ -z "$CC" ]; then
  10. echo "CC must be set"
  11. exit 1
  12. fi
  13. runcmd(){
  14. eval $@
  15. [[ $? != 0 ]] && {
  16. exit 1
  17. }
  18. return 0
  19. }
  20. echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC"
  21. if [ "$PURPOSE" = "compile-with-bazel" ]; then
  22. runcmd "bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //..."
  23. exit 0
  24. fi
  25. # The default env in travis-ci is Ubuntu.
  26. if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC; then
  27. echo "Fail to configure brpc"
  28. exit 1
  29. fi
  30. if [ "$PURPOSE" = "compile" ]; then
  31. make -j4 && sh tools/make_all_examples
  32. elif [ "$PURPOSE" = "unittest" ]; then
  33. # pass the unittest from default Makefile to accelerate build process
  34. :
  35. else
  36. echo "Unknown purpose=\"$PURPOSE\""
  37. fi
  38. echo "start building by cmake"
  39. rm -rf build && mkdir build && cd build
  40. if [ "$PURPOSE" = "compile" ]; then
  41. if ! cmake ..; then
  42. echo "Fail to generate Makefile by cmake"
  43. exit 1
  44. fi
  45. make -j4
  46. elif [ "$PURPOSE" = "unittest" ]; then
  47. if ! cmake -DBUILD_UNIT_TESTS=ON ..; then
  48. echo "Fail to generate Makefile by cmake"
  49. exit 1
  50. fi
  51. make -j4 && cd test && sh ./run_tests.sh && cd ../
  52. else
  53. echo "Unknown purpose=\"$PURPOSE\""
  54. fi