go.uber.org/yarpc@v1.72.1/etc/bin/generate.sh (about) 1 #!/bin/bash 2 3 set -euo pipefail 4 5 DIR="$(cd "$(dirname "${0}")/../.." && pwd)" 6 cd "${DIR}" 7 8 if echo "${GOPATH}" | grep : >/dev/null; then 9 echo "error: GOPATH can only contain one directory but is ${GOPATH}" >&2 10 exit 1 11 fi 12 13 # Run stringer 14 # 15 # https://github.com/golang/go/issues/10249 16 # 17 # $1: type 18 # $2: go package 19 generate_stringer() { 20 go install "${2}" 21 stringer "-type=${1}" "${2}" 22 } 23 24 GOGO_PROTO_DIR=$(go mod download -json github.com/gogo/protobuf | jq -r .Dir) 25 26 # Run protoc 27 # 28 # $1: plugin 29 # $2: file 30 # $3: other options 31 protoc_with_imports() { 32 protoc \ 33 -I "$GOGO_PROTO_DIR/protobuf" \ 34 -I . \ 35 "--${1}_out=${2}Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:." \ 36 "${@:3}" 37 } 38 39 protoc_go() { 40 protoc_with_imports "gogoslick" "" $@ 41 } 42 43 protoc_go_grpc() { 44 protoc_with_imports "gogoslick" "plugins=grpc," $@ 45 } 46 47 protoc_yarpc_go() { 48 protoc_with_imports "yarpc-go" "" $@ 49 } 50 51 protoc_all() { 52 protoc_go_grpc $@ 53 protoc_yarpc_go $@ 54 } 55 56 protoc_with_imports_v2() { 57 protoc \ 58 -I . \ 59 "--${1}_out=${2}Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:." \ 60 "${@:3}" 61 } 62 63 protoc_go_grpc_v2() { 64 protoc_with_imports_v2 "go" "plugins=grpc," $@ 65 } 66 67 protoc_yarpc_go_v2() { 68 protoc_with_imports "yarpc-go-v2" "" $@ 69 } 70 71 protoc_all_v2() { 72 protoc_go_grpc_v2 $@ 73 protoc_yarpc_go_v2 $@ 74 } 75 76 # Add "Generated by" header to Ragel-generated code. 77 # 78 # $1: path to the file 79 generated_by_ragel() { 80 f=$(mktemp -t ragel.XXXXX) 81 # We filter out //line directives because golang/go#27350 affects us in 82 # Go 1.11. 83 echo -e '// Code generated by ragel\n// @generated\n' \ 84 | cat - "$1" \ 85 | grep -v "^//line" \ 86 > "$f" 87 mv "$f" "$1" 88 } 89 90 # Strip thrift warnings. 91 strip_thrift_warnings() { 92 grep -v '^\[WARNING:.*emphasize the signedness' | sed '/^\s*$/d' 93 } 94 95 mockgen -destination=api/middleware/middlewaretest/router.go -package=middlewaretest go.uber.org/yarpc/api/middleware Router,UnaryInbound,UnaryOutbound,OnewayInbound,OnewayOutbound,StreamInbound,StreamOutbound 96 mockgen -destination=api/peer/peertest/list.go -package=peertest go.uber.org/yarpc/api/peer Chooser,List,ChooserList 97 mockgen -destination=api/peer/peertest/peer.go -package=peertest go.uber.org/yarpc/api/peer Identifier,Peer 98 mockgen -destination=api/peer/peertest/transport.go -package=peertest go.uber.org/yarpc/api/peer Transport,Subscriber 99 mockgen -destination=api/transport/transporttest/clientconfig.go -package=transporttest go.uber.org/yarpc/api/transport ClientConfig,ClientConfigProvider 100 mockgen -destination=api/transport/transporttest/handler.go -package=transporttest go.uber.org/yarpc/api/transport UnaryHandler,OnewayHandler,StreamHandler 101 mockgen -destination=api/transport/transporttest/inbound.go -package=transporttest go.uber.org/yarpc/api/transport Inbound 102 mockgen -destination=api/transport/transporttest/outbound.go -package=transporttest go.uber.org/yarpc/api/transport UnaryOutbound,OnewayOutbound,StreamOutbound 103 mockgen -destination=api/transport/transporttest/router.go -package=transporttest go.uber.org/yarpc/api/transport Router,RouteTable 104 mockgen -destination=api/transport/transporttest/stream.go -package=transporttest go.uber.org/yarpc/api/transport Stream,StreamCloser 105 mockgen -destination=api/transport/transporttest/transport.go -package=transporttest go.uber.org/yarpc/api/transport Transport 106 107 generate_stringer ConnectionStatus ./api/peer 108 generate_stringer State ./pkg/lifecycle 109 generate_stringer Type ./api/transport 110 generate_stringer Mode ./api/transport/tls 111 112 thriftrw --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/internal/crossdock/thrift --out=internal/crossdock/thrift internal/crossdock/thrift/echo.thrift 113 thriftrw --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/internal/crossdock/thrift --out=internal/crossdock/thrift internal/crossdock/thrift/oneway.thrift 114 thriftrw --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/internal/crossdock/thrift --out=internal/crossdock/thrift internal/crossdock/thrift/gauntlet.thrift 115 thriftrw --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/internal/examples/thrift-oneway --out=internal/examples/thrift-oneway internal/examples/thrift-oneway/sink.thrift 116 thriftrw --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/internal/examples/thrift-hello/hello --out=internal/examples/thrift-hello/hello internal/examples/thrift-hello/hello/echo.thrift 117 thriftrw --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/internal/examples/thrift-keyvalue/keyvalue --out=internal/examples/thrift-keyvalue/keyvalue internal/examples/thrift-keyvalue/keyvalue/kv.thrift 118 thriftrw --pkg-prefix=go.uber.org/yarpc/encoding/thrift --out=encoding/thrift encoding/thrift/internal.thrift 119 thriftrw --pkg-prefix=go.uber.org/yarpc/serialize --out=serialize serialize/internal.thrift 120 121 thriftrw --no-recurse --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests --out=encoding/thrift/thriftrw-plugin-yarpc/internal/tests encoding/thrift/thriftrw-plugin-yarpc/internal/tests/extends.thrift 122 thriftrw --no-recurse --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests --out=encoding/thrift/thriftrw-plugin-yarpc/internal/tests encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common.thrift 123 thriftrw --no-recurse --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests --out=encoding/thrift/thriftrw-plugin-yarpc/internal/tests encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic.thrift 124 thriftrw --no-recurse --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests --out=encoding/thrift/thriftrw-plugin-yarpc/internal/tests encoding/thrift/thriftrw-plugin-yarpc/internal/tests/NOSERVICES.thrift 125 thriftrw --no-recurse --plugin="yarpc --sanitize-tchannel" --pkg-prefix=go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests --out=encoding/thrift/thriftrw-plugin-yarpc/internal/tests encoding/thrift/thriftrw-plugin-yarpc/internal/tests/weather.thrift 126 thriftrw --no-recurse --plugin=yarpc --pkg-prefix=go.uber.org/yarpc/encoding/thrift/internal/observabilitytest --out=encoding/thrift/internal/observabilitytest encoding/thrift/internal/observabilitytest/test.thrift 127 128 thrift-gen --generateThrift --outputDir internal/crossdock/thrift/gen-go --inputFile internal/crossdock/thrift/echo.thrift 129 thrift-gen --generateThrift --outputDir internal/crossdock/thrift/gen-go --inputFile internal/crossdock/thrift/gauntlet_tchannel.thrift | strip_thrift_warnings 130 131 thrift --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift --out internal/crossdock/thrift/gen-go internal/crossdock/thrift/gauntlet_apache.thrift | strip_thrift_warnings 132 133 protoc_all encoding/protobuf/internal/testpb/test.proto 134 protoc_all internal/examples/protobuf/examplepb/example.proto 135 protoc_all internal/crossdock/crossdockpb/crossdock.proto 136 protoc_all internal/examples/streaming/stream.proto 137 protoc_all internal/prototest/examplepb/example.proto 138 139 protoc_all_v2 encoding/protobuf/internal/testpb/v2/test.proto 140 141 ragel -Z -G2 -o internal/interpolate/parse.go internal/interpolate/parse.rl 142 gofmt -s -w internal/interpolate/parse.go 143 generated_by_ragel internal/interpolate/parse.go 144 145 touch internal/crossdock/thrift/gen-go/echo/.nocover 146 touch internal/crossdock/thrift/gen-go/gauntlet_apache/.nocover 147 touch internal/crossdock/thrift/gen-go/gauntlet_tchannel/.nocover 148 149 rm -rf internal/crossdock/thrift/gen-go/gauntlet_apache/second_service-remote # generated and not needed 150 rm -rf internal/crossdock/thrift/gen-go/gauntlet_apache/thrift_test-remote # generated and not needed 151 152 etc/bin/update-licenses.sh 153 etc/bin/generate-cover-ignore.sh 154 155 rm -f .dockerignore 156 cat .gitignore | sed 's/^\///' > .dockerignore