add demothemes generator to Makefile

minor improvements
This commit is contained in:
ppenguin 2025-04-02 20:47:16 +02:00
parent 11b0ec79a3
commit b338ea5da0
No known key found for this signature in database
GPG key ID: 7E7143B546BB17A7
3 changed files with 26 additions and 17 deletions

13
.gitignore vendored
View file

@ -6,6 +6,17 @@ e2e_report.html
bin
out
d2
# generated svg examples (from make themesdemo)
testdata/examples/svg/
# https://github.com/golang/go/blob/8b67cf0bc6ad657fddcbaaa10729d0086f08f9a9/src/cmd/go/internal/test/test.go#L415-L416
e2etests.test
e2etests.test
# nix/devenv related
# .envrc
devenv.*
!devenv.nix
.devenv*
.direnv
.pre-commit-config.yaml

View file

@ -25,6 +25,18 @@ race: fmt
js: gen
cd d2js/js && NPM_VERSION="${NPM_VERSION}" prefix "$@" ./make.sh all
SVGDIR := testdata/examples/svg
SVGS = $(shell ./d2 themes | gawk -F':' '/^-/{ printf "$(SVGDIR)/themex-%03d.svg ",$$2 }' || :)
.PHONY: clean
clean:
rm -f $(SVGS) d2
.PHONY: themesdemo
themesdemo:
$(MAKE) -C ./testdata/examples/
themesdemo: $(SVGS) d2
$(SVGDIR)/themex-%.svg: testdata/examples/themex.d2
$(info Building $@ from $< ...)
./d2 -t $$(( 10#$* )) $< $@
# d2: build

View file

@ -1,14 +0,0 @@
D2 := ../../d2
SVGS = $(shell $(D2) themes | gawk -F':' '/^-/{ printf "out/themex-%03d.svg ",$$2 }' || :)
.PHONY:
all: $(D2) $(SVGS)
$(D2):
cd $(dir $@) && go build
$(MAKE) $(SVGS)
# D2 as dependency to expire results if recompiled
out/themex-%.svg: themex.d2 $(D2)
$(info Building $@ from $< ...)
$(D2) -t $$(( 10#$* )) $< $@