-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (51 loc) · 1.73 KB
/
Copy pathMakefile
File metadata and controls
61 lines (51 loc) · 1.73 KB
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
BINARY := ma
CARGO := cargo
RELEASE := target/release/$(BINARY)
DEBUG := target/debug/$(BINARY)
CLIPPY_STRICT := --all-targets --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery
SRCS := Cargo.toml Cargo.lock src/i18n.yaml $(shell find src -name '*.rs')
PREFIX ?= $(HOME)/.local/bin
PUBLISH := ma:bin/
PUBLISH_SH := .publish.sh
RUN_ARGS ?=
.PHONY: all clean distclean install lint publish test
all: $(BINARY)
lint:
$(CARGO) clippy -- -D warnings
$(CARGO) fmt --check
mdl *.md
test:
$(CARGO) clippy $(CLIPPY_STRICT)
$(CARGO) test --all-features
# Publish all i18n/*.ftl files to IPFS and write the resulting CIDs to
# src/i18n.yaml. Requires `ipfs` (Kubo) and `jq` to be available.
# This file is a build input: `make release` will rebuild the binary
# whenever any FTL file changes.
src/i18n.yaml: $(wildcard i18n/*.ftl)
@set -e; \
dag='{}'; \
for f in i18n/*.ftl; do \
code=$$(basename $$f .ftl); \
cid=$$(ipfs add -q --cid-version 1 "$$f"); \
dag=$$(printf '%s' "$$dag" | jq --arg k "$$code" --arg v "$$cid" '. + {($$k): {"/": $$v}}'); \
done; \
lang_cid=$$(printf '%s' "$$dag" | ipfs dag put --input-codec dag-json --store-codec dag-cbor); \
{ \
printf 'i18n_cid: %s\n' "$$lang_cid"; \
printf 'langs:\n'; \
printf '%s' "$$dag" | jq -r 'to_entries[] | " " + .key + ": " + .value["/"]'; \
} > src/i18n.yaml; \
echo "Written src/i18n.yaml (i18n_cid=$$lang_cid)"
$(RELEASE): $(SRCS)
$(CARGO) build --release
clean:
$(CARGO) clean
install: $(RELEASE)
mkdir -p $(PREFIX)
install -m 0755 $(RELEASE) $(PREFIX)/$(BINARY)
publish: $(RELEASE)
scp $(RELEASE) $(PUBLISH)
test -f $(PUBLISH_SH) && bash $(PUBLISH_SH)
distclean: clean
rm -rf target
rm -rf Cargo.lock src/i18n.yaml