From 5210648cb2884e0211bebbfdc780df590d425a0c Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Thu, 2 Dec 2021 10:18:53 -0500 Subject: [PATCH] make: Add recipe to run individual/all days This makes it _much_ easier to verify that changes are the same between the python and C solutions. --- Makefile | 23 +++++++++++++++++++++-- README.md | 12 +++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4302d5f..7bfe109 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,15 @@ +# Makefile +# +# Targets: +# +# build: builds all C executables +# +# run: runs all found solutions for $DAY +# (default all, example: make DAY=1 run) +# +# clean: removes all C executables CFLAGS = -g -O2 -Wall -Wpedantic -Wextra +DAY = * TARGETS = \ 1/c/a \ @@ -6,8 +17,16 @@ TARGETS = \ 2/c/a \ 2/c/b \ -.PHONY: all -all: $(TARGETS) +.PHONY: build +build: $(TARGETS) + +.PHONY: run +run: build + @for d in $(DAY)/; do \ + for sol in $${d}py/a.py $${d}c/a $${d}py/b.py $${d}c/b; do \ + [ -e $$sol ] && printf "%-10s %s\n" "$$sol:" `$$sol < $$d/input`; \ + done; \ + done .PHONY: clean clean: diff --git a/README.md b/README.md index 64b575b..c4665b1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ Advent of Code 2021 -------------------- +=================== This year I'm attempting at least some of the earlier problems in C as well as Python (need the dynamic language to get that super speedy private leaderboard time!). @@ -10,3 +10,13 @@ If you want to discuss any of my solutions, shoot me an email at my public inbox: [~akarle/public-inbox@lists.sr.ht][mail] [mail]: mailto:~akarle/public-inbox@lists.sr.ht + +Running +------- +The GNU Makefile builds the C code and runs both C and Python +solutions via the `build` and `run` targets respectively. `run` +takes an optional parameter `DAY` that can limit the solutions +run: + + make run # runs all + make DAY=1 run # runs day 1 -- libgit2 1.8.1