-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
53 lines (37 loc) · 1.32 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
#!/usr/bin/make -f
PACKAGES=$(shell go list ./...)
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
GOBIN ?= $(GOPATH)/bin
export GO111MODULE = on
# process linker flags
ldflags = -X github.com/QOSGroup/qos/version.Version=$(VERSION) \
-X github.com/QOSGroup/qos/version.Commit=$(COMMIT)
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -ldflags '$(ldflags)'
all: install test
########################################
### Build/Install
build:
ifeq ($(OS),Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/qosd.exe ./cmd/qosd
go build -mod=readonly $(BUILD_FLAGS) -o build/qoscli.exe ./cmd/qoscli
else
go build -mod=readonly $(BUILD_FLAGS) -o build/qosd ./cmd/qosd
go build -mod=readonly $(BUILD_FLAGS) -o build/qoscli ./cmd/qoscli
endif
build-linux:
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
install:
go install -mod=readonly $(BUILD_FLAGS) ./cmd/qosd
go install -mod=readonly $(BUILD_FLAGS) ./cmd/qoscli
########################################
### Testing
test: test_unit
test_unit:
@VERSION=$(VERSION) go test -mod=readonly $(PACKAGES) -tags='ledger test_ledger_mock'
test_race:
@VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES)
format:
find . -name '*.go' -type f -not -path "*.git*" | xargs gofmt -w -s