2026-07-25 10:09:34 +02:00
|
|
|
REPO_ROOT := $(shell git rev-parse --show-toplevel)
|
|
|
|
|
PRODUCT := HelloPlaydate.pdx
|
|
|
|
|
include $(REPO_ROOT)/Examples/swift.mk
|
|
|
|
|
|
2026-07-25 12:01:16 +02:00
|
|
|
# MARK: - Build PlaydateKit Wrapper Swift Module
|
2026-07-25 12:39:32 +02:00
|
|
|
# The wrapper sources are organized in nested domain folders, so collect
|
|
|
|
|
# them recursively (a plain *.swift glob would miss the subdirectories).
|
|
|
|
|
PLAYDATEKIT_SOURCES := $(shell find $(REPO_ROOT)/Sources/PlaydateKit -name '*.swift')
|
|
|
|
|
|
|
|
|
|
build/Modules/playdate_device.o: $(PLAYDATEKIT_SOURCES)
|
2026-07-25 10:09:34 +02:00
|
|
|
@mkdir -p build/Modules
|
|
|
|
|
$(SWIFT_EXEC) $(SWIFT_FLAGS) $(SWIFT_FLAGS_DEVICE) -c $^ -emit-module -o $@
|
|
|
|
|
|
2026-07-25 12:39:32 +02:00
|
|
|
build/Modules/playdate_simulator.o: $(PLAYDATEKIT_SOURCES)
|
2026-07-25 10:09:34 +02:00
|
|
|
@mkdir -p build/Modules
|
|
|
|
|
$(SWIFT_EXEC) $(SWIFT_FLAGS) $(SWIFT_FLAGS_SIMULATOR) -c $^ -emit-module -o $@
|
|
|
|
|
|
|
|
|
|
# MARK: - Build Game Swift Object
|
2026-07-25 10:29:30 +02:00
|
|
|
# The wrapper module is a normal prerequisite so wrapper edits also rebuild
|
|
|
|
|
# the game object; only the Swift sources are compiler inputs.
|
|
|
|
|
build/game_device.o: Sources/HelloPlaydate/*.swift build/Modules/playdate_device.o
|
|
|
|
|
$(SWIFT_EXEC) $(SWIFT_FLAGS) $(SWIFT_FLAGS_DEVICE) -c $(filter %.swift,$^) -o $@
|
2026-07-25 10:09:34 +02:00
|
|
|
$(OBJDIR)/pdex.elf: build/game_device.o
|
|
|
|
|
OBJS += build/game_device.o
|
|
|
|
|
# The wrapper object carries symbols that are not emitted into the game
|
|
|
|
|
# object, such as the posix_memalign shim the Embedded Swift runtime needs.
|
2026-07-25 10:29:30 +02:00
|
|
|
# common.mk expanded OBJS before this line, so the link prerequisite has to
|
|
|
|
|
# be added explicitly as well.
|
|
|
|
|
$(OBJDIR)/pdex.elf: build/Modules/playdate_device.o
|
2026-07-25 10:09:34 +02:00
|
|
|
OBJS += build/Modules/playdate_device.o
|
|
|
|
|
|
2026-07-25 10:29:30 +02:00
|
|
|
build/game_simulator.o: Sources/HelloPlaydate/*.swift build/Modules/playdate_simulator.o
|
|
|
|
|
$(SWIFT_EXEC) $(SWIFT_FLAGS) $(SWIFT_FLAGS_SIMULATOR) -c $(filter %.swift,$^) -o $@
|
2026-07-25 10:09:34 +02:00
|
|
|
$(OBJDIR)/pdex.${DYLIB_EXT}: build/game_simulator.o
|
2026-07-25 11:33:09 +02:00
|
|
|
SIMCOMPILER += build/game_simulator.o
|
|
|
|
|
|
|
|
|
|
# MARK: - Convenience Targets
|
|
|
|
|
# The SDK's common.mk (included via swift.mk) already provides the build
|
|
|
|
|
# targets, all packaging $(PRODUCT) with pdc:
|
|
|
|
|
# make device binary + simulator dylib (alias: all)
|
|
|
|
|
# make simulator simulator dylib only
|
|
|
|
|
# make device device binary only
|
|
|
|
|
.PHONY: run clean-swiftpm
|
|
|
|
|
|
|
|
|
|
# Build the simulator flavor and launch the pdx in the Playdate Simulator.
|
|
|
|
|
run: simulator
|
|
|
|
|
open -a "$(SDK)/bin/Playdate Simulator.app" $(PRODUCT)
|
|
|
|
|
|
|
|
|
|
# common.mk's clean removes the build folder, $(PRODUCT), and the binaries
|
|
|
|
|
# copied into Source/; also drop the .build folder SwiftPM leaves behind
|
|
|
|
|
# when building with build.sh.
|
|
|
|
|
clean: clean-swiftpm
|
|
|
|
|
clean-swiftpm:
|
2026-07-25 12:01:16 +02:00
|
|
|
-rm -rf .build
|