OSDN Git Service

Merge pull request #5 from Bytom/develop
[bytom/bytom-spv.git] / Makefile
1 GOTOOLS = \
2                                         github.com/mitchellh/gox \
3                                         github.com/Masterminds/glide
4 PACKAGES=$(shell go list ./... | grep -v '/vendor/')
5 BUILD_TAGS?=bytom
6 TMHOME = $${TMHOME:-$$HOME/.bytom}
7
8 all: install test
9
10 install: get_vendor_deps copy
11         @go install --ldflags '-extldflags "-static"' \
12                 --ldflags "-X github.com/Bytom/blockchain/version.GitCommit=`git rev-parse HEAD`" ./node/
13
14 build: copy
15         go build \
16                 --ldflags "-X github.com/Bytom/blockchain/version.GitCommit=`git rev-parse HEAD`"  -o build/node ./node/
17
18 copy:
19         cp -r vendor/github.com/golang/crypto vendor/golang.org/x/crypto
20         cp -r vendor/github.com/golang/net vendor/golang.org/x/net
21         cp -r vendor/github.com/golang/text vendor/golang.org/x/text
22         cp -r vendor/github.com/golang/tools vendor/golang.org/x/tools
23         cp -r vendor/github.com/golang/time vendor/golang.org/x/time
24
25 # dist builds binaries for all platforms and packages them for distribution
26 dist:
27         @BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'"
28
29 test:
30         @echo "--> Running go test"
31         @go test $(PACKAGES)
32
33 test_race:
34         @echo "--> Running go test --race"
35         @go test -v -race $(PACKAGES)
36
37 test_integrations:
38         @bash ./test/test.sh
39
40 test100:
41         @for i in {1..100}; do make test; done
42
43 draw_deps:
44         # requires brew install graphviz or apt-get install graphviz
45         go get github.com/RobotsAndPencils/goviz
46         @goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
47
48 list_deps:
49         @go list -f '{{join .Deps "\n"}}' ./... | \
50                 grep -v /vendor/ | sort | uniq | \
51                 xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
52
53 get_deps:
54         @echo "--> Running go get"
55         @go get -v -d $(PACKAGES)
56         @go list -f '{{join .TestImports "\n"}}' ./... | \
57                 grep -v /vendor/ | sort | uniq | \
58                 xargs go get -v -d
59
60 get_vendor_deps: ensure_tools
61         @rm -rf vendor/
62         @echo "--> Running glide install"
63         @glide install
64
65 update_deps: tools
66         @echo "--> Updating dependencies"
67         @go get -d -u ./...
68
69 revision:
70         -echo `git rev-parse --verify HEAD` > $(TMHOME)/revision
71         -echo `git rev-parse --verify HEAD` >> $(TMHOME)/revision_history
72
73 tools:
74         go get -u -v $(GOTOOLS)
75
76 ensure_tools:
77         go get $(GOTOOLS)
78
79
80 .PHONY: install build build_race dist test test_race test_integrations test100 draw_deps list_deps get_deps get_vendor_deps update_deps revision tools