aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/golang/protobuf/ptypes/regen.sh
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/golang/protobuf/ptypes/regen.sh')
-rwxr-xr-xvendor/github.com/golang/protobuf/ptypes/regen.sh37
1 files changed, 7 insertions, 30 deletions
diff --git a/vendor/github.com/golang/protobuf/ptypes/regen.sh b/vendor/github.com/golang/protobuf/ptypes/regen.sh
index 2a5b4e8..b50a941 100755
--- a/vendor/github.com/golang/protobuf/ptypes/regen.sh
+++ b/vendor/github.com/golang/protobuf/ptypes/regen.sh
@@ -8,14 +8,7 @@
PKG=github.com/golang/protobuf/ptypes
UPSTREAM=https://github.com/google/protobuf
UPSTREAM_SUBDIR=src/google/protobuf
-PROTO_FILES='
- any.proto
- duration.proto
- empty.proto
- struct.proto
- timestamp.proto
- wrappers.proto
-'
+PROTO_FILES=(any duration empty struct timestamp wrappers)
function die() {
echo 1>&2 $*
@@ -36,31 +29,15 @@ pkgdir=$(go list -f '{{.Dir}}' $PKG)
echo 1>&2 $pkgdir
base=$(echo $pkgdir | sed "s,/$PKG\$,,")
echo 1>&2 "base: $base"
-cd $base
+cd "$base"
echo 1>&2 "fetching latest protos... "
git clone -q $UPSTREAM $tmpdir
-# Pass 1: build mapping from upstream filename to our filename.
-declare -A filename_map
-for f in $(cd $PKG && find * -name '*.proto'); do
- echo -n 1>&2 "looking for latest version of $f... "
- up=$(cd $tmpdir/$UPSTREAM_SUBDIR && find * -name $(basename $f) | grep -v /testdata/)
- echo 1>&2 $up
- if [ $(echo $up | wc -w) != "1" ]; then
- die "not exactly one match"
- fi
- filename_map[$up]=$f
-done
-# Pass 2: copy files
-for up in "${!filename_map[@]}"; do
- f=${filename_map[$up]}
- shortname=$(basename $f | sed 's,\.proto$,,')
- cp $tmpdir/$UPSTREAM_SUBDIR/$up $PKG/$f
-done
-# Run protoc once per package.
-for dir in $(find $PKG -name '*.proto' | xargs dirname | sort | uniq); do
- echo 1>&2 "* $dir"
- protoc --go_out=. $dir/*.proto
+for file in ${PROTO_FILES[@]}; do
+ echo 1>&2 "* $file"
+ protoc --go_out=. -I$tmpdir/src $tmpdir/src/google/protobuf/$file.proto || die
+ cp $tmpdir/src/google/protobuf/$file.proto $PKG/$file
done
+
echo 1>&2 "All OK"