Makefile raw
1 MOXIE ?= $(CURDIR)/../moxie/moxie
2 MOXIEJS ?= $(CURDIR)/../moxie/moxiejs
3 MOXIEROOT ?= $(CURDIR)/../moxie
4 JSRUNTIME ?= $(CURDIR)/../moxie/jsruntime
5 ISKRA ?= $(HOME)/.local/bin/moxie-iskra
6 # Use installed moxie for relay-proxy: the smesh crypto package refactor changed
7 # which packages are transitively linked, and the installed binary has correctly
8 # optimized cached package bitcode for relay-proxy. Building fresh with any current
9 # compiler version produces 780KB with too much recursion during _start().
10 # The root cause is GOCACHE invalidation from the crypto refactor; the installed
11 # binary's cache predates it and produces correct 431KB output.
12 MOXIE_RELAY_PROXY ?= $(HOME)/.local/bin/moxie
13
14 # === Relay (native) ===
15 build-relay:
16 MOXIEROOT=$(MOXIEROOT) $(MOXIE) build -o smesh .
17
18 # === Frontend (WASM) ===
19 build-app-wasm:
20 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/app.wasm ./web/wasm/app/
21
22 build-relay-proxy-wasm:
23 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE_RELAY_PROXY) build -target wasm -o $(CURDIR)/web/static/relay-proxy.wasm ./web/wasm/relay-proxy/
24
25 build-store-wasm:
26 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/store.wasm ./web/wasm/store/
27
28 build-verify-wasm:
29 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/verify.wasm ./web/wasm/verify/
30
31 build-profile-wasm:
32 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/profile.wasm ./web/wasm/profile/
33
34 build-feed-wasm:
35 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/feed.wasm ./web/wasm/feed/
36
37 build-dm-wasm:
38 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/dm.wasm ./web/wasm/dm/
39
40 build-mls-wasm:
41 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/mls.wasm ./web/wasm/mls/
42
43
44 build-notif-wasm:
45 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/notif.wasm ./web/wasm/notif/
46
47 build-sw:
48 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/\$$sw/sw.wasm ./web/wasm/sw/
49
50 # === Signer WASM (page-embedded worker) ===
51 # The web app uses signer.wasm directly via signer-wasm-host.mjs.
52 # No browser extension is required for normal operation.
53 build-signer:
54 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -o $(CURDIR)/web/static/signer.wasm ./web/wasm/signer/
55
56 # Extension build (optional, not part of default build).
57 build-ext-firefox: build-signer
58 cp $(CURDIR)/web/static/signer.wasm $(CURDIR)/web/ext/bg/signer.wasm
59 bash scripts/pack-ext.sh firefox
60 cp dist/smesh-signer-firefox.xpi web/static/smesh-signer.xpi
61
62 build-ext: build-ext-firefox
63
64 # === All ===
65 build: build-relay build-app-wasm build-relay-proxy-wasm build-store-wasm build-verify-wasm build-profile-wasm build-feed-wasm build-mls-wasm build-notif-wasm build-signer build-sw
66
67 # === Test ===
68 build-test-relay:
69 MOXIEROOT=$(MOXIEROOT) $(MOXIE) build -o smesh-test .
70
71 test-signer: build-signer
72 node web/_test/signertest/run.mjs web/ext/bg/signer.wasm
73
74 test: build-test-relay test-signer
75 python3 -m pytest test/ -v --tb=short -x
76
77 test-smoke: build-test-relay
78 python3 -m pytest test/test_smoke.py -v --tb=short
79
80 build-app-wasm-instrumented:
81 MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build -target wasm -tags alloc_trace -print-allocs "web/wasm/app" \
82 -o $(CURDIR)/web/static/app.wasm ./web/wasm/app/
83
84 test-memory: build-test-relay build-app-wasm-instrumented
85 python3 -m pytest test/test_memory_profile.py -v --tb=short -m memory
86
87 # === Dev (frontend only, relay already running) ===
88 dev: build-app-wasm build-relay-proxy-wasm build-store-wasm build-verify-wasm build-profile-wasm build-feed-wasm build-mls-wasm build-notif-wasm build-sw
89
90 .PHONY: build-relay build-app-wasm build-relay-proxy-wasm build-store-wasm build-verify-wasm build-profile-wasm build-feed-wasm build-mls-wasm build-notif-wasm build-sw build-signer build-ext-firefox build-ext-chrome build-ext build dev build-test-relay test-signer test test-smoke build-app-wasm-instrumented test-memory
91