-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (61 loc) · 2.02 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
69
70
71
72
73
# These variables get inserted into build/commit.go
GIT_REVISION=$(shell git rev-parse --short HEAD)
GIT_DIRTY=$(shell git diff-index --quiet HEAD -- || echo "✗-")
ifeq ("$(GIT_DIRTY)", "✗-")
BUILD_TIME=$(shell date)
else
BUILD_TIME=$(shell git show -s --format=%ci HEAD)
endif
ldflags= \
-X "github.com/mike76-dev/hostscore/internal/build.NodeBinaryName=hsd" \
-X "github.com/mike76-dev/hostscore/internal/build.NodeVersion=1.1.5" \
-X "github.com/mike76-dev/hostscore/internal/build.ClientBinaryName=hsc" \
-X "github.com/mike76-dev/hostscore/internal/build.ClientVersion=1.4.5" \
-X "github.com/mike76-dev/hostscore/internal/build.GitRevision=${GIT_DIRTY}${GIT_REVISION}" \
-X "github.com/mike76-dev/hostscore/internal/build.BuildTime=${BUILD_TIME}"
# all will build and install release binaries
all: release
# pkgs changes which packages the makefile calls operate on.
pkgs = \
./api \
./cmd/hsc \
./cmd/hsd \
./external \
./hostdb \
./persist \
./rhp \
./wallet
# release-pkgs determine which packages are built for release and distribution
# when running a 'make release' command.
release-pkgs = ./cmd/hsc ./cmd/hsd
# lockcheckpkgs are the packages that are checked for locking violations.
lockcheckpkgs = \
./cmd/hsc \
./cmd/hsd
# dependencies list all packages needed to run make commands used to build
# and lint hsc/hsd locally and in CI systems.
dependencies:
go get -d ./...
# fmt calls go fmt on all packages.
fmt:
gofmt -s -l -w $(pkgs)
# vet calls go vet on all packages.
# NOTE: go vet requires packages to be built in order to obtain type info.
vet:
go vet $(pkgs)
static:
go build -trimpath -o release/ -tags='netgo' -ldflags='-s -w $(ldflags)' $(release-pkgs)
# release builds and installs release binaries.
release:
go install -tags='netgo' -ldflags='-s -w $(ldflags)' $(release-pkgs)
# clean removes all directories that get automatically created during
# development.
clean:
ifneq ("$(OS)","Windows_NT")
# Linux
rm -rf release
else
# Windows
- DEL /F /Q release
endif
.PHONY: all fmt install release clean