Use separated proto repository

Workflow:
- update goland dependencies
- remove old `*.proto` and `*.pb.go` files
- download specific version of neofs-proto (will be published soon)
- extract proto files into `vendor/proto`
- walk throw `vendor/proto` folders that contains `*.proto` files and override in repo
This commit is contained in:
Evgeniy Kulikov 2020-01-30 15:47:05 +03:00
parent 78d1372cf6
commit b42537f8d8
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2

View file

@ -1,7 +1,34 @@
PROTO_VERSION=master
PROTO_URL=https://bitbucket.org/nspcc-dev/neofs-proto/get/$(PROTO_VERSION).tar.gz
B=\033[0;1m B=\033[0;1m
G=\033[0;92m G=\033[0;92m
R=\033[0m R=\033[0m
.PHONY: deps format docgen protoc
# Dependencies
deps:
@echo "${B}${G}=> Golang modules ${R}"
@go mod tidy -v
@go mod vendor
@echo "${B}${G}=> Cleanup old files ${R}"
@find . -type f -name '*.pb.go' -not -path './vendor/*' -exec rm {} \;
@find . -type f -name '*.proto' -not -path './vendor/*' -not -name '*_test.proto' -exec rm {} \;
@echo "${B}${G}=> NeoFS Proto files ${R}"
@mkdir -p ./vendor/proto
@curl -sL -o ./vendor/proto.tar.gz $(PROTO_URL)
@tar -xzf ./vendor/proto.tar.gz --strip-components 1 -C ./vendor/proto
@for f in `find ./vendor/proto -type f -name '*.proto' -exec dirname {} \; | sort -u `; do \
cp $$f/*.proto ./$$(basename $$f); \
done
@echo "${B}${G}=> Cleanup ${R}"
@rm -rf ./vendor/proto
@rm -rf ./vendor/proto.tar.gz
# Reformat code # Reformat code
format: format:
@[ ! -z `which goimports` ] || (echo "install goimports" && exit 2) @[ ! -z `which goimports` ] || (echo "install goimports" && exit 2)
@ -11,7 +38,7 @@ format:
done done
# Regenerate documentation for protot files: # Regenerate documentation for protot files:
docgen: docgen: deps
@for f in `find . -type f -name '*.proto' -not -path './vendor/*' -exec dirname {} \; | sort -u `; do \ @for f in `find . -type f -name '*.proto' -not -path './vendor/*' -exec dirname {} \; | sort -u `; do \
echo "${B}${G}⇒ Documentation for $$(basename $$f) ${R}"; \ echo "${B}${G}⇒ Documentation for $$(basename $$f) ${R}"; \
protoc \ protoc \
@ -21,14 +48,12 @@ docgen:
done done
# Regenerate proto files: # Regenerate proto files:
protoc: protoc: deps
@go mod tidy -v @echo "${B}${G}=> Install specific version for gogo-proto ${R}"
@go mod vendor
# Install specific version for gogo-proto
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/gogo/protobuf | xargs go get -v @go list -f '{{.Path}}/...@{{.Version}}' -m github.com/gogo/protobuf | xargs go get -v
# Install specific version for protobuf lib @echo "${B}${G}=> Install specific version for protobuf lib ${R}"
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/golang/protobuf | xargs go get -v @go list -f '{{.Path}}/...@{{.Version}}' -m github.com/golang/protobuf | xargs go get -v
# Protoc generate @echo "${B}${G}=> Protoc generate ${R}"
@for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \ @for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \
echo "${B}${G}⇒ Processing $$f ${R}"; \ echo "${B}${G}⇒ Processing $$f ${R}"; \
protoc \ protoc \