-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (32 loc) · 1.37 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
BIN=cj
PKG=github.com/elliottpolk/cj
VERSION=`cat .version`
GOOS?=linux
BUILD_DIR=./build/bin
M = $(shell printf "\033[34;1m◉\033[0m")
default: clean build ; @ ## defaulting to clean and build
.PHONY: all
all: clean test build install
.PHONEY: build-dir
build-dir: ;
@[ ! -d "${BUILD_DIR}" ] && mkdir -vp "${BUILD_DIR}/public" || true
.PHONY: build
build: build-dir; $(info $(M) building ...) @ ## build the binary
@GOOS=$(GOOS) go build -ldflags "-X main.version=$(VERSION) -X main.compiled=$(date +%s)" -o ./build/bin/$(BIN) cmd/main.go
@chmod +x ./build/bin/$(BIN)
.PHONY: install
install: ; $(info $(M) installing locally...) @ ## install the binary locally
@GOOS=$(GOOS) go build -ldflags "-X main.version=$(VERSION) -X main.compiled=$(date +%s)" -o $(GOPATH)/bin/$(BIN) cmd/main.go
@chmod +x $(GOPATH)/bin/$(BIN)
.PHONY: test
test: ; $(info $(M) running unit tests ...) @ ## run the unit tests
@go test -v -cover ./...
.PHONY: clean
clean: ; $(info $(M) running clean ...) @ ## clean up the old build dir
@rm -vrf build || true
@rm -v $(GOPATH)/bin/$(BIN) || true
@go clean
.PHONY: help
help:
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'