Skip to content

Commit

Permalink
Initial import (history reset, this is the last time!)
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook committed Sep 10, 2023
1 parent 2afe4c9 commit 8e3a9b2
Show file tree
Hide file tree
Showing 57 changed files with 2,926 additions and 359 deletions.
7 changes: 7 additions & 0 deletions .github/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[unstable]
unstable-options = true
config-include = true
check-cfg = ["features", "names", "values", "output"]
panic-abort-tests = true
mtime-on-use = true
avoid-dev-deps = true
1 change: 1 addition & 0 deletions .github/workflows/post.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Post
on:
release:
types: [published]
Expand Down
59 changes: 31 additions & 28 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
os:
- macos-latest
- ubuntu-latest
- windows-latest
# - windows-latest
sdk:
- latest

Expand All @@ -36,6 +36,11 @@ jobs:
- name: Cache
uses: Swatinem/rust-cache@v1

- name: Config
run: |
mkdir -p .cargo
cp -rf .github/config.toml .cargo/config.toml
- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
uses: pd-rs/get-playdate-sdk@main
Expand All @@ -45,37 +50,31 @@ jobs:
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version

- name: Install cargo-action-fmt
uses: baptiste0928/cargo-install@v2.1.0
with:
crate: cargo-action-fmt

- name: Test Crates
run: |
FEATURES_1=bindgen-runtime
FEATURES_2=bindgen-runtime,bindings-derive-debug,error-ctx
FEATURES_3=bindgen-runtime,bindings-derive-debug,bindings-documentation
FEATURES_2=bindgen-runtime,bindings-derive-debug,bindings-documentation,error-ctx
cargo test -p=playdate-sys -- --nocapture
cargo test -p=playdate-sys --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-sys --features=$FEATURES_2 -- --nocapture
cargo test -p=playdate-sys --features=$FEATURES_3 -- --nocapture
cargo test -p=playdate-fs --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-fs --lib --no-default-features --features=$FEATURES_2 -- --nocapture
cargo test -p=playdate-fs --lib --no-default-features --features=$FEATURES_3 -- --nocapture
cargo test -p=playdate-sound --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-sound --lib --no-default-features --features=$FEATURES_2 -- --nocapture
cargo test -p=playdate-sound --lib --no-default-features --features=$FEATURES_3 -- --nocapture
cargo test -p=playdate-color --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-color --lib --no-default-features --features=$FEATURES_2 -- --nocapture
cargo test -p=playdate-color --lib --no-default-features --features=$FEATURES_3 -- --nocapture
cargo test -p=playdate-controls --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-controls --lib --no-default-features --features=$FEATURES_2 -- --nocapture
cargo test -p=playdate-controls --lib --no-default-features --features=$FEATURES_3 -- --nocapture
cargo test -p=playdate-menu --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-menu --lib --no-default-features --features=$FEATURES_2 -- --nocapture
cargo test -p=playdate-graphics --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-graphics --lib --no-default-features --features=$FEATURES_2 -- --nocapture
- name: Examples
run: |
Expand All @@ -85,6 +84,8 @@ jobs:
cargo build --target=thumbv7em-none-eabihf -p=playdate-controls --examples --features=$FEATURES -Zbuild-std
cargo build --target=thumbv7em-none-eabihf -p=playdate-color --examples --features=$FEATURES -Zbuild-std
cargo build --target=thumbv7em-none-eabihf -p=playdate-sound --examples --features=$FEATURES -Zbuild-std
cargo build --target=thumbv7em-none-eabihf -p=playdate-menu --examples --features=$FEATURES -Zbuild-std
cargo build --target=thumbv7em-none-eabihf -p=playdate-graphics --examples --features=$FEATURES -Zbuild-std
# Imitate docs.rs environment
- name: Test in no-sdk environment
Expand All @@ -106,8 +107,8 @@ jobs:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
# - ubuntu-latest
# - windows-latest
sdk:
- latest

Expand All @@ -116,6 +117,11 @@ jobs:
- name: Cache
uses: Swatinem/rust-cache@v1

- name: Config
run: |
mkdir -p .cargo
cp -rf .github/config.toml .cargo/config.toml
- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
uses: pd-rs/get-playdate-sdk@main
Expand All @@ -125,29 +131,24 @@ jobs:
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version

- name: Install cargo-action-fmt
uses: baptiste0928/cargo-install@v2.1.0
with:
crate: cargo-action-fmt

- name: Test Utils
run: |
cargo test -p=playdate-build-utils --all-features
cargo test -p=playdate-build --all-features
cargo test -p=playdate-tool --all-features
- name: Check
- name: Test
run: |
cargo check -p=cargo-playdate -q --message-format=json | cargo-action-fmt
cargo test -p=cargo-playdate --no-run -q --message-format=json | cargo-action-fmt
cargo test -p=cargo-playdate -- --nocapture --test-threads=1
rm -rf ./target/tmp
- name: Test
- name: Test (+usb)
run: |
cargo test -p=cargo-playdate -- --nocapture
cargo test -p=cargo-playdate --features=usb -- --nocapture --test-threads=1
rm -rf ./target/tmp
- name: Install
run: |
cargo install -p=cargo-playdate --debug
run: cargo install --path=./cargo --debug

- name: Examples
run: |
Expand All @@ -158,6 +159,8 @@ jobs:
cargo playdate package --simulator --device -p=playdate-controls --examples
cargo playdate package --simulator --device -p=playdate-color --examples
cargo playdate package --simulator --device -p=playdate-sound --examples
cargo playdate package --simulator --device -p=playdate-menu --examples
cargo playdate package --simulator --device -p=playdate-graphics --examples
# TODO: build crankstart with examples for compatibility test

Expand Down
8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@ members = [
"support/*",
# "components/*"
]
default-members = [
"cargo",
"support/tool",
"api/playdate",
"api/sys",
"support/build",
]
default-members = ["cargo", "support/tool"]
exclude = ["cargo/tests/crates/**/*"]
63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# 🦀 Playdate API and build tools in Rust

* [Modular build system][support-dir]
- build-support libraries
- pre-configured bindgen with extra codegen
- [cargo-playdate][cargo-dir] - one-button solution to build, package and run programs
* [Modular low- & high- level API][api-dir]
- with [examples][ctrl-examples-dir]

Welcome to [discussions][] and [issues][] for any questions and suggestions.


## Prerequisites

Follow the instructions for:
1. [SDK](https://sdk.play.date/Inside%20Playdate%20with%20C.html#_prerequisites)
1. [cargo-playdate](https://github.com/boozook/playdate/blob/main/cargo/README.md#prerequisites)
1. [playdate-sys](https://github.com/boozook/playdate/tree/main/api/sys#prerequisites)

TODO: 🚨 proper documentation - short description for all crates with links.


## Usage
Expand All @@ -19,6 +34,52 @@ cargo playdate run -p=playdate-sound --example=sp-simple --device
```


## Modularity

Thanks to the modular structure of the system, you can use all or only the parts of the system you need.

### Create a Game

1. Add [API-components][api-dir] as dependencies to your project
1. Install [cargo-playdate][] to build your project

### Create an API-extension

1. Add [playdate-sys][] to dependencies
1. Write neat code
1. Build & test using cargo, [cargo-playdate][] or anything else.

Here is [example][color-dir] of simple API-extension.

Please follow [the instructions of playdate-sys](https://github.com/boozook/playdate/tree/main/api/sys#extension-development).

### Create your bindings

1. Use [playdate-bindgen][] in your build-script

### Create your build-system

1. Use [build-support crates][support-dir]

There is all needed to find SDK and arm-gnu toolchain on user's system, build flags, configurations, formats including pdxinfo, etc.



[playdate-sys]: https://crates.io/crates/playdate-sys
[cargo-playdate]: https://crates.io/crates/cargo-playdate
[playdate-bindgen]: https://crates.io/crates/playdate-bindgen

[support-dir]: https://github.com/boozook/playdate/tree/main/support
[cargo-dir]: https://github.com/boozook/playdate/tree/main/cargo
[api-dir]: https://github.com/boozook/playdate/tree/main/api
[ctrl-examples-dir]: https://github.com/boozook/playdate/tree/main/api/ctrl/examples
[color-dir]: https://github.com/boozook/playdate/tree/main/api/color

[issues]: https://github.com/boozook/playdate/issues
[discussions]: https://github.com/boozook/playdate/discussions




- - -

Expand Down
40 changes: 20 additions & 20 deletions api/color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ repository = "https://github.com/boozook/playdate.git"


[features]
default = ["pd/default"]
lang-items = ["pd/lang-items"]
allocator = ["pd/allocator"]
panic-handler = ["pd/panic-handler"]
eh-personality = ["pd/eh-personality"]
error-ctx = ["pd/error-ctx"]
bindgen-runtime = ["pd/bindgen-runtime"]
bindings-pre-built = ["pd/bindings-pre-built"]
bindings-generate = ["pd/bindings-generate"]
bindings-derive-default = ["pd/bindings-derive-default"]
bindings-derive-eq = ["pd/bindings-derive-eq"]
bindings-derive-copy = ["pd/bindings-derive-copy"]
bindings-derive-debug = ["pd/bindings-derive-debug"]
bindings-derive-hash = ["pd/bindings-derive-hash"]
bindings-derive-ord = ["pd/bindings-derive-ord"]
bindings-derive-partialeq = ["pd/bindings-derive-partialeq"]
bindings-derive-partialord = ["pd/bindings-derive-partialord"]
bindings-derive-constparamty = ["pd/bindings-derive-constparamty"]
bindings-documentation = ["pd/bindings-documentation"]
default = ["sys/default"]
lang-items = ["sys/lang-items"]
allocator = ["sys/allocator"]
panic-handler = ["sys/panic-handler"]
eh-personality = ["sys/eh-personality"]
error-ctx = ["sys/error-ctx"]
bindgen-runtime = ["sys/bindgen-runtime"]
bindgen-static = ["sys/bindgen-static"]
bindings-derive-default = ["sys/bindings-derive-default"]
bindings-derive-eq = ["sys/bindings-derive-eq"]
bindings-derive-copy = ["sys/bindings-derive-copy"]
bindings-derive-debug = ["sys/bindings-derive-debug"]
bindings-derive-hash = ["sys/bindings-derive-hash"]
bindings-derive-ord = ["sys/bindings-derive-ord"]
bindings-derive-partialeq = ["sys/bindings-derive-partialeq"]
bindings-derive-partialord = ["sys/bindings-derive-partialord"]
bindings-derive-constparamty = ["sys/bindings-derive-constparamty"]
bindings-documentation = ["sys/bindings-documentation"]


[dependencies.pd]
[dependencies.sys]
path = "../sys"
version = "0.1"
package = "playdate-sys"
default-features = false
14 changes: 8 additions & 6 deletions api/color/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
#![feature(const_trait_impl)]
#![feature(impl_trait_in_assoc_type)]

pub extern crate pd as sys;
use pd::ffi::LCDColor;
use pd::ffi::LCDPattern;
use pd::ffi::LCDSolidColor;
pub extern crate sys;
use sys::ffi::LCDColor;
use sys::ffi::LCDPattern;
use sys::ffi::LCDSolidColor;


#[derive(PartialEq, Clone)]
#[cfg_attr(feature = "bindings-derive-debug", derive(Debug))]
pub enum Color<'t> {
Solid(LCDSolidColor),
Pattern(&'t LCDPattern),
PatternRef(&'t LCDPattern),
Pattern(LCDPattern),
}

impl Color<'static> {
Expand All @@ -26,7 +27,8 @@ impl From<Color<'_>> for LCDColor {
fn from(color: Color) -> Self {
match color {
Color::Solid(color) => color as LCDColor,
Color::Pattern(pattern) => (pattern as *const u8) as LCDColor,
Color::Pattern(ref pattern) => (pattern as *const u8) as LCDColor,
Color::PatternRef(pattern) => (pattern as *const u8) as LCDColor,
}
}
}
Expand Down
46 changes: 23 additions & 23 deletions api/ctrl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ repository = "https://github.com/boozook/playdate.git"


[features]
default = ["pd/default"]
lang-items = ["pd/lang-items"]
allocator = ["pd/allocator"]
panic-handler = ["pd/panic-handler"]
eh-personality = ["pd/eh-personality"]
entry-point = ["pd/entry-point"]
error-ctx = ["pd/error-ctx"]
bindgen-runtime = ["pd/bindgen-runtime"]
bindings-pre-built = ["pd/bindings-pre-built"]
bindings-generate = ["pd/bindings-generate"]
bindings-derive-default = ["pd/bindings-derive-default"]
bindings-derive-eq = ["pd/bindings-derive-eq"]
bindings-derive-copy = ["pd/bindings-derive-copy"]
bindings-derive-debug = ["pd/bindings-derive-debug"]
bindings-derive-hash = ["pd/bindings-derive-hash"]
bindings-derive-ord = ["pd/bindings-derive-ord"]
bindings-derive-partialeq = ["pd/bindings-derive-partialeq"]
bindings-derive-partialord = ["pd/bindings-derive-partialord"]
bindings-derive-constparamty = ["pd/bindings-derive-constparamty"]
bindings-documentation = ["pd/bindings-documentation"]


[dependencies.pd]
default = ["sys/default"]
lang-items = ["sys/lang-items"]
allocator = ["sys/allocator"]
panic-handler = ["sys/panic-handler"]
eh-personality = ["sys/eh-personality"]
entry-point = ["sys/entry-point"]
error-ctx = ["sys/error-ctx"]
bindgen-runtime = ["sys/bindgen-runtime"]
bindgen-static = ["sys/bindgen-static"]
bindings-derive-default = ["sys/bindings-derive-default"]
bindings-derive-eq = ["sys/bindings-derive-eq"]
bindings-derive-copy = ["sys/bindings-derive-copy"]
bindings-derive-debug = ["sys/bindings-derive-debug"]
bindings-derive-hash = ["sys/bindings-derive-hash"]
bindings-derive-ord = ["sys/bindings-derive-ord"]
bindings-derive-partialeq = ["sys/bindings-derive-partialeq"]
bindings-derive-partialord = ["sys/bindings-derive-partialord"]
bindings-derive-constparamty = ["sys/bindings-derive-constparamty"]
bindings-documentation = ["sys/bindings-documentation"]


[dependencies.sys]
path = "../sys"
version = "0.1"
package = "playdate-sys"
default-features = false

Expand Down
Loading

0 comments on commit 8e3a9b2

Please sign in to comment.