3 # Copyright 2016 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # This script rebuilds the generated code for the protocol buffers.
18 # To run this you will need protoc and goprotobuf installed;
19 # see https://github.com/golang/protobuf for instructions.
20 # You also need Go and Git installed.
24 PKG=google.golang.org/genproto
25 PROTO_REPO=https://github.com/google/protobuf
26 PROTO_SUBDIR=src/google/protobuf
27 API_REPO=https://github.com/googleapis/googleapis
34 # Sanity check that the right tools are accessible.
35 for tool in go git protoc protoc-gen-go; do
36 q=$(which $tool) || die "didn't find $tool"
40 root=$(go list -f '{{.Root}}' $PKG/... | head -n1)
41 if [ -z "$root" ]; then
42 die "cannot find root of $PKG"
46 trap 'rm -rf $remove_dirs' EXIT
48 if [ -z "$PROTOBUF" ]; then
49 proto_repo_dir=$(mktemp -d -t regen-cds-proto.XXXXXX)
50 git clone -q $PROTO_REPO $proto_repo_dir &
51 remove_dirs="$proto_repo_dir"
52 # The protoc include directory is actually the "src" directory of the repo.
53 protodir="$proto_repo_dir/src"
55 protodir="$PROTOBUF/src"
58 if [ -z "$GOOGLEAPIS" ]; then
59 apidir=$(mktemp -d -t regen-cds-api.XXXXXX)
60 git clone -q $API_REPO $apidir &
61 remove_dirs="$remove_dirs $apidir"
68 # Nuke everything, we'll generate them back
69 rm -r googleapis/ protobuf/
71 go run regen.go -go_out "$root/src" -pkg_prefix "$PKG" "$apidir" "$protodir"
73 # Sanity check the build.
74 echo 1>&2 "Checking that the libraries build..."