OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / vendor / github.com / golang / protobuf / ptypes / regen.sh
1 #!/bin/bash -e
2 #
3 # This script fetches and rebuilds the "well-known types" protocol buffers.
4 # To run this you will need protoc and goprotobuf installed;
5 # see https://github.com/golang/protobuf for instructions.
6 # You also need Go and Git installed.
7
8 PKG=github.com/golang/protobuf/ptypes
9 UPSTREAM=https://github.com/google/protobuf
10 UPSTREAM_SUBDIR=src/google/protobuf
11 PROTO_FILES=(any duration empty struct timestamp wrappers)
12
13 function die() {
14   echo 1>&2 $*
15   exit 1
16 }
17
18 # Sanity check that the right tools are accessible.
19 for tool in go git protoc protoc-gen-go; do
20   q=$(which $tool) || die "didn't find $tool"
21   echo 1>&2 "$tool: $q"
22 done
23
24 tmpdir=$(mktemp -d -t regen-wkt.XXXXXX)
25 trap 'rm -rf $tmpdir' EXIT
26
27 echo -n 1>&2 "finding package dir... "
28 pkgdir=$(go list -f '{{.Dir}}' $PKG)
29 echo 1>&2 $pkgdir
30 base=$(echo $pkgdir | sed "s,/$PKG\$,,")
31 echo 1>&2 "base: $base"
32 cd "$base"
33
34 echo 1>&2 "fetching latest protos... "
35 git clone -q $UPSTREAM $tmpdir
36
37 for file in ${PROTO_FILES[@]}; do
38   echo 1>&2 "* $file"
39   protoc --go_out=. -I$tmpdir/src $tmpdir/src/google/protobuf/$file.proto || die
40   cp $tmpdir/src/google/protobuf/$file.proto $PKG/$file
41 done
42
43 echo 1>&2 "All OK"