forked from miketout/lightwalletd
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
161 lines (125 loc) · 5.79 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# /************************************************************************
# File: Makefile
# Author: mdr0id
# Date: 7/16/2019
# Description: Used for local and container dev in CI deployments
# Usage: make <target_name>
#
# Copyright (c) 2020 The Zcash developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
#
# Known bugs/missing features:
# 1. make msan is not stable as of 9/20/2019
#
# ************************************************************************/
PROJECT_NAME := "lightwalletd"
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v '*_test.go')
GO_TEST_FILES := $(shell find . -name '*_test.go' -type f | rev | cut -d "/" -f2- | rev | sort -u)
GO_BUILD_FILES := $(shell find . -name 'main.go')
VERSION := `git describe --tags`
GITCOMMIT := `git rev-parse HEAD`
BUILDDATE := `date +%Y-%m-%d`
BUILDUSER := `whoami`
LDFLAGSSTRING :=-X github.com/asherda/lightwalletd/common.Version=$(VERSION)
LDFLAGSSTRING +=-X github.com/asherda/lightwalletd/common.GitCommit=$(GITCOMMIT)
LDFLAGSSTRING +=-X github.com/asherda/lightwalletd/common.Branch=$(BRANCH)
LDFLAGSSTRING +=-X github.com/asherda/lightwalletd/common.BuildDate=$(BUILDDATE)
LDFLAGSSTRING +=-X github.com/asherda/lightwalletd/common.BuildUser=$(BUILDUSER)
LDFLAGS :=-ldflags "$(LDFLAGSSTRING)"
# There are some files that are generated but are also in source control
# (so that the average clone - build doesn't need the required tools)
GENERATED_FILES := docs/rtd/index.html walletrpc/compact_formats.pb.go walletrpc/service.pb.go walletrpc/darkside.proto
PWD := $(shell pwd)
.PHONY: all dep build clean test coverage lint doc simpledoc proto
all: first-make-timestamp build $(GENERATED_FILES)
# Ensure that the generated files that are also in git source control are
# initially more recent than the files they're generated from (so we don't try
# to rebuild them); this isn't perfect because it depends on doing a make before
# editing a .proto file; also, "make -jn" may trigger remake if n > 1.
first-make-timestamp:
touch $(GENERATED_FILES) $@
# Lint golang files
lint:
golint -set_exit_status
show_tests:
@echo ${GO_TEST_FILES}
# Run unittests
test:
go test -v ./...
# Run data race detector
race:
GO111MODULE=on CGO_ENABLED=1 go test -v -race -short ./...
# Run memory sanitizer (need to ensure proper build flag is set)
msan:
go test -v -msan -short ${GO_TEST_FILES}
# Generate global code coverage report, ignore generated *.pb.go files
coverage:
go test -coverprofile=coverage.out ./...
sed -i '/\.pb\.go/d' coverage.out
# Generate code coverage report
coverage_report: coverage
go tool cover -func=coverage.out
# Generate code coverage report in HTML
coverage_html: coverage
go tool cover -html=coverage.out
# Generate documents, requires docker, see https://github.com/pseudomuto/protoc-gen-doc
doc: docs/rtd/index.html
docs/rtd/index.html: walletrpc/compact_formats.proto walletrpc/service.proto walletrpc/darkside.proto
docker run --rm -v $(PWD)/docs/rtd:/out -v $(PWD)/walletrpc:/protos pseudomuto/protoc-gen-doc
proto: walletrpc/service.pb.go walletrpc/darkside.pb.go walletrpc/compact_formats.pb.go
walletrpc/service.pb.go: walletrpc/service.proto
cd walletrpc && protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative service.proto
walletrpc/darkside.pb.go: walletrpc/darkside.proto
cd walletrpc && protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative darkside.proto
walletrpc/compact_formats.pb.go: walletrpc/compact_formats.proto
cd walletrpc && protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative compact_formats.proto
# Generate documents using a very simple wrap-in-html approach (not ideal)
simpledoc: lwd-api.html
lwd-api.html: walletrpc/compact_formats.proto walletrpc/service.proto
./docgen.sh $^ >lwd-api.html
# Generate docker image
docker_img:
docker build -t zcash_lwd_base .
# Run the above docker image in a container
docker_img_run:
docker run -i --name zcashdlwd zcash_lwd_base
# Execture a bash process on zcashdlwdcontainer
docker_img_bash:
docker exec -it zcashdlwd bash
# Start the zcashd process in the zcashdlwd container
docker_img_run_zcashd:
docker exec -i zcashdlwd zcashd -printtoconsole
# Stop the zcashd process in the zcashdlwd container
docker_img_stop_zcashd:
docker exec -i zcashdlwd zcash-cli stop
# Start the lightwalletd server in the zcashdlwd container
docker_img_run_lightwalletd_insecure_server:
docker exec -i zcashdlwd server --no-tls-very-insecure=true --conf-file /home/zcash/.zcash/zcash.conf --log-file /logs/server.log --bind-addr 127.0.0.1:18232
# Remove and delete ALL images and containers in Docker; assumes containers are stopped
docker_remove_all:
docker system prune -f
# Get dependencies
dep:
@go get -v -d ./...
cd parser/verushash && mkdir "build" && cd build && cmake .. && make
# Build binary
build:
GO111MODULE=on go build $(LDFLAGS)
build_rel:
GO111MODULE=on GOOS=linux go build $(LDFLAGS)
# Install binaries into Go path
install:
go install ./...
# Update your protoc, protobufs, grpc, .pb.go files
update-grpc:
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u google.golang.org/grpc
cd walletrpc && protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative service.proto
cd walletrpc && protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative darkside.proto
cd walletrpc && protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative compact_formats.proto
go mod tidy && go mod vendor
clean:
@echo "clean project..."
#rm -f $(PROJECT_NAME)