-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
63 lines (53 loc) · 1.5 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
PREFIX?=$(shell pwd)
.PHONY: clean all fmt vet lint build test save
.DEFAULT: all
all: clean fmt vet lint save build test
dist: build
local: dev
APP_NAME=main
GOLINT := $(shell which golint || echo '')
GODEP := $(shell which godep || echo '')
PKGS := $(shell go list ./... | grep -v ^github.com/stackcats/TRSpeexGo/vendor/)
save:
@echo "+ $@"
$(if $(GODEP), , \
$(error Please install godep: go get github.com/tools/godep))
@$(GODEP) save $(PKGS)
clean:
@echo "+ $@"
@rm -rf "${PREFIX}/bin/"
@rm -rf "${PREFIX}/Godeps/"
@rm -rf "${PREFIX}/vendor/"
fmt:
@echo "+ $@"
@test -z "$$(gofmt -s -l . 2>&1 | grep -v ^vendor/ | tee /dev/stderr)" || \
(echo >&2 "+ please format Go code with 'gofmt -s'" && false)
vet:
@echo "+ $@"
@go vet -tags "${DOCKER_BUILDTAGS}" $(PKGS)
lint:
@echo "+ $@"
$(if $(GOLINT), , \
$(error Please install golint: `go get -u github.com/golang/lint/golint 需翻墙!`))
@test -z "$$($(GOLINT) ./... 2>&1 | grep -v ^vendor/ | tee /dev/stderr)"
test:
@echo "+ $@"
@go test -test.short $(PKGS)
build:
@echo "+ $@"
$(if $(GODEP), , \
$(error Please install godep: go get github.com/tools/godep))
@mkdir "${PREFIX}/bin"
rm -rf ${PREFIX}/vendor/github.com/geekypanda
@${GODEP} go build -v -o ${APP_NAME}
@mv ${APP_NAME} "${PREFIX}/bin/"
dev:
@rm -rf "${PREFIX}/bin/"
@mkdir "${PREFIX}/bin"
@go build -v -o ${APP_NAME}
@mv ${APP_NAME} "${PREFIX}/bin/"
restore:
@echo "+ $@"
$(if $(GODEP), , \
$(error Please install godep: go get github.com/tools/godep))
@$(GODEP) restore -v