forked from nspcc-dev/tzhash
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (48 loc) · 1.28 KB
/
Makefile
File metadata and controls
61 lines (48 loc) · 1.28 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
#!/usr/bin/make -f
SHELL = bash
REPO ?= $(shell go list -m)
VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
BIN = bin
DIRS = $(BIN)
# List of binaries to build.
CMDS = $(notdir $(basename $(wildcard cmd/*)))
BINS = $(addprefix $(BIN)/, $(CMDS))
.PHONY: all help clean
# To build a specific binary, use it's name prefix with bin/ as a target
# For example `make bin/tzsum` will build only storage node binary
# Just `make` will build all possible binaries
all: $(DIRS) $(BINS)
# help target
include help.mk
$(BINS): $(DIRS) dep
@echo "⇒ Build $@"
CGO_ENABLED=0 \
go build -v -trimpath \
-ldflags "-X $(REPO)/misc.Version=$(VERSION)" \
-o $@ ./cmd/$(notdir $@)
$(DIRS):
@echo "⇒ Ensure dir: $@"
@mkdir -p $@
# Pull go dependencies
dep:
@printf "⇒ Download requirements: "
CGO_ENABLED=0 \
go mod download && echo OK
@printf "⇒ Tidy requirements : "
CGO_ENABLED=0 \
go mod tidy -v && echo OK
# Run Unit Test with go test
test:
@echo "⇒ Running go test"
@go test ./...
# Run Unit Test with go test
test.generic:
@echo "⇒ Running go test with generic tag"
@go test ./... --tags=generic
# Print version
version:
@echo $(VERSION)
clean:
rm -rf vendor
rm -rf .cache
rm -rf $(BIN)