-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
302 lines (249 loc) · 5.82 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
SHELL := bash
ROOT := $(shell \
cd '$(abspath $(dir $(lastword $(MAKEFILE_LIST))))' && pwd -P)
export ROOT
include $(ROOT)/common/vars.mk
include $(ROOT)/common/java.mk
BINDINGS := \
clojure \
go \
java \
julia \
nodejs \
perl \
perl-alien \
python \
raku \
ruby \
rust \
DIRS := \
core \
libyamlscript \
$(BINDINGS) \
ys \
BUILD_DIRS := \
libyamlscript \
go \
nodejs \
python \
ruby \
rust \
ys \
INSTALL_DIRS := \
libyamlscript \
ys \
BUILD := $(BUILD_DIRS:%=build-%)
BUILD_DOC := $(BINDINGS:%=build-doc-%)
INSTALL := $(INSTALL_DIRS:%=install-%)
TEST := $(DIRS:%=test-%)
TEST_BINDINGS := $(BINDINGS:%=test-%)
PUBLISH := $(DIRS:%=publish-%)
CLEAN := $(DIRS:%=clean-%)
REALCLEAN := $(DIRS:%=realclean-%)
DISTCLEAN := $(DIRS:%=distclean-%)
DOCKER_BUILD := $(DIRS:%=docker-build-%)
DOCKER_TEST := $(DIRS:%=docker-test-%)
DOCKER_SHELL := $(DIRS:%=docker-shell-%)
export HEAD := $(shell git rev-parse HEAD)
LYS_JAR_RELEASE := libyamlscript-$(YS_VERSION)-standalone.jar
YS_JAR_RELEASE := yamlscript.cli-$(YS_VERSION)-standalone.jar
LYS_JAR_PATH := libyamlscript/target/libyamlscript-$(YS_VERSION)-standalone.jar
YS_JAR_PATH := ys/target/uberjar/yamlscript.cli-$(YS_VERSION)-SNAPSHOT-standalone.jar
YS_RELEASE := $(RELEASE_YS_NAME).tar.xz
LYS_RELEASE := $(RELEASE_LYS_NAME).tar.xz
JAR_ASSETS := \
$(LYS_JAR_RELEASE) \
$(YS_JAR_RELEASE) \
ifndef JAR_ONLY
RELEASE_ASSETS := \
$(LYS_RELEASE) \
$(YS_RELEASE)
endif
RELEASE_ASSETS += \
$(JAR_ASSETS) \
RELEASE_LOG := release-$n.log
ifdef PREFIX
override PREFIX := $(abspath $(PREFIX))
endif
ifdef v
export YS_RELEASE_VERBOSE := 1
endif
ifdef d
export YS_RELEASE_DRYRUN := 1
endif
ifdef l
export YS_RELEASE_LAST_STEP := $l
endif
ifdef n
export YS_RELEASE_VERSION_NEW := $n
endif
ifdef o
export YS_OLD_TAG := $o
export YS_RELEASE_VERSION_OLD := $o
endif
default::
env:
@env | sort | less -FRX
chown:
sudo chown -R $(USER):$(USER) .
ys-files:
@( \
find . -name '*.ys' | cut -c3-; \
ag -asl --hidden '^#!/usr/bin/env ys-0$$' .; \
) | grep -Ev '(^note/)' | \
LC_ALL=C sort | uniq
nrepl nrepl-stop nrepl+:
$(MAKE) -C core $@
$(BUILD):
build: $(BUILD)
build-%: %
$(MAKE) -C $< build
$(BUILD_DOC):
build-doc: $(BUILD_DOC)
build-doc-%: %
$(MAKE) -C $< build-doc
$(INSTALL):
install: $(INSTALL)
install-%: % build-%
-$(MAKE) -C $< install PREFIX=$(PREFIX)
$(TEST):
test: $(TEST)
@echo
@echo 'ALL TESTS PASSED!'
test-core:
$(MAKE) -C core test v=$v
test-ys:
$(MAKE) -C ys test-all v=$v GRAALVM_O=b
test-%: %
$(MAKE) -C $< test v=$v GRAALVM_O=b
test-unit:
$(MAKE) -C core test v=$v
$(MAKE) -C ys test v=$v
test-bindings: $(TEST_BINDINGS)
serve publish:
$(MAKE) -C www $@
ifdef s
release: release-check release-yamlscript
else
release: release-check realclean release-pull release-yamlscript
endif
release-check:
ifneq (main,$(shell git rev-parse --abbrev-ref HEAD))
$(error Must be on branch 'main' to release)
endif
ifndef YS_GH_TOKEN
$(error YAMLScript release requires YS_GH_TOKEN to be set)
endif
ifndef YS_GH_USER
$(error YAMLScript release requires YS_GH_USER to be set)
endif
ifndef d
ifndef RELEASE_ID
ifndef YS_RELEASE_VERSION_OLD
$(error 'make release' needs the 'o' variable set to the old version)
endif
ifndef YS_RELEASE_VERSION_NEW
$(error 'make release' needs the 'n' variable set to the new version)
endif
ifeq (,$(shell which yarn))
$(error 'make release' needs 'yarn' installed)
endif
endif
endif
release-pull:
ifndef d
( \
set -ex; \
git pull --rebase; \
if [[ $$(git rev-parse HEAD) != $$HEAD ]]; then \
echo "Pulled new changes. Please re-run 'make release'."; \
exit 1; \
fi \
)
endif
release-yamlscript: $(BUILD_BIN_YS)
(time $< $(ROOT)/util/release-yamlscript $o $n $s) 2>&1 | \
tee -a $(RELEASE_LOG)
release-assets: $(RELEASE_ASSETS)
release-assets $^
release-build: release-build-ys release-build-libyamlscript
release-build-ys: $(YS_RELEASE)
release-build-libyamlscript: $(LYS_RELEASE)
jars: $(JAR_ASSETS)
$(YS_RELEASE): $(RELEASE_YS_NAME)
mkdir -p $<
cp -pPR ys/bin/ys* $</
cp common/install.mk $</Makefile
ifeq (true,$(IS_MACOS))
$(TIME) tar -J -cf $@ $<
else
$(TIME) tar -I'xz -0' -cf $@ $<
endif
$(LYS_RELEASE): $(RELEASE_LYS_NAME)
mkdir -p $<
cp -pPR libyamlscript/lib/libyamlscript.$(SO)* $</
cp common/install.mk $</Makefile
ifeq (true,$(IS_MACOS))
$(TIME) tar -J -cf $@ $<
else
$(TIME) tar -I'xz -0' -cf $@ $<
endif
$(RELEASE_YS_NAME): build-ys
$(RELEASE_LYS_NAME): build-libyamlscript
$(LYS_JAR_RELEASE): $(LYS_JAR_PATH)
cp $< $@
$(YS_JAR_RELEASE): $(YS_JAR_PATH)
cp $< $@
$(LYS_JAR_PATH):
$(MAKE) -C libyamlscript jar
$(YS_JAR_PATH):
$(MAKE) -C ys jar
delete-tag:
-git tag --delete $(YS_VERSION)
-git push --delete origin $(YS_VERSION)
bump: $(BUILD_BIN_YS)
$< $(ROOT)/util/version-bump
$(CLEAN):
clean: $(CLEAN)
$(RM) -r libyamlscript/lib ys/bin $(MAVEN_REPOSITORY)/yamlscript
$(RM) -r libyamlscript-0* ys-0* yamlscript.cli-*.jar
$(RM) -r sample/advent/hearsay-rust/target/
$(RM) -r homebrew-yamlscript
$(RM) NO-NAME release*.log
clean-%: %
$(MAKE) -C $< clean
ifdef d
realclean:
else
$(REALCLEAN):
realclean: clean $(REALCLEAN)
$(MAKE) -C www $@
$(RM) release-*
realclean-%: %
$(MAKE) -C $< realclean
endif
$(DISTCLEAN):
distclean: realclean $(DISTCLEAN)
$(MAKE) -C www $@
$(RM) -r bin/ lib/
distclean-%: %
$(MAKE) -C $< distclean
$(RM) -r .calva/ .clj-kondo/.cache .lsp/
# XXX Limit removing ~/.m2 to ingy until we can get ~/.m2 to not be used
sysclean: realclean
$(RM) -r $(YS_TMP)
$(RM) -r /tmp/yamlscript-* /tmp/ys-local
ifeq (ingy,$(USER))
$(RM) -r $(HOME)/.m2
endif
$(DOCKER_BUILD):
docker-build: $(DOCKER_BUILD)
docker-build-%: %
$(MAKE) -C $< docker-build
$(DOCKER_TEST):
docker-test: $(DOCKER_TEST)
docker-test-%: %
$(MAKE) -C $< docker-test v=$v
$(DOCKER_SHELL):
docker-shell-%: %
$(MAKE) -C $< docker-shell v=$v