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.
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)
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"
24 tmpdir=$(mktemp -d -t regen-wkt.XXXXXX)
25 trap 'rm -rf $tmpdir' EXIT
27 echo -n 1>&2 "finding package dir... "
28 pkgdir=$(go list -f '{{.Dir}}' $PKG)
30 base=$(echo $pkgdir | sed "s,/$PKG\$,,")
31 echo 1>&2 "base: $base"
34 echo 1>&2 "fetching latest protos... "
35 git clone -q $UPSTREAM $tmpdir
37 for file in ${PROTO_FILES[@]}; do
39 protoc --go_out=. -I$tmpdir/src $tmpdir/src/google/protobuf/$file.proto || die
40 cp $tmpdir/src/google/protobuf/$file.proto $PKG/$file