64 releases
| 0.5.8 | Mar 19, 2025 |
|---|---|
| 0.5.5 | Aug 12, 2024 |
| 0.5.3 | Jul 17, 2024 |
| 0.3.16 | Mar 21, 2024 |
| 0.0.0 |
|
#142 in Cargo plugins
57 downloads per month
640KB
15K
SLoC
Build System for Playdate applications
Cargo-playdate is a cross-platform plugin for cargo that can build programs for Playdate handheld gaming system written in Rust. It also works as standalone tool.
It can build programs written in Rust, manage assets, build package for Playdate and run on sim or device. Usually it builds static or dynamic libraries for sim and hardware, but also it can build executable binaries for hardware and this method produces highly optimized output with dramatically minimized size (thanks to DCE & LTO)*.
* For executable binaries use --no-gcc argument needed to set up alternative linking final binary.
Platform specific pre-req install instructions
MacOS:
- Install the PlaydateSDK (by default installs into
~/Developer/PlaydateSDK) - Set PLAYDATE_SDK_PATH env var:
export PLAYDATE_SDK_PATH="$HOME/Developer/PlaydateSDK" - Install cmake:
brew install cmake - Install rust nightly:
rustup toolchain install nightly - Arm toolchain is included with PlaydateSDK.
Ubuntu Linux:
- Install the PlaydateSDK - remember where you extracted it.
- Set PLAYDATE_SDK_PATH env var:
export PLAYDATE_SDK_PATH="/path/to/PlaydateSDK-2.x.x/" - Install cmake:
sudo apt-get install cmake - Install rust nightly:
rustup toolchain install nightly - Install arm toolchain:
sudo apt-get install gcc-arm-none-eabi - Install libudev:
sudo apt-get install libudev-dev
Windows:
- Install the PlaydateSDK (by default installs into
~/Documents/PlaydateSDK) - Set PLAYDATE_SDK_PATH
- windows+r, run:
sysdm.cpl - Advanced Tab -> Environment Variables -> New
- Variable name:
PLAYDATE_SDK_PATH - Variable value:
C:\Users\username\Documents\PlaydateSDK
- windows+r, run:
- Install CMake: cmake downloads
- Install rust nightly:
rustup toolchain install nightly - Install arm toolchain: arm gnu toolchain downloads. Filename will be like 'arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.exe'.
- Add arm toolchain and cmake to PATH environment:
- windows+r, run:
sysdm.cpl - Advanced Tab -> Environment Variables.
- Find
Pathand clickEdit - Click
Newand addC:\Program Files\CMake\bin - Click
Newand addC:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\13.2 Rel1\bin
- windows+r, run:
See also: Inside Playdate with C: Prerequisites
Cargo-Playdate Installation
cargo +nightly install cargo-playdate
cargo +nightly playdate --version
Or install to use bleeding edge bits from a local git clone:
cargo +nightly install cargo-playdate --git=https://github.com/boozook/playdate.git
Hello World
Generate new project using new or init command.
mkdir -p ~/code/pd-hello/
cd ~/code/pd-hello/
cargo +nightly playdate init --lib --full-metadata --deps="playdate"
cargo +nightly playdate run
Note, there are more options for this command, e.g.
--deps="sys:git, controls:git". Runcargo playdate new --helpfor more about it.
New package will be created.
Take a look at the package manifest file (Cargo.toml).
There is extra metadata for your playdate package.
For more information about metadata read documentation.
Configuration
There is no configuration other then inherited by cargo and some special environment variables.
CARGO_PLAYDATE_LOGworking same way asCARGO_LOGor defaultRUST_LOG. AlsoCARGO_PLAYDATE_LOG_STYLEPLAYDATE_SDK_PATHpath to the SDK rootARM_GCC_PATHpath to thearm-none-eabi-gccexecutable.
Execute cargo playdate -h for more details, or with --help for further more.
Limitations
- The
cargo-playdatesupports cargo's auto-targets such asbinandexample, but only for binary executable targets ignoring#![crate_type = "lib"]attribute. So if you want to buildexample-target aslib, that needed for run in simulator, you could declare it in the package manifest like this:
Otherwise[[example]] name = "demo" crate-type = ["dylib", "staticlib"] path = "examples/demo.rs"examplewill be built asbinand runnable on device only. In future versions it may be fixed with adding support ofrustccommand like it doescargo rustcto set--crate-type.
- Assets especially for
examplecargo-targets inherits from package assets. Currently there's no way to set assets for single cargo-target, but only for entire package and for dev-targets - there isdev-assetsextra table inherited by package assets.
Troubleshooting
-
On any OS in case of a restricted environment hardware cannot be ejected because of no permissions. Try to give rights and/or build
cargo-playdatewith featureeject. -
Welcome to discussions and issues.
This software is not sponsored or supported by Panic.
Dependencies
~93–125MB
~2.5M SLoC