build_in_travis_ci.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env sh
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. if [ -z "$PURPOSE" ]; then
  17. echo "PURPOSE must be set"
  18. exit 1
  19. fi
  20. if [ -z "$CXX" ]; then
  21. echo "CXX must be set"
  22. exit 1
  23. fi
  24. if [ -z "$CC" ]; then
  25. echo "CC must be set"
  26. exit 1
  27. fi
  28. runcmd(){
  29. eval $@
  30. [[ $? != 0 ]] && {
  31. exit 1
  32. }
  33. return 0
  34. }
  35. echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC"
  36. init_make_config() {
  37. # The default env in travis-ci is Ubuntu.
  38. if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $@ ; then
  39. echo "Fail to configure brpc"
  40. exit 1
  41. fi
  42. }
  43. if [ "$PURPOSE" = "compile-with-make" ]; then
  44. # In order to run thrift example, we need to add the corresponding flag
  45. init_make_config "--with-thrift" && make -j4 && sh tools/make_all_examples
  46. elif [ "$PURPOSE" = "unittest" ]; then
  47. init_make_config && cd test && make -j4 && sh ./run_tests.sh
  48. elif [ "$PURPOSE" = "compile-with-cmake" ]; then
  49. rm -rf bld && mkdir bld && cd bld && cmake .. && make -j4
  50. elif [ "$PURPOSE" = "compile-with-bazel" ]; then
  51. bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //...
  52. elif [ "$PURPOSE" = "compile-with-make-all-options" ]; then
  53. init_make_config "--with-thrift --with-glog --with-mesalink" && make -j4
  54. elif [ "$PURPOSE" = "compile-with-cmake-all-options" ]; then
  55. rm -rf bld && mkdir bld && cd bld && cmake -DWITH_MESALINK=ON -DWITH_GLOG=ON -DWITH_THRIFT=ON .. && make -j4
  56. elif [ "$PURPOSE" = "compile-with-bazel-all-options" ]; then
  57. bazel build -j 12 -c opt --define with_mesalink=true --define with_glog=true --define with_thrift=true --copt -DHAVE_ZLIB=1 //...
  58. else
  59. echo "Unknown purpose=\"$PURPOSE\""
  60. fi