-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
177 lines (153 loc) · 3.3 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
.PHONY: \
__run-build \
__run-lint-build \
check-tags \
clean \
languages \
lint \
lint-fix \
new-problem \
run \
wrong
SHELL = /bin/bash -euo pipefail
C = c
CLJ = clj
CPP = cpp
CS = cs
DART = dart
GO = go
HS = hs
JAVA = java
JS = js
KT = kt
LUA = lua
ML = ml
PAS = pas
PHP = php
PY = py
R = r
RB = rb
RS = rs
SCALA = scala
SH = sh
SQL = sql
TS = ts
SUPPORTED_LANGUAGES = \
$(C) \
$(CLJ) \
$(CPP) \
$(CS) \
$(DART) \
$(GO) \
$(HS) \
$(JAVA) \
$(JS) \
$(LUA) \
$(ML) \
$(PHP) \
$(PY) \
$(R) \
$(RB) \
$(RS) \
$(SCALA) \
$(SQL) \
$(TS)
# $(PAS)
ifdef LANGUAGES
SUPPORTED_LANGUAGES := $(LANGUAGES)
endif
SUPPORTED_LINTS = \
$(C) \
$(CLJ) \
$(CPP) \
$(DART) \
$(GO) \
$(JS) \
$(PY) \
$(SH)
# $(SQL)
ifdef LINTS
SUPPORTED_LINTS := $(LINTS)
endif
FOLDER_EXISTS = 0
ifneq ("$(wildcard $(FOLDER))","")
FOLDER_EXISTS = 1
endif
ifdef FOLDER
ifeq ("$(FOLDER_EXISTS)","1")
FOLDERS := $(shell find $(FOLDER) -name 'problem.md' | sed 's/problem.md//g' | sort)
endif
else
FOLDERS := $(shell find . -name 'problem.md' | sed 's/problem.md//g' | sort)
endif
DOCKER_RUN := docker run --rm -v $$(pwd):/code -u "$$(id -u):$$(id -g)"
DOCKER_BUILD := docker build -q -f
__run-build:
ifdef LANGUAGE
$(error On run task, you should use LANGUAGES not LANGUAGE)
endif
@for language in $(SUPPORTED_LANGUAGES); do \
$(DOCKER_BUILD) .docker/$$language.Dockerfile -t $$language .; \
done
__run-lint-build:
@for language_lint in $(SUPPORTED_LINTS); do \
$(DOCKER_BUILD) .docker/lint/$${language_lint}-lint.Dockerfile --platform linux/arm64 -t $${language_lint}-lint .; \
done
check-tags:
@scripts/check-tags.sh
clean:
@find . -name '*.class' -delete
@find . -name '*.cml' -delete
@find . -name '*.cmo' -delete
@find . -name '*.exe' -delete
@find . -name '*.hi' -delete
@find . -name '*.o' -delete
@find . -name '*.out' -delete
@find . -name '*.res' -delete
@find . -name '*.s' -delete
@find . -name 'compiledFromTSFile.js' -delete
@find . -name 'Main.java' -delete
@find . -name 'result-*.txt' -delete
@find . -type d -name "META-INF" -exec rm -rf {} +
@find solutions -type d -name "\?" -exec rm -rf {} +
@rm -rf \? || true
languages:
@./scripts/languages.sh
lint: __run-lint-build
ifdef LANGUAGES
$(error On lint task, you should use LINTS not LANGUAGES)
endif
@for language_lint in $(SUPPORTED_LINTS); do \
$(DOCKER_RUN) $${language_lint}-lint; \
done
lint-fix: __run-lint-build
ifdef LANGUAGES
$(error On lint-fix task, you should use LINTS not LANGUAGES)
endif
@for language_lint in $(SUPPORTED_LINTS); do \
$(DOCKER_RUN) -e LINT_FIX=1 $${language_lint}-lint;\
done
new-problem:
ifdef LANGUAGES
$(error On new-problem task, you should use LANGUAGE not LANGUAGES)
endif
ifndef FOLDER
$(error You must specify a FOLDER variable to create a new problem)
endif
ifndef LANGUAGE
$(error You must specify a LANGUAGE variable to create a new problem)
endif
@mkdir -p $(FOLDER)
@touch $(FOLDER)/{out.txt,problem.md,tags.txt,$(shell basename $(FOLDER)).$(LANGUAGE)}
ifeq ($(strip $(LANGUAGE)),sql)
@touch $(FOLDER)/{schema.sql,drop-table.sql}
else
@touch $(FOLDER)/in.txt
endif
run: clean __run-build
ifdef LANGUAGE
$(error On run task, you should use LANGUAGES not LANGUAGE)
endif
@scripts/run-problems.sh "$(FOLDERS)" "$(SUPPORTED_LANGUAGES)" "$(DOCKER_RUN)"
wrong:
@find . -name 'WRONG' | sort