-
Notifications
You must be signed in to change notification settings - Fork 47
/
Makefile
88 lines (72 loc) · 2.62 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
# This Makefile is meant to be used by people that do not usually work
# with Go source code. If you know what GOPATH is then you probably
# don't need to bother with make.
include main.mk
TARGETS := $(sort $(filter-out Dockerfile, $(filter-out flags, $(notdir $(wildcard ./cmd/*)))))
PHONY += $(TARGETS)
PHONY += all
all: $(TARGETS)
.SECONDEXPANSION:
$(TARGETS): $(addprefix $(GOBIN)/,$$@)
$(GOBIN):
@mkdir -p $@
$(GOBIN)/%: $(GOBIN) FORCE
@go build -v -o $@ ./cmd/$(notdir $@)
@echo "Done building."
@echo "Run \"$(subst $(CURDIR),.,$@)\" to launch $(notdir $@)."
migration-%:
@$(MAKE) -f migration/Makefile $@
coverage.txt:
@touch $@
test: coverage.txt FORCE
@$(MAKE) migration-docker
@for d in `go list ./... | grep -v vendor | grep -v mock`; do \
go test -v -coverprofile=profile.out -covermode=atomic $$d; \
if [ $$? -eq 0 ]; then \
echo "\033[32mPASS\033[0m:\t$$d"; \
if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \
rm profile.out; \
fi \
else \
echo "\033[31mFAIL\033[0m:\t$$d"; \
exit -1; \
fi \
done;
contracts: FORCE
$(shell solc contracts/erc20.sol --bin --abi --optimize --overwrite --output-dir contracts)
$(shell abigen --type ERC20Token --abi contracts/ERC20Token.abi -bin contracts/ERC20Token.bin -out contracts/erc20_token.go --pkg contracts)
$(shell abigen --type MithrilToken --abi contracts/MithrilToken.abi -bin contracts/MithrilToken.bin -out contracts/mithril_token.go --pkg contracts)
eth-indexer-docker:
@docker build -f ./cmd/Dockerfile -t $(DOCKER_IMAGE):$(DOCKER_IMAGE_TAG) .
@docker tag $(DOCKER_IMAGE):$(DOCKER_IMAGE_TAG) $(DOCKER_IMAGE):latest
eth-indexer-docker.push:
@docker push $(DOCKER_IMAGE):$(DOCKER_IMAGE_TAG)
@docker push $(DOCKER_IMAGE):latest
PHONY += clean
clean:
rm -fr $(GOBIN)/*
PHONY += help
help:
@echo 'Generic targets:'
@echo '* indexer - Build eth-indexer'
@echo ''
@echo 'Code generation targets:'
@echo ' contracts - Compile solidity contracts'
@echo ''
@echo 'Docker targets:'
@echo ' eth-indexer-docker - Build eth-indexer docker image'
@echo ' eth-indexer-docker.push - Push eth-indexer docker image to quay.io'
@$(MAKE) -f migration/Makefile $@
@echo ''
@echo 'Test targets:'
@echo ' test - Run all unit tests'
@echo ''
@echo 'Cleaning targets:'
@echo ' clean - Remove built executables'
@echo ''
@echo 'Execute "make" or "make all" to build all targets marked with [*] '
@echo 'For further info see the ./README.md file'
PHONY += FORCE
FORCE:
.PHONY: $(PHONY)