generated from userver-framework/service_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (92 loc) · 3.93 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
CMAKE_COMMON_FLAGS ?= -DUSERVER_OPEN_SOURCE_BUILD=1 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE='addr ub'
CMAKE_RELEASE_FLAGS ?=
CMAKE_OS_FLAGS ?= -DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0 -DUSERVER_FEATURE_REDIS_HI_MALLOC=1
NPROCS ?= $(shell nproc)
# NOTE: use Makefile.local for customization
-include Makefile.local
all: test-debug test-release
# Debug cmake configuration
build_debug/Makefile:
@git submodule update --init
@mkdir -p build_debug
@cd build_debug && \
cmake -DCMAKE_BUILD_TYPE=Debug $(CMAKE_COMMON_FLAGS) $(CMAKE_DEBUG_FLAGS) $(CMAKE_OS_FLAGS) $(CMAKE_OPTIONS) ..
# Release cmake configuration
build_release/Makefile:
@git submodule update --init
@mkdir -p build_release
@cd build_release && \
cmake -DCMAKE_BUILD_TYPE=Release $(CMAKE_COMMON_FLAGS) $(CMAKE_RELEASE_FLAGS) $(CMAKE_OS_FLAGS) $(CMAKE_OPTIONS) ..
# build using cmake
build-impl-%: build_%/Makefile
@cmake --build build_$* -j $(NPROCS) --target static_server
# test
test-impl-%: build-impl-%
#@cmake --build build_$* -j $(NPROCS) --target static_server_unittest
#@cmake --build build_$* -j $(NPROCS) --target static_server_benchmark
@cd build_$* && ((test -t 1 && GTEST_COLOR=1 PYTEST_ADDOPTS="--color=yes" ctest -V) || ctest -V)
@pep8 tests
# testsuite service runner
service-impl-start-%: build-impl-%
./build_$*/tests/runtests-static_server-testsuite \
--service-runner-mode -vvs ./tests
# clean
clean-impl-%:
cd build_$* && $(MAKE) clean
# dist-clean
.PHONY: dist-clean
dist-clean:
@rm -rf build_*
@rm -f ./configs/static_config.yaml
# format
.PHONY: format
format:
@find src -name '*pp' -type f | xargs clang-format -i
@find tests -name '*.py' -type f | xargs autopep8 -i
.PHONY: cmake-debug build-debug test-debug clean-debug cmake-release build-release test-release clean-release install install-debug
install: build-release
@cd build_release && \
cmake --install . -v --component static_server
install-debug: build-debug
@cd build_debug && \
cmake --install . -v --component static_server
# Hide target, use only in docker environment
--debug-start-in-docker: install-debug
@/home/user/.local/bin/static_server \
--config /home/user/.local/etc/static_server/static_config.yaml
# Hide target, use only in docker environment
--debug-start-in-docker-debug: install-debug
@/home/user/.local/bin/static_server \
--config /home/user/.local/etc/static_server/static_config.yaml
.PHONY: docker-cmake-debug docker-build-debug docker-test-debug docker-clean-debug docker-cmake-release docker-build-release docker-test-release docker-clean-release docker-install docker-install-debug docker-start-service-debug docker-start-service docker-clean-data
# Build and runs service in docker environment
docker-start-service:
@docker-compose run -p 8080:8080 --rm static_server make -- --debug-start-in-docker
# Build and runs service in docker environment
docker-start-service-debug:
@docker-compose run -p 8080:8080 --rm static_server make -- --debug-start-in-docker-debug
# Start targets makefile in docker environment
docker-impl-%:
docker-compose run --rm static_server make $*
# Explicitly specifying the targets to help shell with completions
cmake-debug: build_debug/Makefile
cmake-release: build_release/Makefile
build-debug: build-impl-debug
build-release: build-impl-release
test-debug: test-impl-debug
test-release: test-impl-release
service-start-debug: service-impl-start-debug
service-start-release: service-impl-start-release
clean-debug: clean-impl-debug
clean-release: clean-impl-release
docker-cmake-debug: docker-impl-cmake-debug
docker-cmake-release: docker-impl-cmake-release
docker-build-debug: docker-impl-build-debug
docker-build-release: docker-impl-build-release
docker-test-debug: docker-impl-test-debug
docker-test-release: docker-impl-test-release
docker-clean-debug: docker-impl-clean-debug
docker-clean-release: docker-impl-clean-release
docker-install: docker-impl-install
docker-install-debug: docker-impl-install-debug