summaryrefslogtreecommitdiffstats
path: root/aoc.mk
blob: 98418e830723ee0ea40cf79d48a7d9710bb17b17 (plain) (blame)
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
CXX			= g++-15
CXX_FLAGS	= -std=c++26
SOLUTION	= solution.cpp
INPUT		= input.txt
TARGET		= ./solution
TESTS		= $(wildcard tests/*.input)
TIMEOUT		= 5

.PHONY: run tests force

all: compile run

compile: ${TARGET}

${TARGET}: ${SOLUTION}
	${CXX} ${CXX_FLAGS} $? -o $@

force:

tests: ${TESTS}

tests/test%.input: tests/test%.output compile force
	@diff -BZ --color=always <(timeout ${TIMEOUT} ${TARGET} < $@) <(cat $<) > /tmp/aoc.output \
			&& echo -e "$@ [\e[0;32mok\e[m]" \
			|| echo -e "$@ [\e[0;31mfail\e[m]"
	@cat /tmp/aoc.output

run: compile
	time timeout ${TIMEOUT} ${TARGET} < ${INPUT}

clean:
	rm -f ${TARGET}