forked from llnl/dftracer-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (97 loc) · 3.64 KB
/
Makefile
File metadata and controls
113 lines (97 loc) · 3.64 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
.PHONY: coverage coverage-clean coverage-view coverage-open test test-coverage test-py build clean format check-format cmake-format lint typecheck help
RUN_TY ?= 0
# Detect build system
BUILD_GENERATOR := $(shell command -v ninja >/dev/null 2>&1 && echo "Ninja" || echo "Unix Makefiles")
BUILD_TOOL := $(shell command -v ninja >/dev/null 2>&1 && echo "ninja" || echo "make")
NUM_JOBS := $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
# Default target
help:
@echo "Available targets:"
@echo " coverage - Build with coverage and generate HTML report"
@echo " coverage-open - Build coverage and open report in browser"
@echo " coverage-clean - Clean coverage build directory"
@echo " coverage-view - Open existing coverage report in browser"
@echo " test - Build and run tests without coverage"
@echo " test-coverage - Run tests with coverage (requires prior coverage build)"
@echo " test-py - Run Python tests in isolated venv"
@echo " format - Format code using clang-format"
@echo " check-format - Check code formatting"
@echo " cmake-format - Format CMake files"
@echo " lint - Run ruff linter on Python code"
@echo " typecheck - Run ty type checker on Python code"
@echo " clean - Clean all build directories"
@echo " help - Show this help"
@echo ""
@echo "Build system: $(BUILD_GENERATOR) ($(BUILD_TOOL))"
# Generate coverage report
coverage:
@./scripts/coverage.sh
# Generate coverage report and open in browser
coverage-open:
@./scripts/coverage.sh --open
# Clean coverage build
coverage-clean:
@echo "Cleaning coverage build directory..."
@rm -rf build_coverage coverage
# View existing coverage report
coverage-view:
@./scripts/coverage.sh --no-clean --open || \
(echo "Coverage report not found. Run 'make coverage' first." && exit 1)
# Build and run tests without coverage
test:
@echo "Building and running tests..."
@cmake --preset tests
@cmake --build --preset tests
@ctest --preset tests
# Run tests with coverage (requires coverage build)
test-coverage:
@if [ -d "build_coverage" ]; then \
ctest --test-dir build_coverage --output-on-failure; \
else \
echo "Coverage build not found. Run 'make coverage' first."; \
exit 1; \
fi
# Run Python tests in isolated environment
test-py:
@echo "Running Python tests in isolated environment..."
@rm -rf .venv_test_py
@python3 -m venv .venv_test_py
@.venv_test_py/bin/pip install --upgrade pip setuptools wheel
@if [ "$(RUN_TY)" = "1" ]; then \
.venv_test_py/bin/pip install -e .[dev] ty; \
else \
.venv_test_py/bin/pip install -e .[dev]; \
fi
@.venv_test_py/bin/pytest tests/python -v
@if [ "$(RUN_TY)" = "1" ]; then \
.venv_test_py/bin/ty check --python "$$(pwd)/.venv_test_py/bin/python" python/; \
fi
@rm -rf .venv_test_py
@echo "Python tests completed successfully!"
# Python linting
lint:
@echo "Running ruff..."
@uvx ruff check python/ tests/python/
@uvx ruff format --check python/ tests/python/
@echo "Ruff passed!"
# Python type checking
typecheck:
@echo "Running ty..."
@uvx ty check python/
@echo "Type check passed!"
# Code formatting
format:
@echo "Formatting code..."
@./scripts/formatting/autoformat.sh
check-format:
@echo "Checking code format..."
@./scripts/formatting/check-formatting.sh
cmake-format:
@echo "Formatting CMake files..."
@cmake-format CMakeLists.txt src/CMakeLists.txt cmake/**/*.cmake --in-place
# Clean all build artifacts
clean:
@echo "Cleaning all build directories..."
@rm -rf build_* coverage .venv_test_py
@find . -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" | xargs rm -f 2>/dev/null || true
@echo "Clean complete!"