-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
144 lines (117 loc) · 4.32 KB
/
Makefile
File metadata and controls
144 lines (117 loc) · 4.32 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
# Lesma Makefile
# Shortcuts for common development tasks
.PHONY: all debug release configure-debug configure-release build test clean \
format tidy fix lint help
# Default target
all: debug
# =============================================================================
# Build targets
# =============================================================================
## Configure and build debug
debug: configure-debug
cmake --build build/Debug
## Configure and build release
release: configure-release
cmake --build build/Release
## Configure debug (uses CMake presets)
configure-debug:
cmake --preset Debug
## Configure release (uses CMake presets)
configure-release:
cmake --preset Release
## Build without reconfiguring (debug)
build:
cmake --build build/Debug
## Build release without reconfiguring
build-release:
cmake --build build/Release
# =============================================================================
# Test targets
# =============================================================================
## Run tests (debug)
test: debug
ctest --test-dir build/Debug --output-on-failure
## Run tests (release)
test-release: release
ctest --test-dir build/Release --output-on-failure
# =============================================================================
# Code quality targets
# =============================================================================
## Format all source files with clang-format
format:
@echo "Formatting source files..."
@find src -name '*.cpp' -o -name '*.h' | xargs clang-format -i
@echo "Done."
# Detect OS for platform-specific settings
UNAME_S := $(shell uname -s)
# Clang-tidy extra args (fixes stdlib path mismatch between Apple Clang and Homebrew LLVM)
ifeq ($(UNAME_S),Darwin)
SDKROOT := $(shell xcrun --show-sdk-path)
TIDY_EXTRA_ARGS := -extra-arg=-isystem -extra-arg=$(SDKROOT)/usr/include/c++/v1 \
-extra-arg=-isystem -extra-arg=$(SDKROOT)/usr/include
else
TIDY_EXTRA_ARGS :=
endif
## Source directories to check
HEADER_FILTER := $(shell pwd)/(src|tests)/.*
SOURCE_FILTER := (src|tests)/.*\.cpp$$
## Run clang-tidy checks (no fixes)
lint:
@echo "Running clang-tidy..."
@run-clang-tidy -p build/Debug $(TIDY_EXTRA_ARGS) -header-filter='$(HEADER_FILTER)' '$(SOURCE_FILTER)' 2>&1 \
| grep -E "^$(shell pwd)/(src|tests)/.*: (warning|error):" | head -50
## Run clang-tidy checks with full output (includes analysis notes)
lint-verbose:
@echo "Running clang-tidy (verbose)..."
@run-clang-tidy -p build/Debug $(TIDY_EXTRA_ARGS) -header-filter='$(HEADER_FILTER)' '$(SOURCE_FILTER)' 2>&1 | tail -100
## Run clang-tidy and apply fixes
tidy:
@echo "Running clang-tidy with fixes..."
@run-clang-tidy -p build/Debug $(TIDY_EXTRA_ARGS) -header-filter='$(HEADER_FILTER)' -fix '$(SOURCE_FILTER)'
@echo "Done."
## Full fix: run tidy + format
fix: tidy format
@echo "All fixes applied."
# =============================================================================
# Clean targets
# =============================================================================
## Clean debug build
clean:
rm -rf build/Debug
## Clean release build
clean-release:
rm -rf build/Release
## Clean all builds
clean-all:
rm -rf build
# =============================================================================
# Help
# =============================================================================
## Show this help
help:
@echo "Lesma Makefile"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Build targets:"
@echo " debug Configure and build debug (default)"
@echo " release Configure and build release"
@echo " build Build debug without reconfiguring"
@echo " build-release Build release without reconfiguring"
@echo " configure-debug Configure debug only"
@echo " configure-release Configure release only"
@echo ""
@echo "Test targets:"
@echo " test Run tests (debug)"
@echo " test-release Run tests (release)"
@echo ""
@echo "Code quality:"
@echo " format Format code with clang-format"
@echo " lint Run clang-tidy (no fixes)"
@echo " tidy Run clang-tidy and apply naming fixes"
@echo " fix Run tidy + format"
@echo ""
@echo "Clean:"
@echo " clean Clean debug build"
@echo " clean-release Clean release build"
@echo " clean-all Clean all builds"