-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
41 lines (29 loc) · 1.52 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
CURRENTOS := $(shell go env GOOS)
CURRENTARCH := $(shell go env GOARCH)
COMMIT := $(shell git rev-parse --short HEAD)
VERSION := v1.3.6
LDFLAGS="-X main.buildVersion=$(VERSION) -X main.commitVersion=$(COMMIT)"
.DEFAULT_GOAL := build
help: ## List targets & descriptions
@grep --no-filename -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
build: clean test darwin-binary linux-binary copy-binary ## Build all the binaries
clean: ## Delete the destination directory.
rm -rf ./bin
test: mocks ## Run unit tests
go test -v ./...
darwin-binary: mocks ## Build a macOS binary
GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags $(LDFLAGS) -o bin/vault-ctrl-tool.darwin.amd64 .
GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags $(LDFLAGS) -o bin/vault-ctrl-tool.darwin.arm64 .
linux-binary: mocks ## Build a Linux (amd64) binary
GOOS=linux GOARCH=amd64 go build -trimpath -ldflags $(LDFLAGS) -o bin/vault-ctrl-tool.linux.amd64 .
GOOS=linux GOARCH=arm64 go build -trimpath -ldflags $(LDFLAGS) -o bin/vault-ctrl-tool.linux.arm64 .
# Useful when doing development
copy-binary:
cp bin/vault-ctrl-tool.$(CURRENTOS).$(CURRENTARCH) vault-ctrl-tool
deps: ## Ensure dependencies are present and prune orphaned
go mod download
go mod tidy
vaultclient/mocks/vaultclient.go: vaultclient/vaultclient.go
mockgen -source=$< -destination=$@
mocks: vaultclient/mocks/vaultclient.go
.PHONY: help mocks deps copy-binary linux-binary darwin-binary test clean build