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
|
bin
|
||||||
temp
|
temp
|
||||||
/vendor/
|
/vendor/
|
||||||
|
|
79
Makefile
79
Makefile
|
@ -1,61 +1,50 @@
|
||||||
PROTO_VERSION=v1.2.0
|
#!/usr/bin/make -f
|
||||||
PROTO_URL=https://github.com/nspcc-dev/neofs-api/archive/$(PROTO_VERSION).tar.gz
|
SHELL = bash
|
||||||
|
|
||||||
B=\033[0;1m
|
.PHONY: dep fmts fmt imports protoc
|
||||||
G=\033[0;92m
|
|
||||||
R=\033[0m
|
|
||||||
|
|
||||||
.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
|
# Run all code formaters
|
||||||
deps:
|
fmts: fmt imports
|
||||||
@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
|
|
||||||
|
|
||||||
# Reformat code
|
# Reformat code
|
||||||
format:
|
fmt:
|
||||||
@[ ! -z `which goimports` ] || (echo "install goimports" && exit 2)
|
@echo "⇒ Processing gofmt check"
|
||||||
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
||||||
echo "${B}${G}⇒ Processing $$f ${R}"; \
|
GO111MODULE=on gofmt -s -w $$f; \
|
||||||
goimports -w $$f; \
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Regenerate documentation for protot files:
|
# Reformat imports
|
||||||
docgen: deps
|
imports:
|
||||||
@for f in `find . -type f -name '*.proto' -not -path './vendor/*' -exec dirname {} \; | sort -u `; do \
|
@echo "⇒ Processing goimports check"
|
||||||
echo "${B}${G}⇒ Documentation for $$(basename $$f) ${R}"; \
|
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
||||||
protoc \
|
GO111MODULE=on goimports -w $$f; \
|
||||||
--doc_opt=.github/markdown.tmpl,$${f}.md \
|
|
||||||
--proto_path=.:./vendor:/usr/local/include \
|
|
||||||
--doc_out=docs/ $${f}/*.proto; \
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Regenerate proto files:
|
# Regenerate proto files:
|
||||||
protoc:
|
protoc:
|
||||||
@echo "${B}${G}⇒ Cleanup old files ${R}"
|
@GOPRIVATE=github.com/nspcc-dev go mod vendor
|
||||||
@find . -type f -name '*.pb.go' -not -path './vendor/*' -exec rm {} \;
|
# Install specific version for protobuf lib
|
||||||
@echo "${B}${G}⇒ Protoc generate ${R}"
|
@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 \
|
@for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \
|
||||||
echo "${B}${G}⇒ Processing $$f ${R}"; \
|
echo "⇒ Processing $$f "; \
|
||||||
protoc \
|
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; \
|
--gofast_out=plugins=grpc,paths=source_relative:. $$f; \
|
||||||
done
|
done
|
||||||
|
rm -rf vendor
|
||||||
update: docgen protoc
|
|
||||||
|
|
Loading…
Reference in a new issue