2018-08-22 20:46:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2018 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-12-07 22:38:17 +00:00
|
|
|
go generate internal/cmd/generate-types/main.go
|
|
|
|
|
2018-08-22 20:46:02 +00:00
|
|
|
# Install the working tree's protoc-gen-gen in a tempdir.
|
|
|
|
tmpdir=$(mktemp -d -t protobuf-regen.XXXXXX)
|
|
|
|
trap 'rm -rf $tmpdir' EXIT
|
|
|
|
mkdir -p $tmpdir/bin
|
|
|
|
PATH=$tmpdir/bin:$PATH
|
|
|
|
GOBIN=$tmpdir/bin go install ./cmd/protoc-gen-go
|
2018-09-21 22:03:34 +00:00
|
|
|
GOBIN=$tmpdir/bin go install ./cmd/protoc-gen-go-grpc
|
2018-08-22 20:46:02 +00:00
|
|
|
|
|
|
|
# Generate various test protos.
|
|
|
|
PROTO_DIRS=(
|
|
|
|
cmd/protoc-gen-go/testdata
|
2018-12-07 22:38:17 +00:00
|
|
|
internal/testprotos/test
|
2018-08-22 20:46:02 +00:00
|
|
|
)
|
2019-01-26 22:24:59 +00:00
|
|
|
GRPC_PROTO_DIRS=(
|
|
|
|
cmd/protoc-gen-go-grpc/testdata
|
|
|
|
)
|
2018-08-22 20:46:02 +00:00
|
|
|
for dir in ${PROTO_DIRS[@]}; do
|
|
|
|
for p in `find $dir -name "*.proto"`; do
|
|
|
|
echo "# $p"
|
2018-12-05 06:53:56 +00:00
|
|
|
PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc -I$dir \
|
2018-09-21 22:03:34 +00:00
|
|
|
--go_out=paths=source_relative:$dir \
|
2019-01-26 22:24:59 +00:00
|
|
|
$p
|
|
|
|
done
|
|
|
|
done
|
|
|
|
for dir in ${GRPC_PROTO_DIRS[@]}; do
|
|
|
|
for p in `find $dir -name "*.proto"`; do
|
|
|
|
echo "# $p"
|
|
|
|
PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc -I$dir \
|
2018-09-21 22:03:34 +00:00
|
|
|
--go-grpc_out=paths=source_relative:$dir \
|
|
|
|
$p
|
2018-08-22 20:46:02 +00:00
|
|
|
done
|
|
|
|
done
|
2018-12-05 06:53:56 +00:00
|
|
|
|
|
|
|
# Generate descriptor and plugin.
|
|
|
|
# TODO: Make this more automated.
|
|
|
|
|
|
|
|
echo "# types/descriptor/descriptor.proto"
|
|
|
|
mkdir -p $tmpdir/src/google/protobuf
|
|
|
|
cp ./types/descriptor/descriptor.proto $tmpdir/src/google/protobuf/descriptor.proto
|
|
|
|
PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc -I$tmpdir/src \
|
|
|
|
--go_out=paths=source_relative:$tmpdir/src \
|
|
|
|
$tmpdir/src/google/protobuf/descriptor.proto
|
|
|
|
cp $tmpdir/src/google/protobuf/descriptor.pb.go ./types/descriptor/descriptor.pb.go
|
|
|
|
|
|
|
|
echo "# types/plugin/plugin.proto"
|
|
|
|
mkdir -p $tmpdir/src/google/protobuf/compiler
|
|
|
|
cp ./types/plugin/plugin.proto $tmpdir/src/google/protobuf/compiler/plugin.proto
|
|
|
|
PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc -I$tmpdir/src \
|
|
|
|
--go_out=paths=source_relative:$tmpdir/src \
|
|
|
|
$tmpdir/src/google/protobuf/compiler/plugin.proto
|
|
|
|
cp $tmpdir/src/google/protobuf/compiler/plugin.pb.go ./types/plugin/plugin.pb.go
|
2018-12-06 23:28:53 +00:00
|
|
|
|
2019-02-13 22:13:21 +00:00
|
|
|
echo "# encoding/testprotos/pb?/test.proto"
|
2018-12-13 22:19:50 +00:00
|
|
|
PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc --go_out=paths=source_relative:. \
|
2019-02-13 22:13:21 +00:00
|
|
|
encoding/testprotos/pb?/test.proto
|
2018-12-26 23:57:16 +00:00
|
|
|
|
|
|
|
echo "# reflect/protoregistry/testprotos/test.proto"
|
|
|
|
PROTOC_GEN_GO_ENABLE_REFLECT=1 protoc --go_out=paths=source_relative:. \
|
|
|
|
reflect/protoregistry/testprotos/test.proto
|