Makefile raw

   1  # musiquay - the web app: wasm bundles + static shell for the musiquay platform.
   2  #
   3  # The native relay lives in ../morly; it serves this directory. `make build`
   4  # leaves a deployable web/static/ (boot, sign-in, wallet, settings) - the
   5  # kind-1 forum is parked and the MLS/Marmot DM worker is parked (see below).
   6  
   7  MOXIE    ?= $(CURDIR)/../moxie/moxie
   8  # An inherited MOXIEROOT is ignored on purpose: `?=` cannot tell an exported
   9  # stale root from an intended one, and a stale root silently compiles a
  10  # different tree's src/ and pkg/. Pass it on the command line to build against
  11  # another tree: make MOXIEROOT=/path/to/moxie ...
  12  ifeq ($(origin MOXIEROOT),environment)
  13  MOXIEROOT := $(CURDIR)/../moxie
  14  endif
  15  MOXIEROOT ?= $(CURDIR)/../moxie
  16  
  17  # Moxie closures do not capture: a closure receives what it needs through its
  18  # parameters. The app predates that enforcement and registers hundreds of
  19  # handlers that close over the enclosing frame, so every build opts out
  20  # explicitly (same as smesh; porting them is app work, not a compiler change).
  21  CAPTURES ?= -allow-closure-captures
  22  
  23  # The relay used by the smoke test. It lives in ../morly and is built there.
  24  MORLY    ?= $(CURDIR)/../morly/morly
  25  
  26  # === Frontend (WASM) ===
  27  build-app-wasm:
  28  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/app.wasm ./web/wasm/app/
  29  
  30  build-relay-proxy-wasm:
  31  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/relay-proxy.wasm ./web/wasm/relay-proxy/
  32  
  33  build-store-wasm:
  34  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/store.wasm ./web/wasm/store/
  35  
  36  build-verify-wasm:
  37  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/verify.wasm ./web/wasm/verify/
  38  
  39  build-profile-wasm:
  40  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/profile.wasm ./web/wasm/profile/
  41  
  42  build-notif-wasm:
  43  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/notif.wasm ./web/wasm/notif/
  44  
  45  build-sw:
  46  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/\$$sw/sw.wasm ./web/wasm/sw/
  47  
  48  # The signer is a page-embedded worker; no browser extension is required.
  49  build-signer:
  50  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/signer.wasm ./web/wasm/signer/
  51  
  52  # Parked modules. Neither is built or served by default:
  53  #   * feed - the kind-1 forum feed worker; every forum route lands on the empty
  54  #            home page and nothing subscribes to kind 1 (see web/wasm/app/main.mx).
  55  #   * mls  - the MLS/Marmot DM worker; it panics in Moxie's codec generating its
  56  #            first KeyPackage (an invalid type descriptor), parked until fixed.
  57  build-feed-wasm:
  58  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/feed.wasm ./web/wasm/feed/
  59  
  60  build-mls-wasm:
  61  	MOXIEROOT=$(MOXIEROOT) GOWORK=off $(MOXIE) build $(CAPTURES) -target wasm -o $(CURDIR)/web/static/mls.wasm ./web/wasm/mls/
  62  
  63  # === All ===
  64  build: build-app-wasm build-relay-proxy-wasm build-store-wasm build-verify-wasm build-profile-wasm build-notif-wasm build-signer build-sw
  65  
  66  # === Dev (frontend only, relay already running) ===
  67  dev: build-app-wasm build-relay-proxy-wasm build-store-wasm build-verify-wasm build-profile-wasm build-notif-wasm build-sw
  68  
  69  # === Test ===
  70  # Every package under pkg/ and web/ carrying a *_test.mx, through the compiler's
  71  # harness. pkg/protocol is the vocabulary every other package is written
  72  # against, so its tests are part of the gate, not an extra.
  73  UNIT_SKIP ?=
  74  test-unit:
  75  	@set -e ; for d in $$( find pkg web -name '*_test.mx' | xargs -n1 dirname | sort -u ) ; do \
  76  		case " $(UNIT_SKIP) " in *" $$d "*) echo "=== unit: $$d (skipped)" ; continue ;; esac ; \
  77  		echo "=== unit: $$d" ; \
  78  		MOXIEROOT=$(MOXIEROOT) $(MOXIE) test $(CAPTURES) ./$$d || exit 1 ; \
  79  	done
  80  
  81  # Standalone vector harnesses under web/_test/ (each is a main package that
  82  # prints its own pass/fail count and exits non-zero on failure).
  83  test-helpers:
  84  	@set -e ; for d in web/_test/bech32test web/_test/hkdftest ; do \
  85  		b=$$(basename $$d) ; \
  86  		echo "=== harness: $$d" ; \
  87  		MOXIEROOT=$(MOXIEROOT) $(MOXIE) build $(CAPTURES) -o $(CURDIR)/tmp/$$b ./$$d ; \
  88  		$(CURDIR)/tmp/$$b ; \
  89  	done
  90  
  91  # The harness verifies the signer's signatures against the legacy moxiejs
  92  # secp256k1 runtime - an independent implementation, and a build product of the
  93  # legacy compiler rather than part of this tree. It looks in the smesh checkout
  94  # by default; override with MOXIEJS_RUNTIME=/path/to/signer-bg/$runtime. The
  95  # harness names that path when it is missing.
  96  test-signer: build-signer
  97  	node web/_test/signertest/run.mjs web/static/signer.wasm
  98  
  99  # Playwright smoke test: boots the morly relay against this static dir, loads
 100  # the app, signs in and asserts the parked state (no forum UI, empty main area
 101  # and notifications). Build the relay first: cd ../morly && make build
 102  test-smoke:
 103  	MORLY=$(MORLY) python3 -m pytest test -v --tb=short
 104  
 105  test: test-unit test-helpers test-signer test-smoke
 106  
 107  .PHONY: build-app-wasm build-relay-proxy-wasm build-store-wasm build-verify-wasm build-profile-wasm build-notif-wasm build-feed-wasm build-mls-wasm build-sw build-signer build dev test-unit test-helpers test-signer test-smoke test
 108