build_in_travis_ci.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. # The default env in travis-ci is Ubuntu.
  22. if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC; then
  23. echo "Fail to configure brpc"
  24. exit 1
  25. fi
  26. if [ "$PURPOSE" = "compile" ]; then
  27. make -j4 && sh tools/make_all_examples
  28. elif [ "$PURPOSE" = "unittest" ]; then
  29. # pass the unittest from default Makefile to accelerate build process
  30. :
  31. else
  32. echo "Unknown purpose=\"$PURPOSE\""
  33. fi
  34. echo "start building by cmake"
  35. rm -rf build && mkdir build && cd build
  36. if [ "$PURPOSE" = "compile" ]; then
  37. if ! cmake ..; then
  38. echo "Fail to generate Makefile by cmake"
  39. exit 1
  40. fi
  41. make -j4
  42. elif [ "$PURPOSE" = "unittest" ]; then
  43. if ! cmake -DBUILD_UNIT_TESTS=ON ..; then
  44. echo "Fail to generate Makefile by cmake"
  45. exit 1
  46. fi
  47. make -j4 && cd test && sh ./run_tests.sh && cd ../
  48. else
  49. echo "Unknown purpose=\"$PURPOSE\""
  50. fi