-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
206 lines (170 loc) · 6.48 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#---------------------------------------------------------------
# This makefile defines the following targets
#
# - all (default) - buid iroha-build container, and build iroha
# - docker - build iroha runtime container
# - up - running iroha container by docker-compose
# - down - stop and remove iroha container by docker-compose
# - testup - running iroha for test container by docker-compose
# - test - exec all test commands
# - logs - show logs of iroha_node_1 container
# - up4 - running iroha container by docker-compose 4 nodes
# - down4 - stop and remove iroha container by docker-compose 4 ndoes
# - logs4 - show logs of iroha-node[1-4] containers
# - clean - cleaning protobuf schemas and build directory
# - version - show labels in container
#
# - iroha-dev - build iroha-dev container
# - iroha-bld - build iroha binaries
# - iroha-rel - extract binaries, libraries from iroha build
# - iroha - build iroha runtime container
#
# - iroha-up - running iroha container by docker-compose
# - iroha-down - stop and remove iroha container by docker-compose
#---------------------------------------------------------------
# Copyright (c) 2017-2021 Takeshi Yonezu
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.PHONY: all help docker up dwon testup test clean version
BUILD_HOME := $(PWD)/../iroha
IROHA_HOME := /opt/iroha
IROHA_IMG := $(shell grep IROHA_IMG .env | cut -d"=" -f2)
IROHA_PRJ := $(shell grep IROHA_PRJ .env | cut -d"=" -f2)
COMPOSE_PROJECT_NAME := $(shell grep COMPOSE_PROJECT_NAME .env | cut -d'=' -f2)
BUILD_DATE := $(shell echo "`env LC_ALL=C date`")
BUILD_HOST := $(shell hostname)
ifeq ("$(wildcard $(BUILD_HOME))","")
$(error $(BUILD_HOME) does'nt exist. Please clone it.)
endif
ifeq ("$(wildcard .buildno)","")
$(shell echo "1000" >.buildno)
endif
BUILD_NO := $(shell echo "Build `cat .buildno`")
GITLOG := $(shell [ -d $(BUILD_HOME) ] && scripts/iroha-gitlog.sh $(BUILD_HOME))
NUMCORE := $(shell scripts/numcore.sh)
UKERNEL := $(shell uname -s)
UMACHINE := $(shell uname -m)
URELEASE := $(shell uname -r)
ifeq ($(UKERNEL),Linux)
ifeq ($(UMACHINE),x86_64)
DOCKER := Dockerfile
COMPOSE_TEST := docker-compose-test.yml
endif
ifeq ($(UMACHINE),armv7l)
DOCKER := Dockerfile
endif
ifeq ($(UMACHINE),aarch64)
DOCKER := Dockerfile
endif
endif
ifeq ($(UKERNEL),Darwin)
DOCKER := Dockerfile
COMPOSE_TEST := docker-compose-test.yml
endif
ifeq ($(DOCKER), )
$(error This platform "$(UKERNEL)/$(UMACHINE)" is not supported.)
endif
TESTING := ON
ifeq ($(UKERNEL),Darwin)
TESTING := OFF
else
ifneq ($(UMACHINE),x86_64)
TESTING := OFF
else
PRODUCT_NAME := $(shell sudo dmidecode -s system-product-name 2>/dev/null)
ifeq ($(PRODUCT_NAME),VirtualBox)
TESTING := OFF
endif
ifeq ($(PRODUCT_NAME),)
TESTING := OFF
endif
endif
endif
all: vcpkg-build iroha
## all: iroha-dev iroha-bld iroha-rel iroha
help:
@echo "help - show make targets"
@echo "all (default) - buid iroha-dev container, and build iroha"
@echo "docker - build iroha runtime container"
@echo "up - running iroha container by docker-compose"
@echo "down - stop and remove iroha container by docker-compose"
ifneq ($(UMACHINE),armv7l)
@echo "testup - running iroha for test container by docker-compose"
@echo "test - exec all test commands"
endif
@echo "logs - show logs of iroha_node_1 container"
@echo "up4 - running iroha container by docker-compose 4 nodes"
@echo "down4 - stop and remove iroha container by docker-compose 4 ndoes"
@echo "logs4 - show logs of iroha-node[1-4] containers"
@echo "clean - cleaning protobuf schemas and build directory"
@echo "version - show labels in container"
docker: iroha-rel iroha
up: iroha-up
down: iroha-down
ifeq ($(UMACHINE),x86_64)
testup: iroha-testup
endif
vcpkg-build:
bash scripts/vcpkg-build.sh
iroha-dev:
cd docker/dev && docker build --rm --build-arg NUMCORE=$(NUMCORE) -t $(IROHA_PRJ)/$(IROHA_IMG)-dev .
iroha-bld:
sudo rsync -av scripts $(BUILD_HOME)
docker run -t --rm --name iroha-bld -v $(BUILD_HOME):/opt/iroha $(IROHA_PRJ)/$(IROHA_IMG)-dev /opt/iroha/scripts/iroha-bld.sh $(NUMCORE) $(TESTING)
iroha-rel:
docker run -t --rm --name iroha-rel -v $(BUILD_HOME):/opt/iroha -w /opt/iroha $(IROHA_PRJ)/$(IROHA_IMG)-dev /opt/iroha/scripts/iroha-rel.sh
sudo rsync -av ${BUILD_HOME}/docker/iroha docker/rel
sudo rm -fr ${BUILD_HOME}/docker/iroha
iroha:
mkdir -p docker/rel/iroha
rsync -av ${BUILD_HOME}/build/bin docker/rel/iroha
strip docker/rel/iroha/bin/*
cd docker/rel; docker build --rm --build-arg GITLOG="$(GITLOG)" --build-arg BUILD_DATE="$(BUILD_DATE)" --build-arg BUILD_NO="$(BUILD_NO)" --build-arg BUILD_HOST="$(BUILD_HOST)" -t $(IROHA_PRJ)/$(IROHA_IMG) .
@scripts/build-no.sh
iroha-up:
docker-compose -p $(COMPOSE_PROJECT_NAME) up -d
iroha-down:
docker-compose -p $(COMPOSE_PROJECT_NAME) down -v
up4:
ifeq ($(UMACHINE),armv7l)
cd example/node4; COMPOSE_HTTP_TIMEOUT=120 docker-compose -p $(COMPOSE_PROJECT_NAME) up -d
else
cd example/node4; docker-compose -p $(COMPOSE_PROJECT_NAME) up -d
endif
down4:
cd example/node4; docker-compose -p $(COMPOSE_PROJECT_NAME) down -v
ifeq ($(UMACHINE),x86_64)
iroha-testup:
docker-compose -p $(COMPOSE_PROJECT_NAME) -f $(COMPOSE_TEST) up -d
test:
cd scripts && bash iroha-test.sh
endif
logs:
docker logs -f iroha_node_1
logs4:
cd example/node4; bash logs4.sh
clean:
-sudo rm -fr docker/rel/iroha
ifneq ("$(wildcard $(BUILD_HOME)/scripts/numcore.sh)","")
-sudo rm $(BUILD_HOME)/scripts/iroha*.sh
-sudo rm $(BUILD_HOME)/scripts/build-no.sh
-sudo rm $(BUILD_HOME)/scripts/iroha-test.lst
-sudo rm $(BUILD_HOME)/scripts/numcore.sh
endif
-sudo rm -fr $(BUILD_HOME)/external
-sudo rm -fr $(BUILD_HOME)/build
-sudo rm -fr $(BUILD_HOME)/cmake-build-debug
-sudo rm -fr ${BUILD_HOME}/vcpkg/vcpkg
version:
docker inspect -f {{.Config.Labels}} $(IROHA_PRJ)/$(IROHA_IMG)