regenerate.bash 917 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # Copyright 2018 The Go Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style
  4. # license that can be found in the LICENSE file.
  5. set -e
  6. # Install the working tree's protoc-gen-gen in a tempdir.
  7. tmpdir=$(mktemp -d -t protobuf-regen.XXXXXX)
  8. trap 'rm -rf $tmpdir' EXIT
  9. mkdir -p $tmpdir/bin
  10. PATH=$tmpdir/bin:$PATH
  11. GOBIN=$tmpdir/bin go install ./cmd/protoc-gen-go
  12. # Public imports require at least Go 1.9.
  13. supportTypeAliases=""
  14. if go list -f '{{context.ReleaseTags}}' runtime | grep -q go1.9; then
  15. supportTypeAliases=1
  16. fi
  17. # Generate various test protos.
  18. PROTO_DIRS=(
  19. cmd/protoc-gen-go/testdata
  20. )
  21. for dir in ${PROTO_DIRS[@]}; do
  22. for p in `find $dir -name "*.proto"`; do
  23. if [[ $p == */import_public/* && ! $supportTypeAliases ]]; then
  24. echo "# $p (skipped)"
  25. continue;
  26. fi
  27. echo "# $p"
  28. protoc -I$dir --go_out=paths=source_relative:$dir $p
  29. done
  30. done