vikunja-api/vendor/github.com/swaggo/swag/Makefile

91 lines
1.9 KiB
Makefile
Raw Permalink Normal View History

2019-05-07 21:42:24 +02:00
GOCMD:=$(shell which go)
GOLINT:=$(shell which golint)
GOIMPORT:=$(shell which goimports)
GOFMT:=$(shell which gofmt)
GOBUILD:=$(GOCMD) build
2019-10-16 22:52:29 +02:00
GOINSTALL:=$(GOCMD) install
2019-05-07 21:42:24 +02:00
GOCLEAN:=$(GOCMD) clean
GOTEST:=$(GOCMD) test
GOGET:=$(GOCMD) get
GOLIST:=$(GOCMD) list
GOVET:=$(GOCMD) vet
2019-10-16 22:52:29 +02:00
u := $(if $(update),-u)
2019-05-07 21:42:24 +02:00
BINARY_NAME:=swag
2019-10-16 22:52:29 +02:00
PACKAGES:=$(shell $(GOLIST) github.com/swaggo/swag github.com/swaggo/swag/cmd/swag github.com/swaggo/swag/gen)
2019-05-07 21:42:24 +02:00
GOFILES:=$(shell find . -name "*.go" -type f)
export GO111MODULE := on
all: test build
2019-05-07 21:42:24 +02:00
.PHONY: build
2019-10-16 22:52:29 +02:00
build: deps
$(GOBUILD) -o $(BINARY_NAME) ./cmd/swag
.PHONY: install
install: deps
$(GOINSTALL) ./cmd/swag
2019-05-07 21:42:24 +02:00
.PHONY: test
test:
2019-05-07 21:42:24 +02:00
echo "mode: count" > coverage.out
for PKG in $(PACKAGES); do \
$(GOCMD) test -v -covermode=count -coverprofile=profile.out $$PKG > tmp.out; \
cat tmp.out; \
if grep -q "^--- FAIL" tmp.out; then \
rm tmp.out; \
exit 1; \
elif grep -q "build failed" tmp.out; then \
rm tmp.out; \
exit; \
fi; \
if [ -f profile.out ]; then \
cat profile.out | grep -v "mode:" >> coverage.out; \
rm profile.out; \
fi; \
done
2019-05-07 21:42:24 +02:00
.PHONY: clean
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
2019-10-16 22:52:29 +02:00
.PHONY: deps
deps:
$(GOGET) ${u} -d
2019-05-07 21:42:24 +02:00
$(GOGET) github.com/stretchr/testify/assert
2019-10-16 22:52:29 +02:00
$(GOGET) github.com/alecthomas/template
.PHONY: devel-deps
devel-deps:
GO111MODULE=off $(GOGET) -v -u \
golang.org/x/lint/golint \
github.com/swaggo/swag/cmd/swag \
github.com/swaggo/swag/gen
2019-05-07 21:42:24 +02:00
.PHONY: lint
2019-10-16 22:52:29 +02:00
lint: devel-deps
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
2019-05-07 21:42:24 +02:00
.PHONY: vet
2019-10-16 22:52:29 +02:00
vet: deps devel-deps
2019-05-07 21:42:24 +02:00
$(GOVET) $(PACKAGES)
.PHONY: fmt
fmt:
$(GOFMT) -s -w $(GOFILES)
.PHONY: fmt-check
fmt-check:
@diff=$$($(GOFMT) -s -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
2019-05-07 21:42:24 +02:00
.PHONY: view-covered
view-covered:
$(GOTEST) -coverprofile=cover.out $(TARGET)
2019-05-07 21:42:24 +02:00
$(GOCMD) tool cover -html=cover.out