-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (55 loc) · 1.83 KB
/
Makefile
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
CURRENT_MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_MAKEFILE_DIR := $(patsubst %/,%,$(dir $(CURRENT_MAKEFILE_PATH)))
# If no target is specified, display help
.DEFAULT_GOAL := help
help: # Display this help.
@-+echo "Run make with one of the following targets:"
@-+echo
@-+grep -Eh "^[a-z-]+:.*#" $(CURRENT_MAKEFILE_PATH) | sed -E 's/^(.*:)(.*#+)(.*)/ \1 @@@ \3 /' | column -t -s "@@@"
run: # Run all days
cargo run --bin aoc2024
test: # Run all tests
cargo test
clean: # Clean
cargo clean
make install: # Install aoc-cli
cargo install aoc-cli
fetch-day: # ie: make fetch-day day=1
@if [ -z "$(day)" ]; then \
echo "Usage: make fetch-day day=N (where N is 1-30)"; \
exit 1; \
fi
@if ! [ "$(day)" -ge 1 ] || ! [ "$(day)" -le 30 ]; then \
echo "Error: day must be between 1 and 30"; \
exit 1; \
fi
@mkdir -p src/inputs
@padded_day=$$(printf "%02d" $(day)); \
aoc download -o -d $$padded_day -i src/inputs/$$padded_day.txt -p src/inputs/$$padded_day.md; \
[ -f "src/bin/$$padded_day.rs" ] || cp src/bin/_template.rs src/bin/$$padded_day.rs; \
echo "Fetched day $$padded_day puzzle and input"
run-day: # ie: make run-day day=1
@if [ -z "$(day)" ]; then \
echo "Usage: make run-day N (where N is 1-30)"; \
exit 1; \
fi
@if ! [ "$(day)" -ge 1 ] || ! [ "$(day)" -le 30 ]; then \
echo "Error: day must be between 1 and 30"; \
exit 1; \
fi
@padded_day=$$(printf "%02d" $(day)); \
cargo run --bin $$padded_day
test-day: # ie: make test-day day=1
@if [ -z "$(day)" ]; then \
echo "Usage: make test-day N (where N is 1-30)"; \
exit 1; \
fi
@if ! [ "$(day)" -ge 1 ] || ! [ "$(day)" -le 30 ]; then \
echo "Error: day must be between 1 and 30"; \
exit 1; \
fi
@padded_day=$$(printf "%02d" $(day)); \
cargo test --bin $$padded_day -- --nocapture
%:
@:
.PHONY: run clean fetch-day run-day test-day help test