build.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. #
  3. # Build file to set up and run tests
  4. set -ex
  5. # Install Bazel 4.0.0.
  6. use_bazel.sh 4.0.0
  7. bazel version
  8. # Print bazel testlogs to stdout when tests failed.
  9. function print_test_logs {
  10. # TODO(yannic): Only print logs of failing tests.
  11. testlogs_dir=$(bazel info bazel-testlogs)
  12. testlogs=$(find "${testlogs_dir}" -name "*.log")
  13. for log in $testlogs; do
  14. cat "${log}"
  15. done
  16. }
  17. # Change to repo root
  18. cd $(dirname $0)/../../..
  19. git submodule update --init --recursive
  20. # Disabled for now, re-enable if appropriate.
  21. # //:build_files_updated_unittest \
  22. trap print_test_logs EXIT
  23. bazel test -k --copt=-Werror --host_copt=-Werror \
  24. //java:tests \
  25. //:protoc \
  26. //:protobuf \
  27. //:protobuf_python \
  28. //:protobuf_test \
  29. @com_google_protobuf//:cc_proto_blacklist_test
  30. trap - EXIT
  31. pushd examples
  32. bazel build //...
  33. popd
  34. # Verify that we can build successfully from generated tar files.
  35. ./autogen.sh && ./configure && make -j$(nproc) dist
  36. DIST=`ls *.tar.gz`
  37. tar -xf $DIST
  38. cd ${DIST//.tar.gz}
  39. bazel build //:protobuf //:protobuf_java