Added a Makefile file to handle the development lifecycle in the project.
This commit is contained in:
@@ -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
|
||||||
@@ -314,6 +314,22 @@ SWIFT_BIN=~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-<date>.xctoo
|
|||||||
Scripts/build-embedded.sh
|
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=<path to swift>`.
|
||||||
|
|
||||||
|
| 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
|
## 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`:
|
[`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`:
|
||||||
|
|||||||
Reference in New Issue
Block a user