forked from lucidsoftware/lucid-programming-competition-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (51 loc) · 2.66 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
67
68
69
70
71
MAKEFLAGS := -j 4
SHELL := /bin/bash
.DELETE_ON_ERROR:
PROBLEM_DESCRIPTIONS_MD := $(wildcard problems/*/description.md)
PROBLEM_DESCRIPTIONS_HTML := $(PROBLEM_DESCRIPTIONS_MD:%.md=%.html)
SAMPLE_DESCRIPTIONS_MD := $(wildcard samples/*/description.md)
SAMPLE_DESCRIPTIONS_HTML := $(SAMPLE_DESCRIPTIONS_MD:%.md=%.html)
all: problems.pdf instructions.pdf
include $(wildcard problems/*/Makefile) $(wildcard samples/*/Makefile)
test-%:
@for f in $(sort $(wildcard problems/$*/solutions/*.run samples/$*/solutions/*.run)); do \
for g in $(sort $(wildcard problems/$*/tests/*.in samples/$*/tests/*.in)); do \
if /usr/bin/time -o/tmp/lucid-programming-time -f%E colordiff -b "$${g/.in/.out}" <("$$f" < "$$g"); then \
echo "Solution $$(basename $$f .run), Test $$(basename $$g .in): SUCCESS ($$(< /tmp/lucid-programming-time))"; \
else \
echo "Solution $$(basename $$f .run), Test $$(basename $$g .in): FAILURE ($$(< /tmp/lucid-programming-time))"; \
fi \
done \
done
TESTS := $(shell echo problems/*/tests samples/*/tests)
.PHONY: zip-tests
zip-tests: $(TESTS:=.zip)
%/tests.zip: zip-tests.py
(echo $@: $*/tests/*.in $*/tests/*.out; echo $*/tests/*.in $*/tests/*.out :) > [email protected]
shopt -s nullglob; ./$< --input $*/tests/*.in --output $*/tests/*.out > $@
-include $(wildcard problems/*/tests.zip.dep samples/*/tests.zip.dep)
%.html: %.md convert.html.erb
ruby -rerb -rnet/http -e 'puts ERB.new(File.read "convert.html.erb").result' < $< > $@
PDF_OPTIONS := -g -B 15mm -L 20mm -R 20mm -T 20mm -s Letter --print-media-type
problems.pdf: $(PROBLEM_DESCRIPTIONS_HTML) $(shell find problems -name '*.png' -o -name '*.svg')
wkhtmltopdf $(PDF_OPTIONS) $(sort $(PROBLEM_DESCRIPTIONS_HTML)) $@
instructions.pdf: instructions.html rules.html $(SAMPLE_DESCRIPTIONS_HTML) $(shell find samples -name '*.png')
wkhtmltopdf $(PDF_OPTIONS) instructions.html rules.html $(sort $(SAMPLE_DESCRIPTIONS_HTML)) $@
scoreboard/.npm-install:
rm -rf $(@D)/node_modules
cd $(@D) && yarn install
> $@
scoreboard/.tsc-compile: scoreboard/.npm-install $(wildcard scoreboard/*.ts)
$(@D)/node_modules/.bin/tsc -p $(@D)
> $@
scoreboard.zip: $(shell find scoreboard) scoreboard/.npm-install scoreboard/.tsc-compile
rm -f $@
cd scoreboard && zip -qr ../scoreboard node_modules *.js
.PHONY: deploy
deploy: deploy-scoreboard deploy-queue
.PHONY: deploy-scoreboard
deploy-scoreboard: scoreboard.zip
aws-staging --region us-west-1 lambda update-function-code --function-name competition-2017-leaderboard --zip-file fileb://$< --publish
.PHONY: deploy-queue
deploy-queue: scoreboard.zip
aws-staging --region us-west-1 lambda update-function-code --function-name competition-2017-queue --zip-file fileb://$< --publish