genproto.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh -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"
  8. SHA="20c42d4d4d776b60d32c2d35ecac40a60793f661"
  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 code.google.com/p/gogoprotobuf/{proto,protoc-gen-gogo,gogoproto}
  18. pushd ${GOPATH}/src/code.google.com/p/gogoprotobuf
  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/code.google.com/p/gogoprotobuf/protobuf:${GOPATH}/src *.proto
  26. sed -i".bak" -e "s|code.google.com/p/gogoprotobuf/proto|${PREFIX}/code.google.com/p/gogoprotobuf/proto|" *.go
  27. rm -f *.bak
  28. popd
  29. done