forked from TrueCloudLab/frostfs-api-go
Simplify Makefile
Signed-off-by: Stanislav Bogatyrev <stanislav@nspcc.ru>
This commit is contained in:
parent
59033d330d
commit
1a9b163561
3 changed files with 37 additions and 46 deletions
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -1 +1,2 @@
|
|||
/**/*.pb.go -diff binary
|
||||
/**/*.pb.go -diff -merge
|
||||
/**/*.pb.go linguist-generated=true
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
.idea
|
||||
bin
|
||||
temp
|
||||
/vendor/
|
||||
|
|
79
Makefile
79
Makefile
|
@ -1,61 +1,50 @@
|
|||
PROTO_VERSION=v1.2.0
|
||||
PROTO_URL=https://github.com/nspcc-dev/neofs-api/archive/$(PROTO_VERSION).tar.gz
|
||||
#!/usr/bin/make -f
|
||||
SHELL = bash
|
||||
|
||||
B=\033[0;1m
|
||||
G=\033[0;92m
|
||||
R=\033[0m
|
||||
.PHONY: dep fmts fmt imports protoc
|
||||
|
||||
.PHONY: deps format docgen protoc
|
||||
# Pull go dependencies
|
||||
dep:
|
||||
@printf "⇒ Tidy requirements : "
|
||||
CGO_ENABLED=0 \
|
||||
GO111MODULE=on \
|
||||
go mod tidy -v && echo OK
|
||||
@printf "⇒ Download requirements: "
|
||||
CGO_ENABLED=0 \
|
||||
GO111MODULE=on \
|
||||
go mod download && echo OK
|
||||
@printf "⇒ Install test requirements: "
|
||||
CGO_ENABLED=0 \
|
||||
GO111MODULE=on \
|
||||
go test -i ./... && echo OK
|
||||
|
||||
# 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 '*.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
|
||||
# Run all code formaters
|
||||
fmts: fmt imports
|
||||
|
||||
# Reformat code
|
||||
format:
|
||||
@[ ! -z `which goimports` ] || (echo "install goimports" && exit 2)
|
||||
fmt:
|
||||
@echo "⇒ Processing gofmt check"
|
||||
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
||||
echo "${B}${G}⇒ Processing $$f ${R}"; \
|
||||
goimports -w $$f; \
|
||||
GO111MODULE=on gofmt -s -w $$f; \
|
||||
done
|
||||
|
||||
# Regenerate documentation for protot files:
|
||||
docgen: deps
|
||||
@for f in `find . -type f -name '*.proto' -not -path './vendor/*' -exec dirname {} \; | sort -u `; do \
|
||||
echo "${B}${G}⇒ Documentation for $$(basename $$f) ${R}"; \
|
||||
protoc \
|
||||
--doc_opt=.github/markdown.tmpl,$${f}.md \
|
||||
--proto_path=.:./vendor:/usr/local/include \
|
||||
--doc_out=docs/ $${f}/*.proto; \
|
||||
# Reformat imports
|
||||
imports:
|
||||
@echo "⇒ Processing goimports check"
|
||||
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
||||
GO111MODULE=on goimports -w $$f; \
|
||||
done
|
||||
|
||||
# Regenerate proto files:
|
||||
protoc:
|
||||
@echo "${B}${G}⇒ Cleanup old files ${R}"
|
||||
@find . -type f -name '*.pb.go' -not -path './vendor/*' -exec rm {} \;
|
||||
@echo "${B}${G}⇒ Protoc generate ${R}"
|
||||
@GOPRIVATE=github.com/nspcc-dev go mod vendor
|
||||
# Install specific version for protobuf lib
|
||||
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/golang/protobuf | xargs go get -v
|
||||
# Protoc generate
|
||||
@for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \
|
||||
echo "${B}${G}⇒ Processing $$f ${R}"; \
|
||||
echo "⇒ Processing $$f "; \
|
||||
protoc \
|
||||
--proto_path=.:./vendor:/usr/local/include \
|
||||
--proto_path=.:./vendor:./vendor/github.com/nspcc-dev/neofs-api:/usr/local/include \
|
||||
--gofast_out=plugins=grpc,paths=source_relative:. $$f; \
|
||||
done
|
||||
|
||||
update: docgen protoc
|
||||
rm -rf vendor
|
||||
|
|
Loading…
Reference in a new issue