Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

77 lignes
2.0 KiB

  1. #!/bin/bash
  2. #
  3. # Copyright 2016 Google Inc.
  4. #
  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
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  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.
  16. # This script rebuilds the generated code for the protocol buffers.
  17. # To run this you will need protoc and goprotobuf installed;
  18. # see https://github.com/golang/protobuf for instructions.
  19. # You also need Go and Git installed.
  20. set -e
  21. PKG=google.golang.org/genproto
  22. PROTO_REPO=https://github.com/google/protobuf
  23. GOOGLEAPIS_REPO=https://github.com/googleapis/googleapis
  24. function die() {
  25. echo 1>&2 $*
  26. exit 1
  27. }
  28. # Sanity check that the right tools are accessible.
  29. for tool in go git protoc protoc-gen-go; do
  30. q=$(which $tool) || die "didn't find $tool"
  31. echo 1>&2 "$tool: $q"
  32. done
  33. root=$(go list -f '{{.Root}}' $PKG/... | head -n1)
  34. if [ -z "$root" ]; then
  35. die "cannot find root of $PKG"
  36. fi
  37. remove_dirs=
  38. trap 'rm -rf $remove_dirs' EXIT
  39. if [ -z "$PROTOBUF" ]; then
  40. proto_repo_dir=$(mktemp -d -t regen-cds-proto.XXXXXX)
  41. git clone $PROTO_REPO $proto_repo_dir
  42. remove_dirs="$proto_repo_dir"
  43. # The protoc include directory is actually the "src" directory of the repo.
  44. protodir="$proto_repo_dir/src"
  45. else
  46. protodir="$PROTOBUF/src"
  47. fi
  48. if [ -z "$GOOGLEAPIS" ]; then
  49. apidir=$(mktemp -d -t regen-cds-api.XXXXXX)
  50. git clone $GOOGLEAPIS_REPO $apidir
  51. remove_dirs="$remove_dirs $apidir"
  52. else
  53. apidir="$GOOGLEAPIS"
  54. fi
  55. wait
  56. # Nuke everything, we'll generate them back
  57. rm -r googleapis/ protobuf/
  58. go run regen.go -go_out "$root/src" -pkg_prefix "$PKG" "$apidir" "$protodir"
  59. # Sanity check the build.
  60. echo 1>&2 "Checking that the libraries build..."
  61. go build -v ./...
  62. echo 1>&2 "All done!"