-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
40 lines (30 loc) · 1.25 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
.PHONY: build lint clean help all
ARCH ?= amd64
BIN_NAME = workers-scale
BIN_DIR = bin
BIN_PATH = $(BIN_DIR)/$(ARCH)/$(BIN_NAME)
CGO = 0
GIT_COMMIT = $(shell git rev-parse HEAD)
VERSION ?= $(shell hack/tag_name.sh)
SOURCES := $(shell find . -type f -name "*.go")
BUILD_DATE = $(shell date '+%Y-%m-%d-%H:%M:%S')
VERSION_PKG=github.com/cloud-bulldozer/go-commons/version
all: lint build
help:
@echo "Commands for $(BIN_PATH):"
@echo
@echo 'Usage:'
@echo ' make lint Install and execute pre-commit'
@echo ' make clean Clean the compiled binaries'
@echo ' [ARCH=arch] make build Compile the project for arch, default amd64'
@echo ' [ARCH=arch] make install Installs kube-burner binary in the system, default amd64'
@echo ' make help Show this message'
build: $(BIN_PATH)
$(BIN_PATH): $(SOURCES)
@echo -e "\033[2mBuilding $(BIN_PATH)\033[0m"
@echo "GOPATH=$(GOPATH)"
GOARCH=$(ARCH) CGO_ENABLED=$(CGO) go build -v -ldflags "-X $(VERSION_PKG).GitCommit=$(GIT_COMMIT) -X $(VERSION_PKG).BuildDate=$(BUILD_DATE) -X $(VERSION_PKG).Version=$(VERSION)" -o $(BIN_PATH) ./workerscale/cmd/
lint:
find . -name '*.go' -type f -exec go fmt {} \;
install:
cp $(BIN_PATH) /usr/bin/$(BIN_NAME)