massi-world

this website of mine
Log | Files | Refs

Makefile (1958B)


      1 SHARED_FILES := $(shell fd . common-static)
      2 MW_STATIC_FILES := $(shell fd . site/static)
      3 CLJ_DEPS := src/core.clj
      4 
      5 clj = $(CLJ_DEPS) src/$(1).clj $(shell fd --glob '*.templ.*' $(1))
      6 
      7 MW_CLJ_FILES := $(call clj,site)
      8 SB_CLJ_FILES := $(call clj,swatchbuckler)
      9 
     10 SITE := build/massi.world/index.html
     11 SB := build/swatchbuckler.massi.world/index.html
     12 JS := build/common/shared/js
     13 
     14 # Directory targets don't update on file modification, just file
     15 # creation/deletion/renaming. To prevent file modifications from
     16 # causing this rule to trigger every build, update the mtime of $(1)
     17 # by creating and removing a dummy file.
     18 
     19 # NOTE that this probably isn't a best practice. We should be listing
     20 # each file explicitly.
     21 touch_dir = touch $(1)/.howdy && rm $(1)/.howdy
     22 
     23 all: $(JS) $(SITE) $(SB)
     24 
     25 $(JS): $(wildcard ts/*.ts) | build/common
     26 	./node_modules/esbuild/bin/esbuild \
     27 	--splitting \
     28 	--bundle \
     29 	--sourcemap \
     30 	--outdir=$@ \
     31 	--format=esm \
     32 	ts/*.ts ;
     33 	$(call touch_dir,$@)
     34 
     35 $(SITE): $(MW_CLJ_FILES) | build/massi.world
     36 	clj -X site/build
     37 
     38 $(SB): $(SB_CLJ_FILES) | build/swatchbuckler.massi.world
     39 	clj -X swatchbuckler/build
     40 
     41 build/massi.world: $(MW_STATIC_FILES) build/common
     42 	mkdir -p $@
     43 	cp -r site/static/* $@
     44 	cd $@ && cp -r ../common/* . || echo "its ok"
     45 	$(call touch_dir,$@)
     46 
     47 build/swatchbuckler.massi.world: build/common
     48 	mkdir -p $@
     49 	cd $@ && cp -r ../common/* . || echo "its ok"
     50 	$(call touch_dir,$@)
     51 
     52 build/common: $(SHARED_FILES)
     53 	mkdir -p $@
     54 	cp -r common-static/* $@
     55 	$(call touch_dir,$@)
     56 
     57 serve:
     58 	MW_ENV=dev make
     59 	http-server build -p 8080 & while true; do \
     60 		inotifywait @./build -qre close_write .; \
     61 		MW_ENV=dev make; \
     62 	done
     63 
     64 publish: build
     65 	rsync -rl --delete build/ "mw:/home/protected/builds/massi-world"
     66 	ssh mw cp -r /home/protected/builds/massi-world/massi.world /home/public/test-massi.world
     67 	ssh mw cp -r /home/protected/builds/massi-world/swatchbuckler.massi.world /home/public/test-swatchbuckler.massi.world
     68 
     69 clean:
     70 	rm -r build