-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
60 lines (51 loc) · 1.27 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
GOMAXPROCS = 4
PROJECT = "github.com/bruj0/vault-plugin-auth-u2f"
NAME = $(shell go run version/cmd/main.go name)
VERSION = $(shell go run version/cmd/main.go version)
COMMIT = $(shell git rev-parse --short HEAD)
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
LDFLAGS = \
-s \
-w \
-X ${PROJECT}/version.GitCommit=${COMMIT}
# XC_* are the platforms for cross-compiling. Customize these values to suit
# your needs.
XC_OS = linux
XC_ARCH = amd64
XC_EXCLUDE =
# default is the default make command
default: dev
fmt:
gofmt -w $(GOFMT_FILES)
# deps updates the project deps using golang/dep
deps:
@dep ensure -v -update
.PHONY: deps
# dev builds and installs the plugin for local development
dev:
@env \
CGO_ENABLED=1 \
go install \
-ldflags="${LDFLAGS}" \
./cmd/... && cp $(HOME)/go/bin/vault-plugin-auth-u2f plugins/u2f
.PHONY: dev
# test runs the tests
test:
@go test -timeout=60s -parallel=10 ./...
.PHONY: test
# xc compiles all the binaries using the local go installation
xc:
@for OS in $(XC_OS); do \
for ARCH in $(XC_ARCH); do \
env \
CGO_ENABLED=0 \
GOOS=$${OS} \
GOARCH=$${ARCH} \
go build \
-a \
-o "pkg/$${OS}_$${ARCH}/${NAME}" \
-ldflags "${LDFLAGS}"
./cmd/... ; \
done \
done
.PHONY: xc