-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
31 lines (22 loc) · 1.03 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
SHELL=/bin/bash
YEAR ?= $(shell /bin/date +"%Y")
DAY ?= $(shell /bin/date +"%d")
AOC_SESSION_COOKIE ?= $(shell cat ~/.aoc-session-cookie)
AOC_INPUT_FILE = https://adventofcode.com/$(YEAR)/day/$(shell echo $(DAY) | sed 's/^0*//')/input
CURRENTDAYFOLDER = $(YEAR)/day$(DAY)
CURRENTDAYGOFILE = $(CURRENTDAYFOLDER)/day$(DAY).go
CURRENTDAYGOTESTFILE = $(CURRENTDAYFOLDER)/day$(DAY)_test.go
CURRENTDAYINPUT = $(CURRENTDAYFOLDER)/input.txt
all: $(CURRENTDAYFOLDER) $(CURRENTDAYGOFILE) $(CURRENTDAYGOTESTFILE) $(CURRENTDAYINPUT)
$(CURRENTDAYFOLDER):
@mkdir -p ./$(CURRENTDAYFOLDER)
$(CURRENTDAYGOFILE):
@cp -r template/day0.go ./$(CURRENTDAYGOFILE)
@sed -i 's/Day0/Day'$(DAY)'/g' ./$(CURRENTDAYGOFILE)
@sed -i 's/day0/day'$(DAY)'/g' ./$(CURRENTDAYGOFILE)
$(CURRENTDAYGOTESTFILE):
@cp -r template/day0_test.go ./$(CURRENTDAYGOTESTFILE)
@sed -i 's/Day0/Day'$(DAY)'/g' ./$(CURRENTDAYGOTESTFILE)
@sed -i 's/day0/day'$(DAY)'/g' ./$(CURRENTDAYGOTESTFILE)
$(CURRENTDAYINPUT):
@curl --cookie $(AOC_SESSION_COOKIE) $(AOC_INPUT_FILE) -o ./$(CURRENTDAYINPUT)