commit be41cccaa62cb9d2d4a6867cec2ce3952cf318c3 parent 5c5888f8bd5ec604bb4feb58d117b581f1adcc3f Author: massi <git@massi.world> Date: Fri, 16 Aug 2024 01:19:49 -0700 1000x better makefile Diffstat:
10 files changed, 44 insertions(+), 24 deletions(-)
diff --git a/Makefile b/Makefile @@ -1,45 +1,65 @@ -clean: - rm -r build +SHARED_FILES := $(shell fd . common-static) +MW_STATIC_FILES := $(shell fd . site/static) +CLJ_DEPS := src/core.clj + +clj = $(CLJ_DEPS) src/$(1).clj $(shell fd --glob '*.templ.*' $(1)) -build: -# make dirs - mkdir -p build/shared - mkdir -p build/swatchbuckler.massi.world - mkdir -p build/massi.world +MW_CLJ_FILES := $(call clj,site) +SB_CLJ_FILES := $(call clj,swatchbuckler) -# copy static files for shared AND each subdomain - cp -r shared/static/* build/shared - cp -r site/static/* build/massi.world -# cp -r swatchbuckler/static/* build/swatchbuckler.massi.world # nonconforning rn +SITE := build/massi.world/index.html +SB := build/swatchbuckler.massi.world/index.html +JS := build/common/shared/js -# copy over random shared things -# cp node_modules/d3-color/dist/d3-color.min.js shared/static/shared/js/ +# Directory targets don't update on file modification, just file +# creation/deletion/renaming. To prevent file modifications from +# causing this rule to trigger every build, update the mtime of $(1) +# by creating and removing a dummy file. +touch_dir = touch $(1)/.howdy && rm $(1)/.howdy -# build ts files +all: $(JS) $(SITE) $(SB) + +$(JS): $(wildcard ts/*.ts) ./node_modules/esbuild/bin/esbuild \ --splitting \ --bundle \ --sourcemap \ - --outdir=build/shared/shared/js \ + --outdir=$@ \ --format=esm \ ts/*.ts ; + $(call touch_dir,$@) -# link shared files to each subdomain - cd build/massi.world && ln -s ../shared/* . - cd build/swatchbuckler.massi.world && ln -s ../shared/* . - -# build +$(SITE): $(MW_CLJ_FILES) | build/massi.world clj -X site/build + +$(SB): $(SB_CLJ_FILES) | build/swatchbuckler.massi.world clj -X swatchbuckler/build +build/massi.world: $(MW_STATIC_FILES) build/common + mkdir -p $@ + cp -r site/static/* $@ + cd $@ && ln -s ../common/* . || echo "its ok" + $(call touch_dir,$@) + +build/swatchbuckler.massi.world: build/common + mkdir -p $@ + cd $@ && ln -s ../common/* . || echo "its ok" + $(call touch_dir,$@) + +build/common: $(SHARED_FILES) + mkdir -p $@ + cp -r common-static/* $@ + $(call touch_dir,$@) + serve: - make clean - MW_ENV=dev make build + MW_ENV=dev make http-server build -p 8080 & while true; do \ inotifywait @./build -qre close_write .; \ - make clean; \ - MW_ENV=dev make build; \ + MW_ENV=dev make; \ done publish: build rsync -rl --delete build/ "mw:/home/protected/builds/massi-world" + +clean: + rm -r build diff --git a/shared/static/favicon.ico b/common-static/favicon.ico Binary files differ. diff --git a/shared/static/shared/assets/icon-16-16.png b/common-static/shared/assets/icon-16-16.png Binary files differ. diff --git a/shared/static/shared/assets/icon-180-180.png b/common-static/shared/assets/icon-180-180.png Binary files differ. diff --git a/shared/static/shared/assets/icon-192-192.png b/common-static/shared/assets/icon-192-192.png Binary files differ. diff --git a/shared/static/shared/assets/icon-32-32.png b/common-static/shared/assets/icon-32-32.png Binary files differ. diff --git a/shared/static/shared/assets/icon-48-48.png b/common-static/shared/assets/icon-48-48.png Binary files differ. diff --git a/shared/static/shared/assets/mw-spritesheet.png b/common-static/shared/assets/mw-spritesheet.png Binary files differ. diff --git a/shared/static/shared/assets/spiral-for-dark-mode.svg b/common-static/shared/assets/spiral-for-dark-mode.svg diff --git a/shared/static/shared/assets/spiral-for-light-mode.svg b/common-static/shared/assets/spiral-for-light-mode.svg