| Crates.io | turbine-pd |
| lib.rs | turbine-pd |
| version | 0.1.2 |
| created_at | 2025-02-23 00:57:36.104186+00 |
| updated_at | 2025-02-24 21:00:21.890774+00 |
| description | Rust wrapper for the Playdate C API |
| homepage | |
| repository | https://codeberg.org/badeline/turbine |
| max_upload_size | |
| id | 1565961 |
| size | 51,895 |
Rust wrapper for the Playdate C API.
The first step is to tell Rust to build your program as a cdylib and staticlib. This will result in the target directory
containing both a libmyproject.so and a libmyproject.a when building for the simulator, and a libmyproject.a when building for
real hardware. Add this to your Cargo.toml:
[lib]
crate-type = ["cdylib", "staticlib"]
You then must tell Rust to disable unwinding, as arm-none-eabi doesn't support it, and I'm sure the simulator will freak out if you try, so put this in your Cargo.toml:
[profile.release]
panic = 'abort'
[profile.dev]
panic = 'abort'
Finally, you need to tell Rust to depend on turbine and panic-halt.
Again, in your Cargo.toml:
[dependencies]
panic-halt = "*"
turbine = "^0.1"
Now, put this in your src/lib.rs file:
#![no_std] // tell rust we don't want to import `std`, since Playdate doesn't support it
use turbine::playdate_main;
use panic_halt as _; // endlessly loop on panic.
#[playdate_main] // make this our update function
fn main(api: &mut turbine::core::PlaydateAPI) -> u8 {
0
}
Once you've configured your project, you then need to compile it. You can do this using cargo-carbide, so install it with cargo install cargo-carbide.
You then need to configure your package metadata to tell Playdate about your game. It should look something like this:
[package.metadata.playdate]
name = "Playdate Rust Example"
bundle_id = "com.example.playdate.game"
build_number = 1
You can then use cargo carbide build to compile it.