-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (71 loc) · 2.46 KB
/
Makefile
File metadata and controls
91 lines (71 loc) · 2.46 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
# Makefile - Wrapper around putup for orchestration tasks
#
# Usage:
# make # Configure and build
# make test # Run unit and E2E tests
# make install # Install to ~/bin (or PREFIX=/usr/local)
# make tidy # Run clang-tidy on all sources
# make format # Format all sources with clang-format
# make clean # Clean build outputs
# make distclean # Full reset: remove build directory
PREFIX ?= $(HOME)
PUTUP ?= $(PREFIX)/bin/putup
BUILD_DIR := build
# Detect mold linker
MOLD_PATH := $(shell command -v mold 2>/dev/null)
ifneq ($(MOLD_PATH),)
export USE_MOLD := 1
endif
# Verbose mode
ifeq ("$(V)", "1")
BUILD_OPTIONS = -v
endif
COMPDB := compile_commands.json
.PHONY: all build configure test install compdb tidy tidy-fix format format-check check clean distclean
all: build
# Configure: generate tup.config (putup skips if already up-to-date)
configure:
$(PUTUP) configure -B $(BUILD_DIR) $(BUILD_OPTIONS)
# Build: configure first, then build
build: configure
$(PUTUP) -B $(BUILD_DIR) $(BUILD_OPTIONS)
test: build
./$(BUILD_DIR)/test/unit/putup_test
install: build
@mkdir -p $(PREFIX)/bin
install -m 755 $(BUILD_DIR)/putup $(PREFIX)/bin/putup
ln -sf putup $(PREFIX)/bin/pup
@echo "Installed putup to $(PREFIX)/bin/putup (with pup symlink)"
compdb: configure
@echo "Generating compile_commands.json..."
@$(PUTUP) show compdb -B $(BUILD_DIR) > $(COMPDB)
RUN_CLANG_TIDY ?= run-clang-tidy
tidy: compdb
@echo "Running clang-tidy..."
@$(RUN_CLANG_TIDY) -p . $(TIDY_FLAGS) 'src/|test/'
tidy-fix: compdb
@echo "Running clang-tidy with fixes..."
@$(RUN_CLANG_TIDY) -p . -fix $(TIDY_FLAGS) 'src/|test/'
format:
@echo "Formatting sources..."
@find src include -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i
format-check:
@echo "Checking format..."
@find src include -name '*.cpp' -o -name '*.hpp' | xargs clang-format --dry-run --Werror
iwyu: compdb
@echo "Checking includes..."
@fail=0; \
for f in $$(find src include/pup -name '*.cpp' -o -name '*.hpp' | grep -v third_party | sort); do \
changes=$$(clang-include-cleaner-18 -p . --print=changes "$$f" 2>/dev/null | grep "^- "); \
if [ -n "$$changes" ]; then \
echo "$$f:"; echo "$$changes"; fail=1; \
fi; \
done; \
if [ "$$fail" -eq 1 ]; then echo "Dead includes found."; exit 1; fi; \
echo "No dead includes found."
check: format-check tidy test
@echo "All checks passed."
clean:
$(PUTUP) clean -B $(BUILD_DIR)
distclean:
$(PUTUP) distclean -B $(BUILD_DIR)