summaryrefslogtreecommitdiffstats
path: root/aoc.mk
blob: c7f8bc018e6e2d57a206227c1c9ecf3163dd829c (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
33
34
35
CXX			= g++-15
CXXFLAGS	= -std=c++26 -O2
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} ${CXXFLAGS} $? -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}