diff options
author | EuAndreh <eu@euandre.org> | 2024-10-21 07:39:46 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-10-21 17:17:17 -0300 |
commit | d45cf0d708bc739b6478e741c964da2e64e3d874 (patch) | |
tree | a62b03cb31f8f3fe9dc1f4b94ab8a0f5669bb5b3 /Makefile | |
parent | src/content/img/: Add favicon and logo SVGs (diff) | |
download | chat.papo.im-d45cf0d708bc739b6478e741c964da2e64e3d874.tar.gz chat.papo.im-d45cf0d708bc739b6478e741c964da2e64e3d874.tar.xz |
Init work on offline support and tests
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..669e9cc --- /dev/null +++ b/Makefile @@ -0,0 +1,97 @@ +.POSIX: +NAME = webapp +PREFIX = /usr +SRCDIR = $(PREFIX)/src/$(NAME) +SHAREDIR = $(PREFIX)/share +# DOCDIR? JavaScript goes to DOCDIR? Really? +DOCDIR = $(SHAREDIR)/doc/$(NAME) + + + +.SUFFIXES: +.SUFFIXES: .js + + +all: +include deps.mk + + + +static-contents = \ + src/content/papo.js \ + src/content/style.css \ + src/content/index.html \ + +contents = \ + src/content/service-worker.js \ + $(img.svg) \ + + +derived-assets = \ + src/content/papo.exported.js \ + src/content/sw.exported.js \ + src/content/service-worker.js \ + + + +all: $(derived-assets) + + +## The use of static `import` statements inside service workers +## isn't supported. So in order to have tests for the code in +## it, a "main()" function is included in the generated file +## so that is can be ran as a standalone file. +src/content/service-worker.js: src/content/sw.js src/sw-main.js Makefile + cat src/content/sw.js src/sw-main.js > $@ + +src/content/papo.exported.js src/content/sw.exported.js: \ + Makefile src/exported.sh +src/content/papo.exported.js: src/content/papo.js +src/content/sw.exported.js: src/content/sw.js + +src/content/papo.exported.js src/content/sw.exported.js: + sh src/exported.sh $(@D)/`basename $@ .exported.js`.js > $@ + + + +.SUFFIXES: .js-check +tests/papo.js-check: src/content/papo.exported.js +tests/sw.js-check: src/content/sw.exported.js +tests/papo.js-check tests/sw.js-check: + node tests/node-driver.js $*.js + + +check-unit: tests/papo.js-check tests/sw.js-check + +check-integration: + +check: check-unit check-integration + + +clean: + rm -rf $(derived-assets) $(side-assets) + +install: all + mkdir -p \ + '$(DESTDIR)$(SRCDIR)' \ + + for f in $(contents) $(static-contents); do \ + dir='$(DESTDIR)$(DOCDIR)'/"`dirname "$${f#src/content/}"`"; \ + mkdir -p "$$dir"; \ + cp -P "$$f" "$$dir"; \ + done + +uninstall: + rm -rf \ + '$(DESTDIR)$(SRCDIR)' \ + '$(DESTDIR)$(DOCDIR)' \ + + + +PORT = 3334 +## Run file server for local static files +run: + serve -n -p $(PORT) -d '$(DESTDIR)$(DOCDIR)' + + +ALWAYS: |