mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: regenerate proto to use local import path
Using Go-style import paths in protos is not idiomatic. Normally, this detail would be internal to etcd, but the path from which gogoproto is imported affects downstream consumers (e.g. cockroachdb). In cockroach, we want to avoid including `$GOPATH/src` in our protoc include path for various reasons. This patch puts etcd on the same convention, which allows this for cockroach. More information: https://github.com/cockroachdb/cockroach/pull/2339#discussion_r38663417 This commit also regenerates all the protos, which seem to have drifted a tiny bit.
This commit is contained in:
@@ -22,7 +22,7 @@ export GOBIN=${PWD}/bin
|
||||
go get github.com/gogo/protobuf/{proto,protoc-gen-gogo,gogoproto}
|
||||
pushd ${GOPATH}/src/github.com/gogo/protobuf/
|
||||
git reset --hard ${SHA}
|
||||
make
|
||||
make install
|
||||
popd
|
||||
|
||||
export PATH="${GOBIN}:${PATH}"
|
||||
@@ -35,10 +35,17 @@ for dir in ${DIRS}; do
|
||||
popd
|
||||
done
|
||||
|
||||
COREOS_ROOT="${GOPATH}/src/github.com/coreos"
|
||||
GOGOPROTO_ROOT="${GOPATH}/src/github.com/gogo/protobuf"
|
||||
GOGOPROTO_PATH="${GOGOPROTO_ROOT}:${GOGOPROTO_ROOT}/protobuf"
|
||||
|
||||
ESCAPED_PREFIX=$(echo $PREFIX | sed -e 's/[\/&]/\\&/g')
|
||||
|
||||
for dir in ${DIRS}; do
|
||||
pushd ${dir}
|
||||
protoc --gogofast_out=plugins=grpc:. -I=.:${GOPATH}/src/github.com/gogo/protobuf/protobuf:${GOPATH}/src *.proto
|
||||
sed -i".bak" -e "s|github.com/gogo/protobuf/proto|${PREFIX}/github.com/gogo/protobuf/proto|" *.go
|
||||
protoc --gogofast_out=plugins=grpc,import_prefix=github.com/coreos/:. -I=.:"${GOGOPROTO_PATH}":"${COREOS_ROOT}" *.proto
|
||||
sed -i.bak -E "s/github\.com\/coreos\/(gogoproto|github\.com|golang\.org|google\.golang\.org)/${ESCAPED_PREFIX}\/\1/g" *.pb.go
|
||||
sed -i.bak -E 's/github\.com\/coreos\/(errors|fmt|io)/\1/g' *.pb.go
|
||||
rm -f *.bak
|
||||
popd
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user