-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (37 loc) · 1.34 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
PACKAGE = github.com/vechain/thor
GIT_COMMIT = $(shell git --no-pager log --pretty="%h" -n 1)
GIT_TAG = $(shell git tag -l --points-at HEAD)
THOR_VERSION = $(shell cat cmd/thor/VERSION)
DISCO_VERSION = $(shell cat cmd/disco/VERSION)
PACKAGES = `go list ./... | grep -v '/vendor/'`
MAJOR = $(shell go version | cut -d' ' -f3 | cut -b 3- | cut -d. -f1)
MINOR = $(shell go version | cut -d' ' -f3 | cut -b 3- | cut -d. -f2)
export GO111MODULE=on
.PHONY: thor disco all clean test
thor:| go_version_check
@echo "building $@..."
@go build -v -o $(CURDIR)/bin/$@ -ldflags "-X main.version=$(THOR_VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.gitTag=$(GIT_TAG)" ./cmd/thor
@echo "done. executable created at 'bin/$@'"
disco:| go_version_check
@echo "building $@..."
@go build -v -o $(CURDIR)/bin/$@ -ldflags "-X main.version=$(DISCO_VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.gitTag=$(GIT_TAG)" ./cmd/disco
@echo "done. executable created at 'bin/$@'"
dep:| go_version_check
@go mod download
go_version_check:
@if test $(MAJOR) -lt 1; then \
echo "Go 1.16 or higher required"; \
exit 1; \
else \
if test $(MAJOR) -eq 1 -a $(MINOR) -lt 16; then \
echo "Go 1.16 or higher required"; \
exit 1; \
fi \
fi
all: thor disco
clean:
-rm -rf \
$(CURDIR)/bin/thor \
$(CURDIR)/bin/disco
test:| go_version_check
@go test -cover $(PACKAGES)