-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
68 lines (47 loc) · 1.78 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
61
62
63
64
65
66
67
68
PKGS := $(shell go list ./... | grep -v /vendor)
BIN_DIR := $(GOPATH)/bin
# Try to detect current branch if not provided from environment
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
# Commit hash from git
COMMIT=$(shell git rev-parse --short HEAD)
# Tag on this commit
TAG = $(shell git tag --points-at HEAD)
ifneq ("$(shell which gotestsum)", "")
TESTEXE := gotestsum --
else
TESTEXE := go test ./...
endif
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
VERSION := $(or $(TAG),$(COMMIT)-$(BRANCH)-$(BUILD_DATE))
LDFLAGS = -X main.Version=$(VERSION) -X main.GitCommit=$(COMMIT) -X main.BuildDate=$(BUILD_DATE)
all: test lint build coverage ## test, lint, build, coverage test run
.PHONY: all deps install grammar antlr build lint test coverage clean
lint: ## Run golangci-lint
golangci-lint run
coverage: ## Verify the test coverage remains high
./scripts/check-coverage.sh 40
test: ## Run tests without coverage
$(TESTEXE)
BINARY := wbnf
PLATFORMS := windows linux darwin
.PHONY: $(PLATFORMS)
$(PLATFORMS): build
mkdir -p release
GOOS=$@ GOARCH=amd64 \
go build -o release/$(BINARY)-$(VERSION)-$@$(shell test $@ = windows && echo .exe) \
-ldflags="$(LDFLAGS)" \
-v \
./cmd/sysl
build: ## Build wbnf into the ./dist folder
go build -o ./dist/$(BINARY) -ldflags="$(LDFLAGS)" -v .
deps: ## Download the project dependencies with `go get`
go get -v -d ./...
.PHONY: release
release: $(PLATFORMS) ## Build release binaries for all supported platforms into ./release
install: build ## Install the wbnf binary into $(GOPATH)/bin
cp ./dist/$(BINARY) $(GOPATH)/bin
clean: ## Clean temp and build files
rm -rf release dist
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'