forked from vmware/concord-bft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
131 lines (115 loc) · 5.22 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
CONCORD_BFT_DOCKER_REPO:=concordbft/
CONCORD_BFT_DOCKER_IMAGE:=concord-bft
CONCORD_BFT_DOCKER_IMAGE_VERSION:=0.4
CONCORD_BFT_DOCKER_CONTAINER:=concord-bft
CONCORD_BFT_DOCKERFILE:=Dockerfile
CONCORD_BFT_BUILD_DIR:=build
CONCORD_BFT_TARGET_SOURCE_PATH:=/concord-bft
CONCORD_BFT_CONTAINER_SHELL:=/bin/bash
CONCORD_BFT_CONTAINER_CC:=clang
CONCORD_BFT_CONTAINER_CXX:=clang++
CONCORD_BFT_CMAKE_FLAGS:=-DUSE_CONAN=OFF \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TESTING=ON \
-DBUILD_COMM_TCP_PLAIN=FALSE \
-DBUILD_COMM_TCP_TLS=FALSE \
-DCMAKE_CXX_FLAGS_RELEASE=-O3 -g \
-DUSE_LOG4CPP=TRUE \
-DBUILD_ROCKSDB_STORAGE=TRUE \
-DUSE_S3_OBJECT_STORE=FALSE \
-DUSE_OPENTRACING=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DOMIT_TEST_OUTPUT=OFF
# The consistency parameter makes sense only at MacOS.
# It is ignored at all other platforms.
CONCORD_BFT_CONTAINER_MOUNT_CONSISTENCY=,consistency=cached
CONCORD_BFT_CTEST_TIMEOUT:=3000 # Default value is 1500 sec. It takes 2500 to run all the tests at my dev station
CONCORD_BFT_ADDITIONAL_RUN_PARAMS:=
CONCORD_BFT_ADDITIONAL_RUN_COMMANDS:=
# MakefileCustom may be useful for overriding the default variables
# or adding custom targets. The include directive is ignored if MakefileCustom file does not exist.
-include MakefileCustom
.PHONY: help
help: ## The Makefile helps to build Concord-BFT in a docker container
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Basic HOW-TO:
# make pull # Pull image from Docker Hub
# make run-c # Run container in background
# make build-s # Build Concord-BFT sources
# make test # Run tests
# make remove-c # Remove existing container
# make build-docker-image # Build docker image locally
.PHONY: pull
pull: ## Pull image from remote
docker pull ${CONCORD_BFT_DOCKER_REPO}${CONCORD_BFT_DOCKER_IMAGE}:${CONCORD_BFT_DOCKER_IMAGE_VERSION}
.PHONY: run-c
run-c: ## Run container in background
docker run -d --rm --privileged=true \
--cap-add NET_ADMIN --cap-add=SYS_PTRACE --ulimit core=-1 \
--name="${CONCORD_BFT_DOCKER_CONTAINER}" \
--workdir=${CONCORD_BFT_TARGET_SOURCE_PATH} \
--mount type=bind,source=${CURDIR},target=/cores \
--mount type=bind,source=${CURDIR},target=${CONCORD_BFT_TARGET_SOURCE_PATH}${CONCORD_BFT_CONTAINER_MOUNT_CONSISTENCY} \
${CONCORD_BFT_ADDITIONAL_RUN_PARAMS} \
${CONCORD_BFT_DOCKER_REPO}${CONCORD_BFT_DOCKER_IMAGE}:${CONCORD_BFT_DOCKER_IMAGE_VERSION} \
${CONCORD_BFT_CONTAINER_SHELL} -c \
"${CONCORD_BFT_ADDITIONAL_RUN_COMMANDS} \
/usr/bin/tail -f /dev/null"
@echo
@echo "The container \"${CONCORD_BFT_DOCKER_CONTAINER}\" with the build environment is started as daemon."
@echo "Run \"make stop-c\" to stop or \"make remove-c\" to delete."
.PHONY: login
login: ## Login to the container
docker exec -it ${CONCORD_BFT_DOCKER_CONTAINER} \
${CONCORD_BFT_CONTAINER_SHELL};exit 0
.PHONY: stop-c
stop-c: ## Stop the container
docker container stop ${CONCORD_BFT_DOCKER_CONTAINER}
@echo
@echo "The container \"${CONCORD_BFT_DOCKER_CONTAINER}\" is successfully stopped."
.PHONY: remove-c
remove-c: ## Remove the container
docker container rm -f ${CONCORD_BFT_DOCKER_CONTAINER}
@echo
@echo "The container \"${CONCORD_BFT_DOCKER_CONTAINER}\" is successfully removed."
.PHONY: build
build: ## Build Concord-BFT source. Note: this command is mostly for developers
docker exec -t ${CONCORD_BFT_DOCKER_CONTAINER} \
${CONCORD_BFT_CONTAINER_SHELL} -c \
"mkdir -p ${CONCORD_BFT_TARGET_SOURCE_PATH}/${CONCORD_BFT_BUILD_DIR} && \
cd ${CONCORD_BFT_BUILD_DIR} && \
CC=${CONCORD_BFT_CONTAINER_CC} CXX=${CONCORD_BFT_CONTAINER_CXX} \
cmake ${CONCORD_BFT_CMAKE_FLAGS} .. && \
make format-check && \
make -j $$(nproc)"
@echo
@echo "Build finished. The binaries are in ${CURDIR}/${CONCORD_BFT_BUILD_DIR}"
.PHONY: test
test: ## Run all tests
docker exec -t ${CONCORD_BFT_DOCKER_CONTAINER} \
${CONCORD_BFT_CONTAINER_SHELL} -c \
"cd ${CONCORD_BFT_BUILD_DIR} && \
ctest --timeout ${CONCORD_BFT_CTEST_TIMEOUT} --output-on-failure"
.PHONY: single-test
single-test: ## Run single test `make single-test TEST_NAME=<test name>`
docker exec -t ${CONCORD_BFT_DOCKER_CONTAINER} \
${CONCORD_BFT_CONTAINER_SHELL} -c \
"cd ${CONCORD_BFT_BUILD_DIR} && \
ctest -R ${TEST_NAME} --timeout ${CONCORD_BFT_CTEST_TIMEOUT} --output-on-failure"
.PHONY: clean
clean: ## Clean Concord-BFT build directory
docker exec -t ${CONCORD_BFT_DOCKER_CONTAINER} \
${CONCORD_BFT_CONTAINER_SHELL} -c \
"rm -rf ${CONCORD_BFT_BUILD_DIR}"
.PHONY: build-docker-image
build-docker-image: ## Re-build the container without caching
docker build --rm --no-cache=true -t ${CONCORD_BFT_DOCKER_IMAGE}:latest \
-f ./${CONCORD_BFT_DOCKERFILE} .
@echo
@echo "Build finished. Docker image name: \"${CONCORD_BFT_DOCKER_IMAGE}:latest\"."
@echo "Before you push it to Docker Hub, please tag it(CONCORD_BFT_DOCKER_IMAGE_VERSION + 1)."
@echo "If you want the image to be the default, please update the following variables:"
@echo "1. ${CURDIR}/Makefile: CONCORD_BFT_DOCKER_IMAGE_VERSION"
@echo "2. ${CURDIR}/.travis.yml: DOCKER_IMAGE_VER"
@echo "3. ${CURDIR}/.github/workflows/build_and_test.yml: DOCKER_IMAGE_VER"