From f6645d2613eef016ee777c959f16920c9ea51b09 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 25 Jul 2026 11:48:09 +0200 Subject: [PATCH] Added a Makefile file to handle the development lifecycle in the project. --- Makefile | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 16 +++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..67b22f8 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +# Development lifecycle front door for the play-date package. All logic +# lives in SwiftPM, Scripts/, and the example's own Makefile; the targets +# here only dispatch. Run `make` or `make help` for the list. +# +# `build`, `test`, `docs`, and `consumer-test` need only Xcode's toolchain +# (plus the one-time `make setup`). `embedded` and the example targets +# additionally need the device toolchains described in the README. + +.DEFAULT_GOAL := help + +EXAMPLE_DIR := Examples/HelloPlaydate + +# The embedded check needs a swift.org snapshot toolchain. Pick up the +# standard install location automatically (matching Examples/swift.mk); +# override with `make embedded SWIFT_BIN=/path/to/swift`. +SWIFT_LATEST := $(HOME)/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift +SWIFT_BIN ?= $(if $(wildcard $(SWIFT_LATEST)),$(SWIFT_LATEST),swift) + +.PHONY: help setup build test outdated upgrade embedded consumer-test check docs docs-preview example example-run clean + +help: ## List the available targets + @grep -E '^[a-zA-Z_-]+:.*## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " %-15s %s\n", $$1, $$2}' + +setup: ## One-time: point the "playdate" pkg-config module at the SDK + Scripts/install-pkgconfig.sh + +build: ## Build the bindings for the host + swift build + +test: ## Run the host-runnable unit tests + swift test + +outdated: ## Show the dependency updates that `make upgrade` would apply + swift package update --dry-run + +upgrade: ## Update the SwiftPM dependencies to their latest allowed versions + swift package update + +embedded: ## Compile-only device check (Embedded Swift, armv7em-none-none-eabi) + SWIFT_BIN="$(SWIFT_BIN)" Scripts/build-embedded.sh + +consumer-test: ## Build and run a scratch package depending on play-date + Scripts/consumer-test.sh + +check: build test embedded consumer-test ## Everything CI runs: build, test, embedded, consumer-test + +docs: ## Generate the DocC documentation archive + swift package generate-documentation --target PlayDate + +docs-preview: ## Preview the DocC documentation in a local web server + swift package --disable-sandbox preview-documentation --target PlayDate + +example: ## Build the HelloPlaydate example (device + simulator pdx) + $(MAKE) -C $(EXAMPLE_DIR) + +example-run: ## Build the example and open it in the Playdate Simulator + $(MAKE) -C $(EXAMPLE_DIR) run + +clean: ## Remove build products of the package and the example + rm -rf .build + $(MAKE) -C $(EXAMPLE_DIR) clean diff --git a/README.md b/README.md index 88a6ca5..884df95 100644 --- a/README.md +++ b/README.md @@ -314,6 +314,22 @@ SWIFT_BIN=~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-.xctoo Scripts/build-embedded.sh ``` +## Make targets + +A root Makefile fronts the development lifecycle; a bare `make` (or `make help`) lists the targets. `build`, `test`, `docs`, and `consumer-test` need only Xcode's toolchain (after the one-time `make setup`); `embedded` and the example targets additionally need the device toolchains above — `embedded` picks up a snapshot toolchain installed at `~/Library/Developer/Toolchains` automatically, or takes `SWIFT_BIN=`. + +| Target | Effect | +|---|---| +| `make setup` | One-time: point the `playdate` pkg-config module at the SDK | +| `make build` / `make test` | Build the bindings for the host / run the unit tests | +| `make outdated` / `make upgrade` | Show / apply updates to the SwiftPM dependencies | +| `make embedded` | Compile-only device check (Embedded Swift, `armv7em-none-none-eabi`) | +| `make consumer-test` | Build and run a scratch package depending on play-date | +| `make check` | Everything CI runs: build, test, embedded, consumer-test | +| `make docs` / `make docs-preview` | Generate / preview the DocC documentation | +| `make example` / `make example-run` | Build the HelloPlaydate example / open it in the Playdate Simulator | +| `make clean` | Remove build products of the package and the example | + ## Example [`Examples/HelloPlaydate`](Examples/HelloPlaydate) is a complete minimal game — bouncing box, crank needle, button handling, a system menu item — that builds into a runnable `.pdx`: