This repository was archived by the owner on Jun 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
58 lines (48 loc) · 1.34 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
NAME := lab
VERSION := v0.6.3
REVISION := $(shell git rev-parse --short HEAD)
GOVERSION := $(go version)
SRCS := $(shell find . -type f -name '*.go')
LDFLAGS := -ldflags="-s -w -X \"main.version=$(VERSION)\" -X \"main.revision=$(REVISION)\" -X \"main.goversion=$(GOVERSION)\" "
DIST_DIRS := find * -type d -exec
.PHONY: dep
dep:
ifeq ($(shell command -v dep 2> /dev/null),)
go get github.com/golang/dep/...
endif
.PHONY: ensure
ensure: dep
$(GOPATH)/bin/dep ensure
.PHONY: test
test:
go test github.com/lighttiger2505/lab/...
.PHONY: lint
lint:
@if [ "`gometalinter ./... --config=metaconfig.json | tee /dev/stderr`" ]; then \
echo "^ - lint err" && echo && exit 1; \
fi
.PHONY: build
build: $(SRCS)
go build $(LDFLAGS) ./...
.PHONY: install
install: $(SRCS)
go install $(LDFLAGS) ./...
.PHONY: coverage
coverage:
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
.PHONY: cross-build
cross-build: ensure
for os in darwin linux windows; do \
for arch in amd64 386; do \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build $(LDFLAGS) -o dist/$$os-$$arch/$(NAME); \
done; \
done
.PHONY: dist
dist:
cd dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf $(NAME)-$(VERSION)-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r $(NAME)-$(VERSION)-{}.zip {} \; && \
cd ..