-
Notifications
You must be signed in to change notification settings - Fork 289
/
Makefile
90 lines (76 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
89
90
CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMAKE_DEBUG_FLAGS ?= '-DUSERVER_SANITIZE=addr;ub'
CMAKE_RELEASE_FLAGS ?=
KERNEL := $(shell uname -s)
NPROCS ?= $(shell nproc)
DOXYGEN ?= doxygen
DOCKER_COMPOSE ?= docker-compose
# NOTE: use Makefile.local for customization
-include Makefile.local
CMAKE_DEBUG_FLAGS += -DCMAKE_BUILD_TYPE=Debug $(CMAKE_COMMON_FLAGS)
CMAKE_RELEASE_FLAGS += -DCMAKE_BUILD_TYPE=Release $(CMAKE_COMMON_FLAGS)
.DEFAULT_GOAL := all
.PHONY: all
all: test-debug test-release
# Requires doxygen 1.10.0+
.PHONY: docs
docs:
@rm -rf docs/*
@$(DOXYGEN) --version >/dev/null 2>&1 || { \
echo "!!! No Doxygen found."; \
exit 2; \
}
@{ \
DOXYGEN_VERSION_MIN="1.10.0" && \
DOXYGEN_VERSION_CUR=$$($(DOXYGEN) --version | awk -F " " '{print $$1}') && \
DOXYGEN_VERSION_VALID=$$(printf "%s\n%s\n" "$$DOXYGEN_VERSION_MIN" "$$DOXYGEN_VERSION_CUR" | sort -C && echo 0 || echo 1) && \
if [ "$$DOXYGEN_VERSION_VALID" != "0" ]; then \
echo "!!! Doxygen expected version is $$DOXYGEN_VERSION_MIN, but $$DOXYGEN_VERSION_CUR found."; \
echo "!!! See userver/scripts/docs/README.md"; \
exit 2; \
fi \
}
@( \
cat scripts/docs/doxygen.conf; \
echo OUTPUT_DIRECTORY=docs \
) | $(DOXYGEN) -
@echo 'userver.tech' > docs/html/CNAME
@cp docs/html/d8/dee/md_en_2userver_2404.html docs/html/404.html || :
@sed -i 's|\.\./\.\./|/|g' docs/html/404.html
# Run cmake
.PHONY: cmake-debug
cmake-debug:
cmake -B build_debug $(CMAKE_DEBUG_FLAGS)
.PHONY: cmake-release
cmake-release:
cmake -B build_release $(CMAKE_RELEASE_FLAGS)
# Build using cmake
.PHONY: build-debug build-release
build-debug build-release: build-%: cmake-%
cmake --build build_$* -j $(NPROCS)
# Test
.PHONY: test-debug test-release
test-debug test-release: test-%: build-%
ulimit -n 4096
cd build_$* && ((test -t 1 && GTEST_COLOR=1 PYTEST_ADDOPTS="--color=yes" ctest -V) || ctest -V)
# Start targets makefile in docker environment
.PHONY: docker-cmake-debug docker-build-debug docker-test-debug docker-cmake-release docker-build-release docker-test-release
docker-cmake-debug docker-build-debug docker-test-debug docker-cmake-release docker-build-release docker-test-release: docker-%:
$(DOCKER_COMPOSE) run --rm userver-ubuntu make $*
# Stop docker container and remove PG data
.PHONY: docker-clean-data
docker-clean-data:
$(DOCKER_COMPOSE) down -v
.PHONY: docker-enter
docker-enter:
$(DOCKER_COMPOSE) run --rm userver-ubuntu bash
.PHONY: docker-run-ydb docker-kill
docker-run-ydb:
$(DOCKER_COMPOSE) run -d --rm --service-ports run-ydb
docker-kill:
$(DOCKER_COMPOSE) kill
# clean build folders
.PHONY: dist-clean
dist-clean:
rm -rf build_*
rm -rf docs/