regenerate.bash 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. GOBIN=$tmpdir/bin go install ./cmd/protoc-gen-go-grpc
  13. # Generate various test protos.
  14. PROTO_DIRS=(
  15. cmd/protoc-gen-go/testdata
  16. cmd/protoc-gen-go-grpc/testdata
  17. )
  18. for dir in ${PROTO_DIRS[@]}; do
  19. for p in `find $dir -name "*.proto"`; do
  20. echo "# $p"
  21. PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc -I$dir \
  22. --go_out=paths=source_relative:$dir \
  23. --go-grpc_out=paths=source_relative:$dir \
  24. $p
  25. done
  26. done
  27. # Generate descriptor and plugin.
  28. # TODO: Make this more automated.
  29. echo "# types/descriptor/descriptor.proto"
  30. mkdir -p $tmpdir/src/google/protobuf
  31. cp ./types/descriptor/descriptor.proto $tmpdir/src/google/protobuf/descriptor.proto
  32. PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc -I$tmpdir/src \
  33. --go_out=paths=source_relative:$tmpdir/src \
  34. $tmpdir/src/google/protobuf/descriptor.proto
  35. cp $tmpdir/src/google/protobuf/descriptor.pb.go ./types/descriptor/descriptor.pb.go
  36. echo "# types/plugin/plugin.proto"
  37. mkdir -p $tmpdir/src/google/protobuf/compiler
  38. cp ./types/plugin/plugin.proto $tmpdir/src/google/protobuf/compiler/plugin.proto
  39. PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc -I$tmpdir/src \
  40. --go_out=paths=source_relative:$tmpdir/src \
  41. $tmpdir/src/google/protobuf/compiler/plugin.proto
  42. cp $tmpdir/src/google/protobuf/compiler/plugin.pb.go ./types/plugin/plugin.pb.go