-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (48 loc) · 1.81 KB
/
Makefile
File metadata and controls
63 lines (48 loc) · 1.81 KB
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
BINARY_NAME := localnet
CMD_DIR := ./cmd/localnet
BIN_DIR := bin
DIST_DIR := dist
COVER_FILE := coverage.out
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w \
-X github.com/klever-io/kleverchain-localnet/internal/version.Version=$(VERSION) \
-X github.com/klever-io/kleverchain-localnet/internal/version.Commit=$(COMMIT) \
-X github.com/klever-io/kleverchain-localnet/internal/version.Date=$(BUILD_DATE)
GO ?= go
GOFLAGS ?=
.PHONY: all build test test-race lint fmt cover install clean tidy help
all: lint test build
build:
@mkdir -p $(BIN_DIR)
$(GO) build $(GOFLAGS) -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/$(BINARY_NAME) $(CMD_DIR)
install:
$(GO) install $(GOFLAGS) -trimpath -ldflags "$(LDFLAGS)" $(CMD_DIR)
test:
$(GO) test $(GOFLAGS) ./...
test-race:
$(GO) test $(GOFLAGS) -race ./...
cover:
$(GO) test $(GOFLAGS) -race -coverprofile=$(COVER_FILE) -covermode=atomic ./...
$(GO) tool cover -func=$(COVER_FILE)
lint:
golangci-lint run ./...
fmt:
$(GO) fmt ./...
@command -v goimports >/dev/null 2>&1 && goimports -w -local github.com/klever-io/kleverchain-localnet . || true
tidy:
$(GO) mod tidy
clean:
rm -rf $(BIN_DIR) $(DIST_DIR) $(COVER_FILE)
help:
@echo "Targets:"
@echo " build Build the localnet binary into $(BIN_DIR)/"
@echo " install Install the localnet binary into GOBIN"
@echo " test Run unit tests"
@echo " test-race Run unit tests with the race detector"
@echo " cover Run tests and report coverage"
@echo " lint Run golangci-lint"
@echo " fmt Run gofmt and goimports"
@echo " tidy Run go mod tidy"
@echo " clean Remove build artifacts"