1
1
CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
2
2
CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE='addr ub'
3
3
CMAKE_RELEASE_FLAGS ?=
4
- CMAKE_OS_FLAGS ?= -DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0 -DUSERVER_FEATURE_REDIS_HI_MALLOC=1
5
4
NPROCS ?= $(shell nproc)
6
5
CLANG_FORMAT ?= clang-format
7
6
DOCKER_COMPOSE ?= docker-compose
8
7
9
- # NOTE: use Makefile.local for customization
8
+ # NOTE: use Makefile.local to override the options defined above.
10
9
-include Makefile.local
11
10
11
+ CMAKE_DEBUG_FLAGS += -DCMAKE_BUILD_TYPE=Debug $(CMAKE_COMMON_FLAGS )
12
+ CMAKE_RELEASE_FLAGS += -DCMAKE_BUILD_TYPE=Release $(CMAKE_COMMON_FLAGS )
13
+
12
14
.PHONY : all
13
15
all : test-debug test-release
14
16
15
- # Debug cmake configuration
16
- build_debug/Makefile :
17
- @git submodule update --init
18
- @mkdir -p build_debug
19
- @cd build_debug && \
20
- cmake -DCMAKE_BUILD_TYPE=Debug $(CMAKE_COMMON_FLAGS) $(CMAKE_DEBUG_FLAGS) $(CMAKE_OS_FLAGS) $(CMAKE_OPTIONS) ..
17
+ # Run cmake
18
+ .PHONY : cmake-debug
19
+ cmake-debug :
20
+ git submodule update --init
21
+ cmake -B build_debug $(CMAKE_DEBUG_FLAGS )
21
22
22
- # Release cmake configuration
23
- build_release/Makefile :
24
- @git submodule update --init
25
- @mkdir -p build_release
26
- @cd build_release && \
27
- cmake -DCMAKE_BUILD_TYPE=Release $(CMAKE_COMMON_FLAGS) $(CMAKE_RELEASE_FLAGS) $(CMAKE_OS_FLAGS) $(CMAKE_OPTIONS) ..
23
+ .PHONY : cmake-release
24
+ cmake-release :
25
+ git submodule update --init
26
+ cmake -B build_release $(CMAKE_RELEASE_FLAGS )
28
27
29
- # Run cmake
30
- .PHONY : cmake-debug cmake-release
31
- cmake-debug cmake-release : cmake-% : build_% /Makefile
28
+ build_debug/CMakeCache.txt : cmake-debug
29
+ build_release/CMakeCache.txt : cmake-release
32
30
33
31
# Build using cmake
34
32
.PHONY : build-debug build-release
35
- build-debug build-release : build-% : cmake- %
36
- @ cmake --build build_$* -j $(NPROCS ) --target pg_grpc_service_template
33
+ build-debug build-release : build-% : build_ % /CMakeCache.txt
34
+ cmake --build build_$* -j $(NPROCS ) --target pg_grpc_service_template
37
35
38
36
# Test
39
37
.PHONY : test-debug test-release
40
38
test-debug test-release : test-% : build-%
41
- @ cmake --build build_$* -j $(NPROCS ) --target pg_grpc_service_template_unittest
42
- @ cmake --build build_$* -j $(NPROCS ) --target pg_grpc_service_template_benchmark
43
- @ cd build_$* && (( test - t 1 && GTEST_COLOR= 1 PYTEST_ADDOPTS= "-- color= yes" ctest - V) || ctest - V)
44
- @ pep8 tests
39
+ cmake --build build_$* -j $(NPROCS ) --target pg_grpc_service_template_unittest
40
+ cmake --build build_$* -j $(NPROCS ) --target pg_grpc_service_template_benchmark
41
+ cd build_$* && (( test - t 1 && GTEST_COLOR= 1 PYTEST_ADDOPTS= "-- color= yes" ctest - V) || ctest - V)
42
+ pep8 tests
45
43
46
44
# Start the service (via testsuite service runner)
47
45
.PHONY : service-start-debug service-start-release
48
46
service-start-debug service-start-release : service-start-% : build-%
49
- @cd ./ build_$* && $( MAKE ) start-pg_grpc_service_template
47
+ cmake --build build_$* -v --target start-pg_grpc_service_template
50
48
51
49
# Cleanup data
52
50
.PHONY : clean-debug clean-release
53
51
clean-debug clean-release : clean-% :
54
- cd build_$* && $( MAKE ) clean
52
+ cmake --build build_$* --target clean
55
53
56
54
.PHONY : dist-clean
57
55
dist-clean :
58
- @ rm -rf build_*
59
- @ rm -rf tests/__pycache__/
60
- @ rm -rf tests/.pytest_cache/
56
+ rm -rf build_*
57
+ rm -rf tests/__pycache__/
58
+ rm -rf tests/.pytest_cache/
61
59
62
60
# Install
63
61
.PHONY : install-debug install-release
64
62
install-debug install-release : install-% : build-%
65
- @cd build_$* && \
66
- cmake --install . -v --component pg_grpc_service_template
63
+ cmake --install build_$* -v --component pg_grpc_service_template
67
64
68
65
.PHONY : install
69
66
install : install-release
70
67
71
68
# Format the sources
72
69
.PHONY : format
73
70
format :
74
- @ find src -name ' *pp' -type f | xargs $(CLANG_FORMAT ) -i
75
- @ find tests -name ' *.py' -type f | xargs autopep8 -i
71
+ find src -name ' *pp' -type f | xargs $(CLANG_FORMAT ) -i
72
+ find tests -name ' *.py' -type f | xargs autopep8 -i
76
73
77
74
# Internal hidden targets that are used only in docker environment
78
75
--in-docker-start-debug --in-docker-start-release : --in-docker-start-% : install-%
79
- @ psql ' postgresql://user:password@service-postgres:5432/pg_grpc_service_template_db-1' -f ./postgresql/data/initial_data.sql
80
- @ /home/user/.local/bin/pg_grpc_service_template \
76
+ psql ' postgresql://user:password@service-postgres:5432/pg_grpc_service_template_db-1' -f ./postgresql/data/initial_data.sql
77
+ /home/user/.local/bin/pg_grpc_service_template \
81
78
--config /home/user/.local/etc/pg_grpc_service_template/static_config.yaml \
82
79
--config_vars /home/user/.local/etc/pg_grpc_service_template/config_vars.docker.yaml
83
80
84
81
# Build and run service in docker environment
85
82
.PHONY : docker-start-service-debug docker-start-service-release
86
83
docker-start-service-debug docker-start-service-release : docker-start-service-% :
87
- @ $(DOCKER_COMPOSE ) run -p 8080:8080 --rm pg_grpc_service_template-container make -- --in-docker-start-$*
84
+ $(DOCKER_COMPOSE ) run -p 8080:8080 --rm pg_grpc_service_template-container make -- --in-docker-start-$*
88
85
89
86
# Start targets makefile in docker environment
90
87
.PHONY : docker-cmake-debug docker-build-debug docker-test-debug docker-clean-debug docker-install-debug docker-cmake-release docker-build-release docker-test-release docker-clean-release docker-install-release
@@ -94,5 +91,5 @@ docker-cmake-debug docker-build-debug docker-test-debug docker-clean-debug docke
94
91
# Stop docker container and remove PG data
95
92
.PHONY : docker-clean-data
96
93
docker-clean-data :
97
- @ $(DOCKER_COMPOSE ) down -v
98
- @ rm -rf ./.pgdata
94
+ $(DOCKER_COMPOSE ) down -v
95
+ rm -rf ./.pgdata
0 commit comments