-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
150 lines (136 loc) · 4.79 KB
/
Makefile
File metadata and controls
150 lines (136 loc) · 4.79 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
145
146
147
148
149
150
.PHONY: build install clean test test-verbose test-sequential test-raw test-one test-list theories plugin all extract
# Default target: build plugin and theories only (not tests)
build: plugin theories
# Build everything including tests (extract first to avoid race conditions)
all: extract
dune build
# Extract: build plugin/theories and generate all test C++ files (without compiling them)
# Continues even if some extractions fail (pre-existing plugin bugs)
# Builds all .vo files in a single dune invocation for maximum parallelism
extract: build
@echo "Extracting all tests..."
@vo_targets=""; \
for vfile in tests/*/*/*.v; do \
if [ -f "$$vfile" ]; then \
vo_target=$$(echo "$$vfile" | sed 's/\.v$$/.vo/'); \
vo_targets="$$vo_targets $$vo_target"; \
fi; \
done; \
if [ -n "$$vo_targets" ]; then \
dune build $$vo_targets 2>/dev/null || true; \
fi
# Build just the plugin
plugin:
dune build src
# Build just the theories
theories:
dune build theories
# Install the plugin
install:
dune build @install
dune install
# Build and run tests with formatted summary (parallel)
# extract first to ensure generated .cpp/.h files exist before compiling tests
test: extract
@./scripts/check-dune-rules.sh --fix
@dune build bin/test_runner/main.exe
@./_build/default/bin/test_runner/main.exe
# Build and run tests with verbose error output (parallel)
test-verbose: extract
@dune build bin/test_runner/main.exe
@./_build/default/bin/test_runner/main.exe --verbose
# Run tests sequentially (old bash script)
test-sequential:
@./scripts/run-tests.sh
# Raw dune test output (no formatting)
test-raw:
dune runtest
# Run a single test: make test-one TEST=list
# Examples:
# make test-one TEST=list
# make test-one TEST=basics/nat
# make test-one TEST=monadic/io
test-one:
@if [ -z "$(TEST)" ]; then \
echo "Usage: make test-one TEST=<test_name>"; \
echo ""; \
echo "Examples:"; \
echo " make test-one TEST=list"; \
echo " make test-one TEST=tree"; \
echo " make test-one TEST=basics/nat"; \
echo " make test-one TEST=monadic/io"; \
echo ""; \
echo "Use 'make test-list' to see all available tests."; \
exit 1; \
fi
@# Handle category/test format (e.g., basics/list)
@case "$(TEST)" in \
*/*) dune build @tests/$(TEST)/runtest ;; \
*) if [ -d "tests/basics/$(TEST)" ]; then \
dune build @tests/basics/$(TEST)/runtest; \
elif [ -d "tests/monadic/$(TEST)" ]; then \
dune build @tests/monadic/$(TEST)/runtest; \
else \
echo "Test '$(TEST)' not found in tests/basics/ or tests/monadic/"; \
exit 1; \
fi ;; \
esac
# List all available tests
test-list:
@echo "Available tests:"
@echo ""
@echo "basics:"
@for d in tests/basics/*/; do \
if [ -f "$${d}"*.t.cpp ]; then \
echo " $$(basename $$d)"; \
fi; \
done | sort
@echo ""
@echo "monadic:"
@for d in tests/monadic/*/; do \
if [ -f "$${d}"*.t.cpp ]; then \
echo " $$(basename $$d)"; \
fi; \
done | sort
# Clean build artifacts and generated test files
clean:
@dune clean
@for category in basics monadic regression wip; do \
if [ -d "tests/$$category" ]; then \
for dir in tests/$$category/*/; do \
if [ -d "$$dir" ]; then \
name=$$(basename "$$dir"); \
rm -f "$$dir$$name.cpp" "$$dir$$name.h" "$$dir$$name.o" "$$dir$$name.t.exe"; \
fi; \
done; \
fi; \
done
@echo "Cleaned build artifacts and generated test files"
# Help message
help:
@echo "Crane build system"
@echo ""
@echo "Usage:"
@echo " make - Build plugin and theories (default)"
@echo " make extract - Build + generate all test C++ files"
@echo " make test - Compile and run all tests (parallel)"
@echo " make test-verbose - Run tests with error details (parallel)"
@echo " make test-sequential - Run tests sequentially (old bash script)"
@echo " make test-raw - Run tests with raw dune output"
@echo " make test-one TEST=name - Run a single test (e.g., TEST=list)"
@echo " make test-list - List all available tests"
@echo " make all - Build everything including test executables"
@echo " make install - Install the plugin"
@echo " make clean - Clean build artifacts and generated test files"
@echo ""
@echo "Examples:"
@echo " make test-list # Show all available tests"
@echo " make test-one TEST=list # Run the list test"
@echo " make test-one TEST=tree # Run the tree test"
@echo " make test-one TEST=basics/nat # Run nat from basics"
@echo " make test-one TEST=monadic/io # Run io from monadic"
@echo ""
@echo "Direct dune commands:"
@echo " dune build @install - Build plugin and theories only"
@echo " dune build - Build everything including tests"
@echo " dune runtest - Build and run tests"