blob: 2fdb546a63335a08a0c82688066c80291a02a112 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001#!/bin/bash -e
2#
3# This script rebuilds the generated code for the protocol buffers.
4# To run this you will need protoc and goprotobuf installed;
5# see https://github.com/golang/protobuf for instructions.
6
7PKG=google.golang.org/appengine
8
9function die() {
10 echo 1>&2 $*
11 exit 1
12}
13
14# Sanity check that the right tools are accessible.
15for tool in go protoc protoc-gen-go; do
16 q=$(which $tool) || die "didn't find $tool"
17 echo 1>&2 "$tool: $q"
18done
19
20echo -n 1>&2 "finding package dir... "
21pkgdir=$(go list -f '{{.Dir}}' $PKG)
22echo 1>&2 $pkgdir
23base=$(echo $pkgdir | sed "s,/$PKG\$,,")
24echo 1>&2 "base: $base"
25cd $base
26
27# Run protoc once per package.
28for dir in $(find $PKG/internal -name '*.proto' | xargs dirname | sort | uniq); do
29 echo 1>&2 "* $dir"
30 protoc --go_out=. $dir/*.proto
31done
32
33for f in $(find $PKG/internal -name '*.pb.go'); do
34 # Remove proto.RegisterEnum calls.
35 # These cause duplicate registration panics when these packages
36 # are used on classic App Engine. proto.RegisterEnum only affects
37 # parsing the text format; we don't care about that.
38 # https://code.google.com/p/googleappengine/issues/detail?id=11670#c17
39 sed -i '/proto.RegisterEnum/d' $f
40done