-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (58 loc) · 2.45 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
PROJECT_NAME ?= fiber
CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=1
# Available sanitizers: UBSAN, ASAN, TSAN
CMAKE_DEBUG_FLAGS ?= -DUBSAN=ON -DASAN=ON
CMAKE_RELEASE_FLAGS ?=
NPROCS ?= $(shell nproc)
CLANG_FORMAT ?= clang-format
CLANG_TIDY ?= clang-tidy
DOCKER ?= docker
DOCKER_COMPOSE ?= docker compose
# 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)
.PHONY: all
all: build-release test-release start-release
.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_debug/CMakeCache.txt: cmake-debug
build_release/CMakeCache.txt: cmake-release
target ?= $(PROJECT_NAME)
.PHONY: build-debug build-release
build-debug build-release: build-%: build_%/CMakeCache.txt
@cmake --build build_$* -j $(NPROCS) --target $(target)
.PHONY: test-debug test-release
test-debug test-release: test-%:
@cmake --build build_$* -j $(NPROCS) --target $(PROJECT_NAME)_tests
@build_$*/tests/$(PROJECT_NAME)_tests
.PHONY: start-debug start-release
start-debug start-release: start-%:
@executable_path=$$(find build_$* -name $(target) 2>/dev/null); \
if [ -x $$executable_path ]; then \
$$executable_path; \
else \
echo "Executable not found: $(target)"; \
fi
.PHONY: clean-debug clean-release
clean-debug clean-release: clean-%:
@rm -rf build_$*
.PHONY: format
format:
@find source/$(PROJECT_NAME) tests -name '*pp' -type f | xargs $(CLANG_FORMAT) -i
.PHONY: lint
lint:
@find source/$(PROJECT_NAME) tests -name '*pp' -type f | xargs $(CLANG_TIDY) -p build_$*
.PHONY: docker-start-debug docker-start-release
docker-start-debug docker-start-release: docker-start-%:
@$(DOCKER_COMPOSE) -f docker/docker-compose.yml run --rm $(PROJECT_NAME)-container make start-$* target=$(target)
.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-cmake-debug docker-build-debug docker-test-debug docker-clean-debug docker-cmake-release docker-build-release docker-test-release docker-clean-release: docker-%:
@$(DOCKER_COMPOSE) -f docker/docker-compose.yml run --rm $(PROJECT_NAME)-container make $* target=$(target)
.PHONY: clean-docker
clean-docker:
@$(DOCKER_COMPOSE) -f docker/docker-compose.yml down -v --rmi all