-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
54 lines (39 loc) · 1.45 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
SHELL := /bin/bash
export GO111MODULE=on
export GOPROXY=
export PATH := $(GOPATH)/bin:$(PATH)
BINARY_VERSION?=0.0.1
BINARY_OUTPUT?=clobber
EXTRA_FLAGS?=-mod=vendor
define timed_function
@d=$$(date +%s); \
$(shell echo $1); \
echo "=> Ran $1 in $$(($$(date +%s)-d)) seconds"
endef
.PHONY: all install uninstall build test clean deps upgrade tidy version
all: deps build
install:
$(call timed_function,'go install -v $(EXTRA_FLAGS) -ldflags "-X main.Version=$(BINARY_VERSION)"')
uninstall:
$(call timed_function,'rm -f $(GOPATH)/bin/$(BINARY_OUTPUT)')
build:
$(call timed_function,'$(GOPATH)/bin/packr2 clean')
$(call timed_function,'$(GOPATH)/bin/packr2')
$(call timed_function,'go build -v $(EXTRA_FLAGS) -ldflags "-X main.Version=$(BINARY_VERSION)" -o $(BINARY_OUTPUT)')
$(call timed_function,'$(GOPATH)/bin/packr2 clean')
test:
$(call timed_function,'go test -v $(EXTRA_FLAGS) -race -coverprofile=coverage.txt -covermode=atomic ./...')
clean:
$(call timed_function,'go clean')
$(call timed_function,'rm -f $(BINARY_OUTPUT)')
deps:
$(call timed_function,'go build -v $(EXTRA_FLAGS) ./...')
$(call timed_function,'packr2 version >/dev/null 2>&1 || { go get github.com/gobuffalo/packr/v2/packr2; }')
upgrade:
$(call timed_function,'go get -u ./...')
$(call timed_function,'go get -u github.com/gobuffalo/packr/v2/packr2')
$(call timed_function,'go mod vendor')
tidy:
$(call timed_function,'go mod tidy')
version:
$(call timed_function,'clobber --version')