This repository has been archived by the owner on Oct 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
81 lines (65 loc) · 2.29 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
NAME := matterpoll-emoji
VERSION := v0.2.0
REVISION := $(shell git rev-parse --short HEAD)
LDFLAGS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\" -extldflags \"-static\""
DIST_DIRS := find * -type d -exec
.PHONY: run clean test coverage install-tools update-deps check-style cross-build dist
all: test
run:
go run cmd/matterpoll-emoji/main.go
clean:
rm -rf bin/*
rm -rf vendor/*
rm -rf dist/*
test:
go test ./poll/
coverage:
go test -coverprofile=coverage.txt -covermode=atomic ./poll/
go tool cover -html=coverage.txt
install-tools:
go get -u golang.org/x/lint/golint
update-deps:
dep ensure
dep ensure -update
check-style:
$(eval DIRECTORIES_NOVENDOR_FULLPATH := $(shell go list ./... | grep -v /vendor/))
$(eval GOFILES_NOVENDOR := $(shell find . -type f -name '*.go' -not -path './vendor/*'))
@echo running gofmt
$(eval GOFMT_OUTPUT := $(shell gofmt -l -s $(GOFILES_NOVENDOR) 2>&1))
@if [ ! "$(GOFMT_OUTPUT)" ]; then \
echo "gofmt success\n"; \
else \
echo "gofmt failure. Please run:"; \
echo " gofmt -w -s $(GOFMT_OUTPUT)"; \
exit 1; \
fi
@echo running go vet
$(eval GO_VET_OUTPUT := $(shell go vet $(DIRECTORIES_NOVENDOR_FULLPATH) 2>&1))
@if [ ! "$(GO_VET_OUTPUT)" ]; then \
echo "go vet success\n"; \
else \
echo "go vet failure. You need to fix these errors:"; \
go vet $(DIRECTORIES_NOVENDOR_FULLPATH); \
fi
@echo running golint
$(eval GOLINT_OUTPUT := $(shell golint $(DIRECTORIES_NOVENDOR_FULLPATH) 2>&1))
@if [ ! "$(GOLINT_OUTPUT)" ]; then \
echo "golint success"; \
else \
echo "golint failure. You might want to fix these errors:"; \
golint $(DIRECTORIES_NOVENDOR_FULLPATH); \
fi
cross-build:
for os in darwin linux windows; do \
GOOS=$$os GOARCH=386 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo $(LDFLAGS) -o dist/$$os-i686/$(NAME) cmd/matterpoll-emoji/main.go; \
done
for os in darwin linux windows; do \
GOOS=$$os GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo $(LDFLAGS) -o dist/$$os-x86_64/$(NAME) cmd/matterpoll-emoji/main.go; \
done
dist: cross-build
cd dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) cp ../.config.json {}/config.json \; && \
$(DIST_DIRS) tar -zcf $(NAME)-$(VERSION)-{}.tar.gz {} \; && \
cd ..