|
1 | | -.PHONY: build socrates backward all clean |
| 1 | +# Makefile for eyelite |
2 | 2 |
|
3 | | -build: |
4 | | - cargo build --release |
5 | | - |
6 | | -backward: build |
7 | | - target/release/eyelite examples/backward_demo.n3 > examples/output/backward_demo.n3 |
8 | | - |
9 | | -french: build |
10 | | - target/release/eyelite examples/french_cities.n3 > examples/output/french_cities.n3 |
11 | | - |
12 | | -lldm: build |
13 | | - target/release/eyelite examples/lldm.n3 > examples/output/lldm.n3 |
| 3 | +SHELL := /bin/bash |
| 4 | +BIN := target/release/eyelite |
| 5 | +EXAMPLE_DIR := examples |
| 6 | +EXAMPLES := $(wildcard $(EXAMPLE_DIR)/*.n3) |
14 | 7 |
|
15 | | -peano: build |
16 | | - target/release/eyelite examples/peano.n3 > examples/output/peano.n3 |
| 8 | +.PHONY: all release clean fmt clippy run-examples run-one list-examples |
17 | 9 |
|
18 | | -socrates: build |
19 | | - target/release/eyelite examples/socrates.n3 > examples/output/socrates.n3 |
| 10 | +all: release run-examples |
20 | 11 |
|
21 | | -all: backward french lldm peano socrates |
| 12 | +release: |
| 13 | + cargo build --release |
22 | 14 |
|
23 | 15 | clean: |
24 | 16 | cargo clean |
| 17 | + |
| 18 | +fmt: |
| 19 | + cargo fmt |
| 20 | + |
| 21 | +clippy: |
| 22 | + cargo clippy -- -D warnings |
| 23 | + |
| 24 | +list-examples: |
| 25 | + @echo "Examples:" |
| 26 | + @for f in $(EXAMPLES); do echo " $$f"; done |
| 27 | + |
| 28 | +# Run all examples, show output and save to examples-output.n3 |
| 29 | +run-examples: release |
| 30 | + @{ \ |
| 31 | + set -euo pipefail; \ |
| 32 | + for f in $(EXAMPLES); do \ |
| 33 | + echo "# =================================================="; \ |
| 34 | + echo "# Running $$f"; \ |
| 35 | + echo "# --------------------------------------------------"; \ |
| 36 | + $(BIN) "$$f"; \ |
| 37 | + echo; \ |
| 38 | + done; \ |
| 39 | + echo "# All examples finished OK."; \ |
| 40 | + } 2>&1 | tee examples-output.n3 |
| 41 | + |
| 42 | +# Run one example: make run-one FILE=examples/foo.n3 |
| 43 | +run-one: release |
| 44 | + @if [ -z "$(FILE)" ]; then \ |
| 45 | + echo "Usage: make run-one FILE=examples/foo.n3"; \ |
| 46 | + exit 1; \ |
| 47 | + fi |
| 48 | + @echo "Running $(FILE)" |
| 49 | + @$(BIN) "$(FILE)" |
| 50 | + |
0 commit comments