1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #!/bin/bash
- # Copyright 2020 gRPC authors.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- set -eu -o pipefail
- WORKDIR=$(mktemp -d)
- function finish {
- rm -rf "$WORKDIR"
- }
- trap finish EXIT
- export GOBIN=${WORKDIR}/bin
- export PATH=${GOBIN}:${PATH}
- mkdir -p ${GOBIN}
- echo "remove existing generated files"
- # grpc_testingv3/testv3.pb.go is not re-generated because it was
- # intentionally generated by an older version of protoc-gen-go.
- rm -f $(find . -name '*.pb.go' | grep -v 'grpc_testingv3/testv3.pb.go')
- echo "go install google.golang.org/protobuf/cmd/protoc-gen-go"
- (go install google.golang.org/protobuf/cmd/protoc-gen-go)
- echo "go install google.golang.org/grpc/cmd/protoc-gen-go-grpc"
- (go install google.golang.org/grpc/cmd/protoc-gen-go-grpc)
- #echo "go install cmd/protoc-gen-go-grpc"
- #(cd cmd/protoc-gen-go-grpc && go install .)
- #echo "git clone https://github.com/grpc/grpc-proto"
- #git clone --quiet https://github.com/grpc/grpc-proto ${WORKDIR}/grpc-proto
- #echo "git clone https://github.com/protocolbuffers/protobuf"
- #git clone --quiet https://github.com/protocolbuffers/protobuf ${WORKDIR}/protobuf
- SOURCES=(
- $(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^\(profiling/proto/service.proto\|reflection/grpc_reflection_v1alpha/reflection.proto\)$')
- )
- # These options of the form 'Mfoo.proto=bar' instruct the codegen to use an
- # import path of 'bar' in the generated code when 'foo.proto' is imported in
- # one of the sources.
- OPTS=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config,Mgrpc/core/stats.proto=google.golang.org/grpc/interop/grpc_testing/core
- for src in ${SOURCES[@]}; do
- echo "protoc ${src}"
- mkdir -p ${WORKDIR}/out/${src%.proto}
- protoc --go_out=${OPTS}:${WORKDIR}/out/${src%.proto} --go-grpc_out=${OPTS}:${WORKDIR}/out/${src%.proto} ${src}
- echo "output: $(ls ${WORKDIR}/out/${src%.proto}/*/*/*)"
- cp ${WORKDIR}/out/${src%.proto}/*/*/* ${src%.proto}/
- done
- #for src in ${LEGACY_SOURCES[@]}; do
- # echo "protoc ${src}"
- # protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS},require_unimplemented_servers=false:${WORKDIR}/out \
- # -I"." \
- # -I${WORKDIR}/grpc-proto \
- # -I${WORKDIR}/googleapis \
- # -I${WORKDIR}/protobuf/src \
- # -I${WORKDIR}/istio \
- # ${src}
- #done
- #find ${WORKDIR}/out/ -name *.pb.go -exec cp "{}" golang \;
|