diff options
| -rw-r--r-- | aoc.mk | 35 |
1 files changed, 35 insertions, 0 deletions
| @@ -0,0 +1,35 @@ | |||
| 1 | CXX = g++-15 | ||
| 2 | CXXFLAGS = -std=c++26 -O2 | ||
| 3 | SOLUTION = solution.cpp | ||
| 4 | INPUT = input.txt | ||
| 5 | TARGET = ./solution | ||
| 6 | TESTS = $(wildcard tests/*.input) | ||
| 7 | TIMEOUT = 5 | ||
| 8 | |||
| 9 | .PHONY: run tests force | ||
| 10 | |||
| 11 | all: compile run | ||
| 12 | |||
| 13 | compile: ${TARGET} | ||
| 14 | |||
| 15 | ${TARGET}: ${SOLUTION} | ||
| 16 | ${CXX} ${CXXFLAGS} $? -o $@ | ||
| 17 | |||
| 18 | force: | ||
| 19 | |||
| 20 | tests: ${TESTS} | ||
| 21 | |||
| 22 | tests/test%.input: tests/test%.output compile force | ||
| 23 | @diff -BZ --color=always \ | ||
| 24 | <(timeout ${TIMEOUT} ${TARGET} < $@) \ | ||
| 25 | <(cat $<) \ | ||
| 26 | > /tmp/aoc.output \ | ||
| 27 | && echo -e "$@ [\e[0;32mok\e[m]" \ | ||
| 28 | || echo -e "$@ [\e[0;31mfail\e[m]" | ||
| 29 | @cat /tmp/aoc.output | ||
| 30 | |||
| 31 | run: compile | ||
| 32 | time timeout ${TIMEOUT} ${TARGET} < ${INPUT} | ||
| 33 | |||
| 34 | clean: | ||
| 35 | rm -f ${TARGET} | ||
