chiark / gitweb /
dice: d6: image: wip extraction
[otter.git] / Makefile
1 # Copyright 2020-2021 Ian Jackson and contributors to Otter
2 # SPDX-License-Identifier: AGPL-3.0-or-later
3 # There is NO WARRANTY.
4
5 # make -j8
6 # make -j8 release
7 # make -j8 shapelib
8
9 SHELL=/bin/bash
10 src=.
11
12 default: all check
13 all: debug
14 full-check: all check cargo-syntaxcheck-release shapelib doc-sphinx
15 full-check: for-deploy release
16 everything: debug doc release check bundled-sources
17
18 shapelib: templates/shapelib.html docs/html/index.html
19         @echo 'Shape library preview and docs can now be found here:'
20         @for f in $^; do echo '  file://$(PWD)/'$$f; done
21
22 MAKEFILE_DEP ?= Makefile
23 MAKEFILE_FIND_X ?=
24 # ^ set this to "x" to debug the $rsrcs rune
25
26 #---------- funky macros etc. ----------
27
28 cr = $(addprefix --,$(filter-out debug,$1))
29 rsrcs = $(shell $(foreach x,$(MAKEFILE_FIND_X),set -$x;)\
30     find -H $1 \( -name Cargo.toml -o -name Cargo.lock -o -name Cargo.lock.example -o -name \*.rs \) \! -path '*/build/*' )
31 stamp=@mkdir -p stamp; touch $@
32
33 BUNDLED_SOURCES_LIT = README.md LICENCE
34 BUNDLED_SOURCES_FILES = index.html $(BUNDLED_SOURCES_LIT)
35 BUNDLED_SOURCES_LINKS += $(BUNDLED_SOURCES_LIT) otter/
36 BUNDLED_SOURCES += $(BUNDLED_SOURCES_FILES)
37
38 #---------- programs and config variables ----------
39
40 TARGET_DIR ?= target
41
42 USVG_OPTIONS = "--sans-serif-family=DejaVu Sans"
43
44 WASM_BINDGEN = $(TARGET_DIR)/debug/wasm-bindgen
45 WASM_BINDGEN_OPTIONS =                                          \
46         --remove-name-section --remove-producers-section        \
47         --typescript
48
49 BUNDLE_SOURCES ?= bundle-rust-sources
50
51 SPHINXBUILD   ?= sphinx-build
52
53 ifndef INKSCAPE_EXTENSIONS
54 INKSCAPE ?= inkscape
55 INKSCAPE_SDD_QUIETEN ?= 2>/dev/null
56 # inkscape 0.92.4: --extension-directory works, no --system-data-directory
57 # inkscape 1.0.2: --system-data-directory, no --extension-directory
58 INKSCAPE_EXTENSIONS := $(shell set -e; { sdd=$$( $(INKSCAPE) --system-data-directory $(INKSCAPE_SDD_QUIETEN) ) && echo "$$sdd/extensions"; } || $(INKSCAPE) --extension-directory )
59 endif
60 RECOLOUR_SVG ?= ./run-inkscape-extension $(INKSCAPE_EXTENSIONS)/color_replace.py
61
62 DEPLOY_ARCH=x86_64-unknown-linux-musl
63 DEPLOY_RELEASE=release
64 DEPLOY_TARGET_DIR=$(TARGET_DIR)/$(addsuffix /,$(DEPLOY_ARCH))$(DEPLOY_RELEASE)
65 DEPLOYED_BRANCH=deployed
66 PUBLISHED_BRANCH=published
67
68 RUST_CLIPPY_OPTIONS ?= $(shell perl -pe 's/\#.*//; s/\n/ /' clippy-options)
69 RUST_CLIPPY ?= clippy
70 RUST_CLIPPY_CMD := clippy $(RUST_CLIPPY_OPTIONS)
71
72 #---------- nailing-cargo ----------
73
74 ifneq (,$(wildcard ../Cargo.nail))
75
76 NAILING_CARGO ?= nailing-cargo
77 CARGO_CMD ?= $(NAILING_CARGO)
78 BUILD_SUBDIR ?= ../Build
79 TARGET_DIR = $(BUILD_SUBDIR)/$(notdir $(PWD))/target
80
81 NAILING_CARGO_JUST_RUN ?= $(NAILING_CARGO) --just-run -q ---
82 BUNDLE_SOURCES_CMD ?= $(NAILING_CARGO) --- $(BUNDLE_SOURCES)
83 USVG_CMD ?= $(NAILING_CARGO_JUST_RUN) $(USVG)
84 WASM_BINDGEN_CLI_CARGO_OPTS ?= --subcommand-props=!manifest-path
85
86 CARGO_DOCUMENT_PRIVATE_ITEMS ?= --document-private-items
87 CARGO_DOC_OPTS += $(CARGO_DOCUMENT_PRIVATE_ITEMS)
88
89 clean-nailing:
90         $(NAILING_CARGO_JUST_RUN) \
91  sh -c 'cd "$1"; find -mindepth 1 -maxdepth 1 -print0 | xargs -0r rm -rf --' \
92                 $(abspath $(BUILD_SUBDIR)/$(notdir $(PWD)))
93
94 else
95 CARGO_CMD ?= cargo
96 clean-nailing:
97 endif # Cargo.nail
98
99 BUILD_SUBDIR ?= ../Build
100 BUNDLE_SOURCES_CMD ?= $(BUNDLE_SOURCES)
101 USVG_CMD ?= $(USVG)
102
103 WASM_PACKED=$(TARGET_DIR)/packed-wasm
104
105 #---------- local programs ----------
106
107 define lp
108 stamp/cargo.$2: $(call rsrcs, ! -name \*.rs)
109         $$(CARGO) build $(call cr,$3) -p $2
110         $$(stamp)
111 $1 := $(abspath $(TARGET_DIR)/$3/$4)
112 endef
113
114 $(eval $(call lp,BUNDLE_SOURCES,bundle-sources,debug,bundle-rust-sources))
115 $(eval $(call lp,USVG,usvg,release,usvg))
116
117 #---------- variables defining bits of source etc. ----------
118
119 PROGRAMS=daemon-otter otter
120
121 WASM_ASSETS := $(addprefix otter_wasm,.js _bg.wasm)
122 WASM_OUTPUTS := $(addprefix otter_wasm,.d.ts)
123
124 TS_SRCS= script
125 TS_SRC_FILES= \
126         $(addprefix templates/,$(addsuffix .ts,$(TS_SRCS))) \
127         webassembly-types/webassembly.d.ts \
128         $(WASM_PACKED)/otter_wasm.d.ts
129
130 LITFILES= LICENCE AGPLv3
131 TXTFILES= CC-BY-SA-3.0 CC-BY-SA-4.0
132
133 FILEASSETS = $(addprefix templates/, libre shapelib.html script.js \
134                         $(LITFILES) $(TXTFILES)) \
135                 $(wildcard templates/*.tera) \
136                 nwtemplates/die-overlay.tera
137
138 WASM := wasm32-unknown-unknown
139 # ^ todo: Is this still right after
140 #     Use correct ABI for wasm32 by default
141 #     https://github.com/rust-lang/rust/pull/79998
142 # ?  But maybe it doesn't matter since we're very conservative and
143 # only pass JsValue and a few strings across the WASM ABI.
144
145 RUST_NIGHTLY_VERSION ?= +nightly
146 CARGO = $(CARGO_CMD) $(RUST_VERSION)
147
148 #---------- toplevel aggregate targets ----------
149
150 check: stamp/cargo.debug-check at wdt jstest
151         @echo 'Tests passed.'
152
153 full-check: stamp/cargo.release-check
154 full-check: stamp/cargo.release-miri stamp/cargo.debug-miri
155
156 full-check:
157         @echo 'Full tests passed.'
158
159 doc: cargo-doc doc-sphinx examples
160
161 debug release:: %: stamp/cargo.% assets libraries extra-%
162
163 cargo: cargo-debug cargo-wasm-release
164
165 cargo-debug cargo-release cargo-check cargo-doc \
166 cargo-wasm-debug cargo-wasm-release:: \
167 cargo-%: stamp/cargo.%
168
169 EXAMPLE_BUNDLES = test-bundle big-bundle
170 EXAMPLE_BUNDLE_FILES = $(foreach f, $(EXAMPLE_BUNDLES), examples/$f.zip)
171
172 examples: $(EXAMPLE_BUNDLE_FILES)
173 .PHONY: examples
174
175 cargo-wasm: cargo-wasm-release
176
177 wasm: stamp/wasm-bindgen
178
179 assets: js stamp/wasm-bindgen $(FILEASSETS)
180
181 js: templates/script.js
182
183 extra-debug:
184 extra-release: bundled-sources
185
186 cargo-syntaxcheck: cargo-syntaxcheck-host cargo-syntaxcheck-wasm
187 cargo-syntaxcheck-host:
188         $(CARGO) check --workspace
189 cargo-syntaxcheck-wasm:
190         $(CARGO) check --target $(WASM) -p otter-wasm --release
191 cargo-syntaxcheck-release:
192         $(CARGO) check --workspace --release
193
194 cargo-clippy: cargo-clippy-host cargo-clippy-wasm
195 cargo-clippy-host: clippy-options
196         $(CARGO) $(RUST_CLIPPY) --workspace $(RUST_CLIPPY_OPTIONS)
197 cargo-clippy-wasm: clippy-options
198         $(CARGO) $(RUST_CLIPPY) --target $(WASM) -p otter-wasm $(RUST_CLIPPY_OPTIONS)
199
200 #---------- cargo ----------
201
202 DR=debug release
203 CARGOES=$(foreach t, wasm-,$(addprefix $t,check $(DR)))
204
205 $(addprefix stamp/cargo.,$(DR)):: \
206 stamp/cargo.%: $(call rsrcs,. ! -path './wasm/*')
207         $(CARGO) build --workspace $(call cr,$*) -p otter -p otter-daemon -p otter-cli
208         $(NAILING_CARGO_JUST_RUN) \
209         ln -sf otter $(abspath $(TARGET_DIR))/$*/otter-ssh-proxy
210         $(stamp)
211
212 $(TARGET_DIR)/debug/%: $(call rsrcs, ! -path './wasm/*')
213         $(CARGO) build --workspace -p otter-cli
214         $(NAILING_CARGO_JUST_RUN) touch $(abspath $@)
215
216 stamp/cargo.wasm-bindgen: $(call rsrcs, ! -name \*.rs)
217         $(CARGO_CMD) $(WASM_BINDGEN_CLI_CARGO_OPTS) $(RUST_VERSION) \
218                 build --target-dir=target \
219                 --manifest-path=$(abspath wasm/Cargo.toml) -p wasm-bindgen-cli
220         $(stamp)
221
222 stamp/cargo.%-check: $(call rsrcs,.)
223         $(CARGO) test --workspace $(call cr,$*)
224         $(stamp)
225
226 stamp/cargo.%-miri: $(call rsrcs,.)
227         $(CARGO_CMD) $(RUST_NIGHTLY_VERSION) \
228                 miri test --workspace $(call cr,$*)
229         $(stamp)
230
231 stamp/cargo-at.debug: $(call rsrcs,.)
232         $(CARGO) build --workspace $(call cr,$*) -p otter-api-tests
233         $(stamp)
234
235 stamp/cargo-wdt.debug: $(call rsrcs,.)
236         $(CARGO) build --workspace $(call cr,$*) -p otter-webdriver-tests
237         $(stamp)
238
239 stamp/cargo-jstest.debug: $(call rsrcs,.)
240         $(CARGO) build --workspace $(call cr,$*) -p otter-nodejs-tests
241         $(stamp)
242
243 stamp/cargo.doc: $(call rsrcs,.)
244         set -o pipefail -e; \
245         $(CARGO) doc $(CARGO_DOC_OPTS) --workspace 2>&1 \
246                 |egrep -vf .cargo-doc-suppress-errors
247         $(stamp)
248
249 $(addprefix stamp/cargo.wasm-,$(DR)):: \
250 stamp/cargo.wasm-%: $(call rsrcs, base wasm Cargo.*)
251         $(CARGO) build --target $(WASM) -p otter-wasm $(call cr,$*)
252         $(stamp)
253
254 stamp/cargo.deploy-build: $(call rsrcs,.)
255         $(CARGO) build --target $(DEPLOY_ARCH) $(call cr,$(DEPLOY_RELEASE)) -p otter -p otter-cli -p otter-daemon
256         $(NAILING_CARGO_JUST_RUN) \
257         ln -sf otter $(abspath $(TARGET_DIR)/$(DEPLOY_ARCH))/$(DEPLOY_RELEASE)/otter-ssh-proxy
258         $(stamp)
259
260 #---------- sphnix ----------
261
262 doc-sphinx:     docs/html/index.html \
263         $(foreach f, $(EXAMPLE_BUNDLES), docs/html/examples/$f.zip) \
264         $(addprefix docs/html/examples/, $(notdir $(wildcard specs/*.toml)))
265         @echo 'Documentation can now be found here:'
266         @echo '  file://$(PWD)/$<'
267
268 docs/html/index.html: docs/conf.py $(wildcard docs/*.md docs/*.rst docs/*.png)
269         $(SPHINXBUILD) -M html docs docs $(SPHINXOPTS)
270
271 docs/html/examples/%.zip: examples/%.zip
272         mkdir -p docs/html/examples
273         rm -f $@ && ln $< $@
274
275 docs/html/examples/%.toml: specs/%.toml
276         mkdir -p docs/html/examples
277         rm -f $@ && ln $< $@
278
279 #---------- jstest ----------
280
281 JSTESTS= basic lower
282
283 .PHONY: jstest
284 jstest jstests: $(foreach t,$(JSTESTS),stamp/$t.jstest)
285
286 stamp/%.jstest: jstest/run1 jstest/%.nodejs templates/script.js \
287                 stamp/wasm-bindgen-jstest stamp/cargo-jstest.debug
288         $(NAILING_CARGO_JUST_RUN) $(abspath $(filter-out stamp/%,$^))
289         $(stamp)
290
291 #---------- wasm ----------
292
293 $(addprefix $(WASM_PACKED)/,$(WASM_ASSETS) $(WASM_OUTPUTS)): stamp/wasm-bindgen
294 stamp/wasm-bindgen: stamp/cargo.wasm-bindgen stamp/cargo.wasm-release
295         $(NAILING_CARGO_JUST_RUN) $(abspath $(WASM_BINDGEN)) \
296                 $(WASM_BINDGEN_OPTIONS) --no-modules \
297                 --out-dir target/packed-wasm \
298                 target/$(WASM)/release/otter_wasm.wasm
299         $(stamp)
300
301 stamp/wasm-bindgen-jstest: stamp/cargo.wasm-bindgen stamp/cargo.wasm-release
302         $(NAILING_CARGO_JUST_RUN) $(abspath $(WASM_BINDGEN)) \
303                 $(WASM_BINDGEN_OPTIONS) --nodejs \
304                 --out-dir target/jstest \
305                 target/$(WASM)/release/otter_wasm.wasm
306         $(stamp)
307
308 #---------- bundle-sources ----------
309
310 BUNDLED_SOURCES_DIRS += otter
311
312 bundled-sources:: $(addprefix bundled-sources/, $(BUNDLED_SOURCES_DIRS))
313
314 TARGET_BUNDLED=$(TARGET_DIR)/bundled-sources
315
316 $(TARGET_BUNDLED):
317         $(NAILING_CARGO_JUST_RUN) mkdir -p $(abspath $@)
318
319 $(addprefix bundled-sources/, $(BUNDLED_SOURCES_DIRS)): \
320 bundled-sources/%: stamp/cargo.bundle-sources $(TARGET_BUNDLED)
321         set -e; d=$(abspath $(TARGET_BUNDLED)); \
322         $(if $(filter-out otter,$*), cd ../$*;) \
323         $(BUNDLE_SOURCES_CMD) --output $$d/$*
324
325 bundled-sources:: $(addprefix $(TARGET_BUNDLED)/, $(BUNDLED_SOURCES_FILES))
326
327 $(addprefix $(TARGET_BUNDLED)/, $(BUNDLED_SOURCES_LIT)): \
328 $(TARGET_BUNDLED)/%: % $(TARGET_BUNDLED)
329         $(NAILING_CARGO_JUST_RUN) cp $(abspath $(src))/$< $(abspath $@)
330
331 $(TARGET_BUNDLED)/index.html: bundled-sources-make-index \
332                 $(MAKEFILE_DEP) $(TARGET_BUNDLED)
333         $(NAILING_CARGO_JUST_RUN) sh -ec '                      \
334                 cd $(abspath $(src)); mkdir -p $(dir $@);       \
335                 ./$< >$@.tmp $(BUNDLED_SOURCES_LINKS);          \
336                 mv -f $@.tmp $@;                                \
337         '
338
339 bundled-sources::
340         @echo Bundled sources.
341
342 #---------- svg processing ----------
343
344 LIBRARIES ?= $(basename $(wildcard library/*.toml))
345 USVG_DEP = stamp/cargo.usvg
346
347 include $(addsuffix /files.make, $(LIBRARIES))
348
349 USVG_PROCESSOR = usvg-processor
350 LIBRARY_PROCESS_SVG = ./$(USVG_PROCESSOR) $@ $(wordlist 1,2,$^) '$(USVG_CMD) $(USVG_OPTIONS)'
351 $(LIBRARY_FILES): $(USVG_PROCESSOR) $(USVG_DEP) $(MAKEFILE_DEP)
352
353 # actual command for each of $(LIBRARY_FILES) is in one of the files.make
354
355 library/%/files.make: media-scraper library/%.toml
356         ./$< --offline library/$*.toml
357
358 #---------- typescript ----------
359
360 templates/%.js: tsc-wrap tsconfig.json
361         ./tsc-wrap $@ tsconfig.json $(filter %.ts,$^)
362
363 templates/script.js: $(TS_SRC_FILES) stamp/wasm-bindgen
364
365 #---------- other templates ----------
366
367 $(addprefix templates/,$(LITFILES)): templates/%: %
368         cp $< $@.new && mv -f $@.new $@
369
370 $(addprefix templates/,$(TXTFILES)): templates/%: %.txt
371         cp $< $@.new && mv -f $@.new $@
372
373 libraries: $(LIBRARY_FILES)
374
375 templates/shapelib.html: $(TARGET_DIR)/debug/otterlib $(LIBRARY_FILES)
376         $(NAILING_CARGO_JUST_RUN) $(abspath $<) \
377         --libs '$(addprefix $(PWD)/, $(addsuffix .toml, $(LIBRARIES)))' \
378                 preview >$@.tmp && mv -f $@.tmp $@
379
380 nwtemplates/die-overlay.tera: dice/overlay-template-extractor dice/die.svg
381         ./$< <dice/die.svg >$@.tmp && mv -f $@.tmp $@
382
383 library/edited/dice-d6-blue.svg: dice/extract-image-only dice/die.svg
384         ./$< <dice/die.svg >$@.tmp && mv -f $@.tmp $@
385
386 #---------- examples ----------
387
388 EXAMPLE_BUNDLE_INPUT_DEPS := $(shell                                    \
389         cd examples/test-bundle/ && find \! \( -name '*~' -o -name '.*' \) \
390 )
391
392 examples/%.zip: $(MAKEFILE_DEP)
393         set -e; rm -f $@.tmp; cd examples/$*/; \
394         zip $(ZIPFLAGS) -DX ../$(notdir $@).tmp $(ZIP_INPUTS)
395         mv -f $@.tmp $@
396
397 examples/test-bundle.zip: ZIP_INPUTS=$(EXAMPLE_BUNDLE_INPUT_DEPS)
398 examples/test-bundle.zip: \
399  $(addprefix examples/test-bundle/, $(EXAMPLE_BUNDLE_INPUT_DEPS))
400
401 examples/big-bundle.zip: examples/big-bundle/otter.toml
402 examples/big-bundle.zip: ZIPFLAGS+= -0 -r -q
403 examples/big-bundle.zip: ZIP_INPUTS=.
404 examples/big-bundle/otter.toml: $(LIBRARY_FILES) $(MAKEFILE_DEP)
405         rm -rf examples/big-bundle
406         mkdir examples/big-bundle examples/big-bundle/library
407         @set -e; echo 'MKDIR for $@'; \
408         for l in $(LIBRARIES); do \
409                 mkdir examples/big-bundle/$$l; \
410                 perl -p \
411  -e 'BEGIN { print "# -- AUTOGENERATED FROM COPY IN OTTER SOURCE --\n" }' \
412  -e 'if (m/^\[scraper]/..0) { unless (m/^\[(?!scraper)/..0) { s/^/\#/ } }' \
413  -e 's/(?<=\s)\w\S*(?=\s)/-/ if m/^files = """/..m/^"""/;' \
414                         <$$l.toml >examples/big-bundle/$$l.toml; done
415         @set -e; echo 'LN for $@'; \
416         for e in $(LIBRARY_FILE_INPUTS); do \
417                 ln $${e#*:} examples/big-bundle/$${e%%.usvg:*}.svg; done;
418         @set -e; echo 'MV for $@'; \
419         cd examples/big-bundle/library/; for x in '' .toml; do \
420                 mv wikimedia$$x duped-example$$x; done
421         @set -e; mkdir examples/big-bundle/specs/; \
422         perl -pe <specs/demo.game.toml \
423                 >examples/big-bundle/specs/Modded-spec.game.toml \
424                 's/chess-b-/chess-purple-/; s/chess-w-/chess-yellow-/'
425         @set -e; echo 'ECHO for $@'; \
426         echo 'title = "Autogenerated test bundle - do not distribute"' \
427                 >$@.tmp
428         mv -f $@.tmp $@
429
430 #---------- webdriver tests (wdt) ----------
431
432 AT_TESTS := $(basename $(notdir $(wildcard apitest/at-*.rs)))
433 WDT_TESTS := $(basename $(notdir $(wildcard wdriver/wdt-*.rs)))
434
435 WDT_LANDSCAPE_TESTS = wdt-altergame
436
437 at:     $(foreach f, $(AT_TESTS), stamp/$f.check)
438
439 wdt:    $(foreach f, $(WDT_TESTS), stamp/$f.check) \
440         $(foreach f, $(WDT_LANDSCAPE_TESTS), stamp/$f.lcheck) \
441
442 RUNTEST_DEPS =  apitest/run1 stamp/cargo.debug $(FILEASSETS) \
443                 $(wildcard specs/*.toml) examples/test-bundle.zip \
444                 $(wildcard libraries/*.toml) $(LIBRARY_FILES)
445
446 AT_DEPS =       $(filter-out templates/script.js, $(RUNTEST_DEPS)) \
447                 examples/big-bundle.zip \
448                 stamp/cargo-at.debug
449
450 WDT_DEPS =      $(RUNTEST_DEPS) wdriver/firefox-wrapper \
451                 stamp/cargo-wdt.debug
452
453 AT_WDT_RUN = $(NAILING_CARGO_JUST_RUN) $(abspath $<)
454
455 AT_RUN = $(AT_WDT_RUN) apitest --test=$(basename $(notdir $@))
456 WDT_RUN = $(AT_WDT_RUN) wdriver --test=$(basename $(notdir $@))
457
458 for-at:                 $(AT_DEPS)
459 stamp/at-%.check:       $(AT_DEPS)
460         $(AT_RUN)
461         $(stamp)
462
463 for-wdt:                $(WDT_DEPS)
464 stamp/wdt-%.check:      $(WDT_DEPS)
465         $(WDT_RUN)
466         $(stamp)
467
468 stamp/wdt-%.lcheck:     $(WDT_DEPS)
469         $(WDT_RUN) --as-if=lwdt-$* --layout=Landscape
470         $(stamp)
471
472 #---------- docs publication ----------
473
474 PUBLISH_VERSION=unreleased
475 PUBLISH_USER=ianmdlvl@login.chiark.greenend.org.uk
476 PUBLISH_DOC_SPHINX_BASE=public-html/otter
477 PUBLISH_DOC_SPHINX_TAIL=$(PUBLISH_VERSION)/docs
478 PUBLISH_DOC_SPHINX=$(PUBLISH_USER):$(PUBLISH_DOC_SPHINX_BASE)/$(PUBLISH_DOC_SPHINX_TAIL)
479
480 publish: doc-sphinx
481         ssh $(PUBLISH_USER) 'cd $(PUBLISH_DOC_SPHINX_BASE) && mkdir -p $(PUBLISH_DOC_SPHINX_TAIL)'
482         rsync -r --delete-delay docs/html/. $(PUBLISH_DOC_SPHINX)/.
483         git branch -f $(PUBLISHED_BRANCH)
484
485 publish-make-current:
486         ssh $(PUBLISH_USER) 'set -e; cd $(PUBLISH_DOC_SPHINX_BASE); rm -f current.tmp; ln -s $(PUBLISH_VERSION) current.tmp; mv -T current.tmp current'
487
488 #---------- deployment ----------
489
490 DEPLOY_USER=ian@login.chiark.greenend.org.uk
491 DEPLOY_BASE=$(DEPLOY_USER):/volatile/Otter
492 DEPLOY_FINISH=/home/Otter/etc/deploy-finish
493
494 for-deploy: stamp/cargo.deploy-build
495 deploy: for-deploy bundled-sources assets libraries
496         rsync -zvl --progress $(addprefix $(DEPLOY_TARGET_DIR)/,$(PROGRAMS) otter-ssh-proxy) $(DEPLOY_BASE)/bin/
497         rsync -zv --progress $(TARGET_DIR)/release/usvg $(DEPLOY_BASE)/libexec/
498         rsync -rv --progress $(TARGET_DIR)/bundled-sources/. $(DEPLOY_BASE)/bundled-sources
499         rsync -r README.md $(DEPLOY_BASE)/.
500         rsync -r --delete --exclude=\*~ library specs $(DEPLOY_BASE)/.
501         rsync -r $(FILEASSETS) $(addprefix $(WASM_PACKED)/, $(WASM_ASSETS)) \
502                 $(DEPLOY_BASE)/assets/
503         rsync -r nwtemplates/*.tera $(DEPLOY_BASE)/nwtemplates/
504         ssh -o BatchMode=true $(DEPLOY_USER) $(DEPLOY_FINISH)
505         git branch -f $(DEPLOYED_BRANCH)
506         -git push origin main
507         -git push chiark main
508
509 #$(DEPLOY_BASE)/bundled-sources
510
511 #---------- clean ----------
512
513 clean-for-retest:
514         rm -f templates/script.js library/*/*.usvg stamp/*
515         rm -rf $(LIBRARY_CLEAN)
516         rm -rf examples/big-bundle examples/big-bundle.zip
517         rm -f examples/test-bundle.zip
518         find * \( -name '*~' -o -name '*.tmp' \) -print0 | xargs -0r rm --
519
520 clean: clean-nailing clean-for-retest
521         rm -rf target
522         $(NAILING_CARGO_JUST_RUN) rm -rf target