Port the shared emulator harness (all apps) to SDL 3.4 + SDL3_ttf 3.2:
- window creation without position args; renderer logical size via
SDL_SetRenderLogicalPresentation(LETTERBOX); SDL_RenderTexture;
SDL_SaveBMP_IO frame dumps
- SDL_EVENT_* event scheme, flattened SDL_KeyboardEvent, float mouse
coords; clicks mapped with SDL_ConvertEventToRenderCoordinates, keeping
the Xwayland global-state cross-check from 260a2b3
- audio shim on the stream API (SDL_OpenAudioDeviceStream +
SDL_PutAudioStreamData) since SDL_QueueAudio is gone
- TTF_RenderText_Blended (explicit length); SDL3_ttf header layout
handled via __has_include (Ubuntu installs under SDL3_ttf/)
- e2e freeze-tint pixel assertions updated to the committed
diagonal-stripe pattern (stale since the freeze rework; pre-existing
failures at HEAD under SDL2), sampled away from the freeze text
Full suite green: 14 unit + 7 integration + 3 E2E journeys, 0 failures.
MissileCommand, MiataDrive, NetDeck build; CrtTerminal (missing sndBlip
declaration) and Lotus3 (sketch not in repo) fail identically at HEAD -
pre-existing, out of scope.
97 lines
3.4 KiB
Makefile
97 lines
3.4 KiB
Makefile
# SDL3 emulator for T-Deck example sketches (run the app on your PC)
|
|
#
|
|
# make build the MissileCommand emulator (default)
|
|
# make APP=CrtTerminal build the CRT terminal emulator
|
|
# make run [APP=...] build + launch the window
|
|
# make smoke [APP=...] headless test: N frames, dump the last frame
|
|
# make clean [APP=...] remove the binary + smoke frame
|
|
#
|
|
# The sketch is included by src/main.cpp as a single translation unit:
|
|
# -DAPP_INO='"<App>.ino"'. Apps with a sound_engine.cpp get it linked
|
|
# automatically (wildcard).
|
|
|
|
APP ?= MissileCommand
|
|
APP_DIR := ../examples/$(APP)
|
|
|
|
ifeq ($(APP),MissileCommand)
|
|
APP_TITLE := Missile Command
|
|
DEFS += -DEMU_APP_MISSILECOMMAND
|
|
endif
|
|
ifeq ($(APP),CrtTerminal)
|
|
APP_TITLE := CRT Terminal
|
|
endif
|
|
ifeq ($(APP),NetDeck)
|
|
APP_TITLE := NetDeck // Breach & Board
|
|
# the sketch moved to src/netdeck (next to nd_layout.h); its hardware
|
|
# shim header utilities.h stays with the pio project in examples/NetDeck
|
|
APP_DIR := ../src/netdeck
|
|
APP_EXTRA_INC := ../examples/NetDeck
|
|
endif
|
|
ifeq ($(APP),Lotus3)
|
|
APP_TITLE := Lotus 3
|
|
DEFS += -DEMU_APP_LOTUS3
|
|
ifdef AUTOPLAY
|
|
DEFS += -DAUTOPLAY
|
|
endif
|
|
endif
|
|
APP_TITLE ?= $(APP)
|
|
|
|
CXX ?= g++
|
|
CXXFLAGS ?= -std=gnu++17 -O2 -Wall -Wextra
|
|
SDLFLAGS := $(shell pkg-config --cflags sdl3 sdl3-ttf)
|
|
INC := -Isrc/shim -I$(APP_DIR) $(if $(APP_EXTRA_INC),-I$(APP_EXTRA_INC))
|
|
LIBS := $(shell pkg-config --libs sdl3 sdl3-ttf)
|
|
|
|
DEFS += -DAPP_INO='"$(APP).ino"' -DAPP_NAME='"$(APP_TITLE)"'
|
|
|
|
SHIMS := $(wildcard src/shim/*.h) $(wildcard src/shim/driver/*.h)
|
|
SKETCH_SRCS := $(APP_DIR)/$(APP).ino $(wildcard $(APP_DIR)/*.h)
|
|
SOUND_SRC := $(wildcard $(APP_DIR)/sound_engine.cpp)
|
|
EMU := $(APP)-emu
|
|
|
|
# Headless test binaries (tests/): same single-TU sketch inclusion as
|
|
# main.cpp, no window. Unit+integration share one fast binary; E2E is a
|
|
# separate build driving the real loop() through the device input pipeline.
|
|
TESTS := $(wildcard tests/*.h tests/*.cpp tests/e2e/*.cpp)
|
|
TESTS_INC := $(INC) -Itests
|
|
|
|
.PHONY: all run smoke test test-unit test-e2e clean
|
|
|
|
all: $(EMU)
|
|
|
|
$(EMU): src/main.cpp $(SOUND_SRC) $(APP_DIR)/$(APP).ino $(SHIMS)
|
|
$(CXX) $(CXXFLAGS) $(SDLFLAGS) $(INC) $(DEFS) \
|
|
src/main.cpp $(SOUND_SRC) -o $@ $(LIBS)
|
|
|
|
run: $(EMU)
|
|
./$(EMU)
|
|
|
|
# Headless smoke test: dummy video/audio, run N frames, save the last frame.
|
|
# Feed keys via --type "text" (queued a few chars per frame).
|
|
smoke: $(EMU)
|
|
./$(EMU) --frames 240 --dump smoke_frame.bmp
|
|
|
|
# --- tests -----------------------------------------------------------------
|
|
# fast layer: unit + integration (deterministic, sim stepped directly)
|
|
$(APP)-tests: tests/test_main.cpp tests/shim_globals.cpp tests/harness.h \
|
|
tests/sim_helpers.h tests/unit_tests.h tests/integration_tests.h \
|
|
$(SHIMS) $(SKETCH_SRCS)
|
|
$(CXX) $(CXXFLAGS) $(SDLFLAGS) $(TESTS_INC) $(DEFS) \
|
|
tests/shim_globals.cpp tests/test_main.cpp -o $@ $(LIBS)
|
|
|
|
# slow layer: E2E journeys through the real loop() + input pipeline (own build)
|
|
$(APP)-e2e: tests/e2e_tests.cpp tests/shim_globals.cpp tests/harness.h \
|
|
tests/sim_helpers.h $(SHIMS) $(SKETCH_SRCS)
|
|
$(CXX) $(CXXFLAGS) $(SDLFLAGS) $(TESTS_INC) $(DEFS) \
|
|
tests/shim_globals.cpp tests/e2e_tests.cpp -o $@ $(LIBS)
|
|
|
|
test-unit: $(APP)-tests
|
|
./$(APP)-tests unit
|
|
|
|
test: test-unit
|
|
./$(APP)-tests integration
|
|
test-e2e: $(APP)-e2e
|
|
SDL_VIDEODRIVER=dummy ./$(APP)-e2e
|
|
|
|
clean:
|
|
rm -f $(EMU) $(APP)-tests $(APP)-e2e smoke_frame.bmp
|