blob: f1966339ee6f7c934643b44b2f1e8899387f82ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
.DEFAULT_GOAL := engine
# Modules listed in dependency order
MODULE_NAMES := entity tween tilemap world input physics renderer assets engine mixer sound animation prefabs scene-loader
OBJECT_FILES := $(patsubst %,bin/%.o,$(MODULE_NAMES))
DEMO_NAMES := platformer shmup topdown audio sandbox spritefont menu tweens scaling animation
DEMO_BINS := $(patsubst %,bin/demo-%,$(DEMO_NAMES))
UNIT_NAMES := $(patsubst %,downstroke-%,$(MODULE_NAMES))
USES_FLAGS := $(patsubst %,-uses %,$(UNIT_NAMES))
# Build all engine modules
engine: $(OBJECT_FILES)
bin:
@mkdir -p $@
# Explicit inter-module dependencies
bin/entity.o:
bin/tween.o: bin/entity.o
bin/tilemap.o:
bin/world.o: bin/entity.o bin/tilemap.o
bin/input.o: bin/entity.o
bin/physics.o: bin/entity.o bin/world.o bin/tilemap.o
bin/renderer.o: bin/entity.o bin/tilemap.o bin/world.o
bin/assets.o:
bin/engine.o: bin/renderer.o bin/world.o bin/input.o bin/assets.o
bin/mixer.o:
bin/sound.o: bin/mixer.o
bin/animation.o: bin/entity.o bin/world.o
bin/prefabs.o: bin/entity.o
bin/scene-loader.o: bin/world.o bin/tilemap.o bin/assets.o bin/engine.o bin/prefabs.o
# Pattern rule: compile each module as a library unit
bin/%.o: %.scm | bin
csc -c -J -unit downstroke-$* $*.scm -o bin/$*.o -I bin
@if [ -f downstroke-$*.import.scm ]; then mv downstroke-$*.import.scm bin/; fi
.PHONY: clean test engine demos filter
clean:
rm -rf bin downstroke/
rm -f *.import.scm *.import.so *.so
rm -f *.log
test:
@echo "Running unit tests..."
@csi -s tests/entity-test.scm
@csi -s tests/world-test.scm
@csi -s tests/tilemap-test.scm
@csi -s tests/physics-test.scm
@csi -s tests/input-test.scm
@csi -s tests/renderer-test.scm
@csi -s tests/assets-test.scm
@csi -s tests/engine-test.scm
@csi -s tests/animation-test.scm
@csi -s tests/prefabs-test.scm
@csi -s tests/scene-loader-test.scm
@csi -s tests/tween-test.scm
# Run a single test file with optional name/group filtering (pytest -k style).
# make filter FILE=tests/physics-test.scm # whole file
# make filter FILE=tests/physics-test.scm K=gravity # tests matching regex
# make filter FILE=tests/physics-test.scm G=apply # groups matching regex
# Note: combining K/G with TEST_QUIET=1 hits a known bug in the `test` egg
# (modulo error in summary timing), so this target intentionally doesn't
# expose Q. Use `TEST_QUIET=1 csi -s <file>` directly when you want quiet.
filter:
@if [ -z "$(FILE)" ]; then echo "usage: make filter FILE=<test.scm> [K=name-regex] [G=group-regex]"; exit 2; fi
@$(if $(K),TEST_FILTER='$(K)') $(if $(G),TEST_GROUP_FILTER='$(G)') csi -s $(FILE)
demos: engine $(DEMO_BINS)
bin/demo-%: demo/%.scm $(OBJECT_FILES) | bin
csc demo/$*.scm $(OBJECT_FILES) -o bin/demo-$* -I bin $(USES_FLAGS) -L -lSDL2_mixer
|