1 # morly - the ORLY Nostr relay framework, the server side of musiquay.
2 #
3 # The web app lives in ../musiquay; this repo is the native relay that serves
4 # it (static files, /blossom/ blobs, /proxy/ media and the Nostr WebSocket
5 # endpoint) and that musiquay's protocols are added to.
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 relay predates that enforcement in places, so the build opts
19 # out explicitly.
20 CAPTURES ?= -allow-closure-captures
21 22 # === Relay ===
23 build:
24 MOXIEROOT=$(MOXIEROOT) $(MOXIE) build $(CAPTURES) -o morly .
25 26 build-test-relay:
27 MOXIEROOT=$(MOXIEROOT) $(MOXIE) build $(CAPTURES) -o morly-test .
28 29 # Run the relay against a frontend build (defaults to the musiquay web app).
30 STATIC ?= $(CURDIR)/../musiquay/web/static
31 DATA ?= $(CURDIR)/data
32 PORT ?= 3334
33 serve: build
34 ORLY_STATIC_DIR=$(STATIC) ORLY_DATA_DIR=$(DATA) \
35 ORLY_LISTEN=127.0.0.1 ORLY_PORT=$(PORT) ./morly relay
36 37 # === Test ===
38 # Every package carrying a *_test.mx, through the compiler's own harness.
39 UNIT_SKIP ?=
40 test-unit:
41 @set -e ; for d in $$( { [ -f main_test.mx ] && echo . ; find pkg -name '*_test.mx' | xargs -n1 dirname ; } | sort -u ) ; do \
42 case " $(UNIT_SKIP) " in *" $$d "*) echo "=== unit: $$d (skipped)" ; continue ;; esac ; \
43 echo "=== unit: $$d" ; \
44 MOXIEROOT=$(MOXIEROOT) $(MOXIE) test $(CAPTURES) ./$$d || exit 1 ; \
45 done
46 47 test: test-unit
48 49 .PHONY: build build-test-relay serve test-unit test
50