genproto.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash -e
  2. #
  3. # Generate all etcd protobuf bindings.
  4. # Run from repository root.
  5. #
  6. PREFIX="github.com/coreos/etcd/Godeps/_workspace/src"
  7. DIRS="./wal/walpb ./etcdserver/etcdserverpb ./snap/snappb ./raft/raftpb ./migrate/etcd4pb ./storage/storagepb"
  8. SHA="bc946d07d1016848dfd2507f90f0859c9471681e"
  9. if ! protoc --version > /dev/null; then
  10. echo "could not find protoc, is it installed + in PATH?"
  11. exit 255
  12. fi
  13. # Ensure we have the right version of protoc-gen-gogo by building it every time.
  14. # TODO(jonboulle): vendor this instead of `go get`ting it.
  15. export GOPATH=${PWD}/gopath
  16. export GOBIN=${PWD}/bin
  17. go get github.com/gogo/protobuf/{proto,protoc-gen-gogo,gogoproto}
  18. pushd ${GOPATH}/src/github.com/gogo/protobuf/
  19. git reset --hard ${SHA}
  20. make
  21. popd
  22. export PATH="${GOBIN}:${PATH}"
  23. for dir in ${DIRS}; do
  24. pushd ${dir}
  25. protoc --gogo_out=. -I=.:${GOPATH}/src/github.com/gogo/protobuf/protobuf:${GOPATH}/src *.proto
  26. sed -i".bak" -e "s|github.com/gogo/protobuf/proto|${PREFIX}/github.com/gogo/protobuf/proto|" *.go
  27. rm -f *.bak
  28. popd
  29. done