-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
68 lines (48 loc) · 1.72 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
# __
# _____/ /_ __ ______ _____ __ ____ ______
# / ___/ __ \/ / / / __ `/ __ \/ / / / / / / __ \
# / /__/ / / / /_/ / /_/ / / / / /_/ / /_/ / / / /
# \___/_/ /_/\__,_/\__,_/_/ /_/\__, /\__,_/_/ /_/
# /____/
# ================================================
# chuanyun.io esmeralda program.
GO ?= GO15VENDOREXPERIMENT=1 go
GOPATH ?= $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
STATICCHECK ?= $(GOPATH)/bin/staticcheck
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
BINARY = esmeralda
DATE ?= $(shell date +%FT%T%z)
COMMIT ?= $(shell git describe --tags --always --dirty="-dev" --match=v* 2> /dev/null || echo v0)
BUILD_TARGET = $(CURDIR)/target
LDFLAGS = -ldflags "-X main.commit=${COMMIT} -X main.buildstamp=${DATE}"
ifeq ($(OS),Windows_NT)
BINARY := $(BINARY).exe
endif
all: format vet build install
@echo
@echo "Build complete."
@echo "Don't forget to run 'make test'."
@echo
format:
@echo ">> formatting code"
@$(GO) fmt $(pkgs)
vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)
staticcheck: $(STATICCHECK)
@echo ">> running staticcheck"
@$(STATICCHECK) $(pkgs)
build:
@echo ">> building binaries"
@$(GO) build $(LDFLAGS) -o $(BUILD_TARGET)/$(BINARY)
install:
@echo ">> installing binaries"
@cp -f $(CURDIR)/esmeralda.sh $(BUILD_TARGET)/esmeralda.sh
@cp -f $(CURDIR)/esmeralda.toml $(BUILD_TARGET)/esmeralda.toml
test:
@echo ">> running tests"
@$(GO) test -short -race $(pkgs)
$(GOPATH)/bin/staticcheck:
@GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
.PHONY: all format vet build test
.PHONY: $(GOPATH)/bin/staticcheck