-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
224 lines (206 loc) · 7.39 KB
/
Makefile
File metadata and controls
224 lines (206 loc) · 7.39 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
.PHONY: build install clean test test-quick test-verbose test-sequential test-raw test-one test-folder test-folder-verbose test-list theories plugin all extract format
# 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
@dune build bin/test_runner/main.exe
@./_build/default/bin/test_runner/main.exe
# Build and run only tests with changed files (parallel)
# Full extraction runs first, then git diff determines which tests need C++ compile/run
test-quick: extract
@./scripts/check-dune-rules.sh --fix
@dune build bin/test_runner/main.exe
@./_build/default/bin/test_runner/main.exe --changed
# 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 ;; \
*) found=""; \
for cat in basics monadic regression wip; do \
if [ -d "tests/$$cat/$(TEST)" ]; then \
found="$$cat"; \
break; \
fi; \
done; \
if [ -n "$$found" ]; then \
dune build @tests/$$found/$(TEST)/runtest; \
else \
echo "Test '$(TEST)' not found in any category"; \
exit 1; \
fi ;; \
esac
# Run all tests in a folder: make test-folder FOLDER=basics
# Examples:
# make test-folder FOLDER=basics
# make test-folder FOLDER=monadic
# make test-folder FOLDER=wip
# make test-folder FOLDER=regression
test-folder: extract
@if [ -z "$(FOLDER)" ]; then \
echo "Usage: make test-folder FOLDER=<folder_name>"; \
echo ""; \
echo "Examples:"; \
echo " make test-folder FOLDER=basics"; \
echo " make test-folder FOLDER=monadic"; \
echo " make test-folder FOLDER=wip"; \
echo " make test-folder FOLDER=regression"; \
exit 1; \
fi
@if [ ! -d "tests/$(FOLDER)" ]; then \
echo "Error: Folder 'tests/$(FOLDER)' does not exist"; \
exit 1; \
fi
@dune build bin/test_runner/main.exe
@./_build/default/bin/test_runner/main.exe --folder $(FOLDER)
# Run all tests in a folder with verbose error output
test-folder-verbose: extract
@if [ -z "$(FOLDER)" ]; then \
echo "Usage: make test-folder-verbose FOLDER=<folder_name>"; \
echo ""; \
echo "Examples:"; \
echo " make test-folder-verbose FOLDER=basics"; \
echo " make test-folder-verbose FOLDER=wip"; \
exit 1; \
fi
@if [ ! -d "tests/$(FOLDER)" ]; then \
echo "Error: Folder 'tests/$(FOLDER)' does not exist"; \
exit 1; \
fi
@dune build bin/test_runner/main.exe
@./_build/default/bin/test_runner/main.exe --folder $(FOLDER) --verbose
# 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
# Format source code
format:
@echo "Formatting C++ test files..."
@find tests -name '*.t.cpp' -exec clang-format -i {} +
@echo "Formatting OCaml files..."
@failed=""; \
for f in $$(find src bin -name '*.ml' -o -name '*.mli'); do \
if ! ocamlformat -i "$$f" 2>/dev/null; then \
failed="$$failed $$f"; \
fi; \
done; \
if [ -n "$$failed" ]; then \
echo "Warning: ocamlformat could not process:$$failed"; \
fi
@echo "Done."
# 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-quick - Extract all, compile/run only changed tests"
@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-folder FOLDER=x - Run all tests in a folder (e.g., FOLDER=wip)"
@echo " make test-folder-verbose FOLDER - Run folder tests with error details"
@echo " make test-list - List all available tests"
@echo " make all - Build everything including test executables"
@echo " make install - Install the plugin"
@echo " make format - Format C++ test files and OCaml source"
@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 " make test-folder FOLDER=basics # Run all basics tests"
@echo " make test-folder FOLDER=wip # Run all wip tests"
@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"