This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
137 lines (109 loc) · 3.74 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
UNAME := $(shell uname)
USER_MAKEFILE := user.mk
PIP_INSTALL := pip3 install
ifeq ($(wildcard $(USER_MAKEFILE)),)
INSTALL_REQUIRES := requires
INSTALL_DEVELOP_REQUIRES := requires-dev
PIP_INSTALL_CMD := $(PIP_INSTALL) -e .
PIP_INSTALL_DEVELOP_CMD := $(PIP_INSTALL_CMD)[tests]
else
include $(USER_MAKEFILE)
endif
PIP_INSTALL += -U
ifeq ($(UNAME), Darwin)
RABBITMQ_CMD := rabbitmqctl
else ifeq ($(UNAME), Linux)
RABBITMQ_CMD := sudo rabbitmqctl
endif
CLEAN_TARGETS := clean-process clean-mq clean-pyc clean-db clean-log clean-test
TEST_CMD := python -m pytest -rsxX
help:
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][-_[:alnum:]]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}'\
$(MAKEFILE_LIST) | column -s: -t
## Check all requirements are installed and started properly.
requirements:
@command -v automake > /dev/null || echo "Error: automake is not installed."
@command -v pkg-config > /dev/null || echo "Error: pkg-config is not installed."
@command -v libtool > /dev/null || dpkg -l libtool > /dev/null || echo "Error: libtool is not installed."
@command -v openssl > /dev/null || echo "Error: openssl is not installed."
@if [ "$$(ps -e | grep '[r]abbitmq-server')" = "" ]; then\
echo "Rabbitmq server is not running locally.";\
fi
@echo "The check for required packages installation is completed."
## pip install packages & generate all
all: install generate-key
requires:
$(PIP_INSTALL) iconservice~=1.8.0
$(PIP_INSTALL) iconrpcserver~=1.6.0
$(PIP_INSTALL) iconsdk~=1.3.2
## pip install packages
install: $(INSTALL_REQUIRES)
$(PIP_INSTALL_CMD)
requires-dev:
$(PIP_INSTALL) git+https://github.com/icon-project/icon-service.git@develop
$(PIP_INSTALL) git+https://github.com/icon-project/icon-rpc-server.git@develop
## pip install packages for develop
develop: $(INSTALL_DEVELOP_REQUIRES)
$(PIP_INSTALL_DEVELOP_CMD)
## Generate python gRPC proto
generate-proto:
@echo "Generating python grpc code from proto"
@python3 setup.py build_proto_modules
## Generate a key
generate-key:
@file="my_keystore.json"; $(RM) $${file} > /dev/null; \
python -c "import getpass; from iconsdk.wallet.wallet import KeyWallet; \
KeyWallet.create().store('$${file}', getpass.getpass('Input your keystore password: '))"; \
cat $${file}
## Check loopchain & gunicorn & rabbitmq processes
check:
@echo "Check loopchain & Gunicorn & RabbitMQ Process..."
ps -ef | egrep --color=auto "loop|gunicorn"
@$(RABBITMQ_CMD) list_queues
## Run unittest
test: unit-test integration-test
unit-test:
@echo "Start unit test..."
$(TEST_CMD) tests/unit --benchmark-disable || exit -1
integration-test:
@echo "Start integration test..."
$(TEST_CMD) tests/integration || exit -1
## Clean all - clean-process clean-mq clean-pyc clean-db clean-log clean-test
clean: $(CLEAN_TARGETS) check
clean-process:
@pkill -f loop || true
@pkill -f gunicorn || true
clean-mq:
@echo "Cleaning up RabbitMQ..."
@$(RABBITMQ_CMD) stop_app
@$(RABBITMQ_CMD) reset
@$(RABBITMQ_CMD) start_app
clean-build:
@$(RM) -r build/ dist/
@$(RM) -r .eggs/ eggs/ *.egg-info/
clean-pyc:
@echo "Clear __pycache__"
@find . -name '*.pyc' -exec $(RM) {} +
@find . -name '*.pyo' -exec $(RM) {} +
@find . -name '*~' -exec $(RM) {} +
clean-db:
@echo "Cleaning up all DB..."
@$(RM) -r .storage*
clean-log:
@echo "Cleaning up logs..."
@$(RM) -r log/
clean-test:
@echo "Cleaning up test related cache..."
@$(RM) -r .hypothesis/ .xprocess/ .pytest_cache/
clean-proto:
@find . -name 'loopchain_pb*.py' -exec $(RM) {} +
## build python wheel
build: clean-build clean-proto
@if [ "$$(python -c 'import sys; print(sys.version_info[0])')" != 3 ]; then\
@echo "The script should be run on python3.";\
exit -1;\
fi
@if ! python -c 'import wheel' &> /dev/null; then \
pip install wheel; \
fi
python3 setup.py bdist_wheel