-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (41 loc) · 1.83 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
BINARY=packer-builder-sandwich
PACKAGES=$(shell glide novendor)
SOURCE_FILES=$(shell find . -name '*.go' -not -path '*vendor*')
VERSION=dev
.PHONY: all build check clean coverage fmt help lint test vet
all: check build test ## run fmt, vet, lint, build the binaries and run the tests
check: fmt vet lint ## run fmt, vet, lint
vet: ## run go vet
@echo "Running $@"
@test -z "$$(go vet ${PACKAGES} 2>&1 | tee /dev/stderr)"
fmt: ## run go fmt
@echo "Running $@"
@gofmt -s -l -w ${SOURCE_FILES}
build: ## build the go packages
@echo "Running $@"
@go build -ldflags "-X main.Version=${VERSION}" -o bin/${BINARY} .
cp bin/${BINARY} ~/.packer.d/plugins/${BINARY}
build-linux: ## build the go packages for Linux
@echo "Running $@"
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.Version=${VERSION}" -o bin/${BINARY}_linux_amd64 .
build-osx: ## build the go packages for OSX
@echo "Running $@"
@GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.Version=${VERSION}" -o bin/${BINARY}_darwin_amd64 .
build-windows: ## build the go packages for Windows
@echo "Running $@"
@GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.Version=${VERSION}" -o bin/${BINARY}_windows_amd64.exe .
localvendor:
@rm -rf vendor/github.com/sandwichcloud/deli-cli
@cp -r $$GOPATH/src/github.com/sandwichcloud/deli-cli vendor/github.com/sandwichcloud/deli-cli
@ rm -rf vendor/github.com/sandwichcloud/deli-cli/vendor
test: ## run test
@echo "Running $@"
@go test ${PACKAGES}
coverage: ## run tests with coverage metrics
@echo "Running $@"
@go test -cover ${PACKAGES}
clean: ## clean up binaries
@echo "Running $@"
@rm -rf bin
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort