Skip to content

Commit

Permalink
Api features refactoring to prevent lang-items duplication (#139)
Browse files Browse the repository at this point in the history
* api features refactor to prevent lang-items duplication

* fix tests
  • Loading branch information
boozook authored Sep 29, 2023
1 parent e6c1ae8 commit cd633e3
Show file tree
Hide file tree
Showing 32 changed files with 324 additions and 504 deletions.
73 changes: 40 additions & 33 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ env:
CARGO_PLAYDATE_LOG: trace
# crates lists:
API_CRATES: >-
-p=playdate-sys
-p=playdate-fs
-p=playdate-sound
-p=playdate-color
Expand All @@ -30,6 +29,11 @@ env:
jobs:
api:
name: API
env:
FEATURES_1: bindgen-runtime
FEATURES_2: bindgen-runtime,bindings-derive-debug
FEATURES_3: bindgen-runtime,bindings-derive-debug,sys/bindings-documentation,sys/error-ctx
BUILD_STD_ARGS: -Zbuild-std=core,alloc --target=thumbv7em-none-eabihf
defaults:
run:
shell: bash
Expand Down Expand Up @@ -90,33 +94,32 @@ jobs:
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version

- name: Test Crates
- name: Test Sys (host)
run: |
FEATURES_1=bindgen-runtime
FEATURES_2=bindgen-runtime,bindings-derive-debug,bindings-documentation,error-ctx
cargo test -p=playdate-sys --features=lang-items -- --nocapture
cargo test -p=playdate-sys --features=lang-items,$FEATURES_1
cargo test -p=playdate-sys --features=lang-items,$FEATURES_2
cargo test -p=playdate-sys --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-sys --features=$FEATURES_2 -- --nocapture
- name: Build Sys (device)
run: |
cargo build -p=playdate-sys ${{ env.BUILD_STD_ARGS }}
cargo build -p=playdate-sys --features=lang-items,$FEATURES_1 ${{ env.BUILD_STD_ARGS }} --examples
cargo build -p=playdate-sys --features=lang-items,$FEATURES_2 ${{ env.BUILD_STD_ARGS }} --examples
- name: Test Crates (host)
run: |
cargo test ${{ env.API_CRATES }} --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test ${{ env.API_CRATES }} --lib --no-default-features --features=$FEATURES_2 -- --nocapture
cargo test ${{ env.API_CRATES }} --lib --no-default-features --features=$FEATURES_2
# cargo test ${{ env.API_CRATES }} --lib --no-default-features --features=$FEATURES_3
- name: Check device target
run: |
# should we check with -Zbuild-std ?
cargo check ${{ env.API_CRATES }} --target=thumbv7em-none-eabihf
- name: Check Crates (device)
run: cargo check ${{ env.API_CRATES }} --target=thumbv7em-none-eabihf

- name: Examples
- name: Build Crates (device)
run: |
FEATURES=bindgen-runtime,bindings-derive-debug
# TODO: use ${{ env.API_CRATES }} when all crates will have example
cargo build --target=thumbv7em-none-eabihf -p=playdate-fs --examples --features=$FEATURES -Zbuild-std
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
cargo build ${{ env.API_CRATES }} --features=sys/lang-items,$FEATURES_1 ${{ env.BUILD_STD_ARGS }} --examples --lib
cargo build ${{ env.API_CRATES }} --features=sys/lang-items,$FEATURES_2 ${{ env.BUILD_STD_ARGS }} --examples --lib
cargo build ${{ env.API_CRATES }} --features=sys/lang-items,$FEATURES_3 ${{ env.BUILD_STD_ARGS }} --examples --lib
# Imitate docs.rs environment
- name: Test in no-sdk environment
Expand All @@ -125,7 +128,7 @@ jobs:
PLAYDATE_SDK_PATH: 0
IGNORE_EXISTING_PLAYDATE_SDK: 1
run: |
cargo doc -p=playdate-sys -v --target=thumbv7em-none-eabihf --features=bindings-documentation,bindings-derive-default,bindings-derive-eq,bindings-derive-copy,bindings-derive-debug,bindings-derive-hash,bindings-derive-ord,bindings-derive-partialeq,bindings-derive-partialord
cargo doc -p=playdate-sys --target=thumbv7em-none-eabihf --features=bindings-documentation,bindings-derive-default,bindings-derive-eq,bindings-derive-copy,bindings-derive-debug,bindings-derive-hash,bindings-derive-ord,bindings-derive-partialeq,bindings-derive-partialord
utils:
name: Utils
Expand Down Expand Up @@ -268,13 +271,14 @@ jobs:
cargo test -p=cargo-playdate -- --nocapture
rm -rf ./target/tmp
# This test is flickering on CI 🤷🏻‍♂️
# This test is flickering on GH CI 🤷🏻‍♂️
- name: Execution
if: runner.os == 'macOS' && contains(github.event.head_commit.message, 'execution')
env:
RUSTFLAGS: --cfg exec_tests
run: |
cargo test -p=cargo-playdate run -- --nocapture --test-threads=1
sudo killall "Playdate Simulator" || true
rm -rf ./target/tmp
use-tool:
Expand Down Expand Up @@ -349,16 +353,19 @@ jobs:

- name: Examples
run: |
FEATURES=bindgen-runtime,bindings-derive-debug
# TODO: use ${{ env.API_CRATES }} when all crates will have example
cargo playdate package --simulator --device -p=playdate-sys --examples --features=$FEATURES
cargo playdate package --simulator --device -p=playdate-fs --examples --features=$FEATURES
cargo playdate package --simulator --device -p=playdate-controls --examples --features=$FEATURES
cargo playdate package --simulator --device -p=playdate-color --examples --features=$FEATURES
cargo playdate package --simulator --device -p=playdate-sound --examples --features=$FEATURES
cargo playdate package --simulator --device -p=playdate-menu --examples --features=$FEATURES
cargo playdate package --simulator --device -p=playdate-graphics --examples --features=$FEATURES
cargo playdate package --features=lang-items --examples --device --simulator -p=playdate-sys
cargo playdate package --features=sys/lang-items --examples --device --simulator -p=playdate-color
cargo playdate package --features=sys/lang-items --examples --device --simulator -p=playdate-controls
cargo playdate package --features=sys/lang-items --examples --device --simulator -p=playdate-display
cargo playdate package --features=sys/lang-items --examples --device --simulator -p=playdate-fs
cargo playdate package --features=sys/lang-items --examples --device --simulator -p=playdate-graphics
cargo playdate package --features=sys/lang-items --examples --device --simulator -p=playdate-menu
cargo playdate package --features=sys/lang-items --example=fp --device --simulator -p=playdate-sound
cargo playdate package --features=sys/lang-items,sys/entry-point --example=sp --device --simulator -p=playdate-sound
cargo playdate package --features=sys/lang-items --examples --device --simulator -p=playdate-sprite
cargo playdate package --features=sys/lang-items --examples --device --simulator -p=playdate-system
cargo playdate package --features=lang-items --examples --device --simulator -p=playdate
# TODO: build crankstart with examples for compatibility test

Expand Down
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ repository = "https://github.com/boozook/playdate.git"


[workspace.dependencies]
color = { version = "0.1", path = "api/color", package = "playdate-color", default-features = false }
ctrl = { version = "0.1", path = "api/ctrl", package = "playdate-controls", default-features = false }
color = { version = "0.2", path = "api/color", package = "playdate-color", default-features = false }
ctrl = { version = "0.2", path = "api/ctrl", package = "playdate-controls", default-features = false }
display = { version = "0.3", path = "api/display", package = "playdate-display", default-features = false }
fs = { version = "0.2", path = "api/fs", package = "playdate-fs", default-features = false }
gfx = { version = "0.3", path = "api/gfx", package = "playdate-graphics", default-features = false }
menu = { version = "0.1", path = "api/menu", package = "playdate-menu", default-features = false }
menu = { version = "0.2", path = "api/menu", package = "playdate-menu", default-features = false }
sound = { version = "0.2", path = "api/sound", package = "playdate-sound", default-features = false }
sprite = { version = "0.1", path = "api/sprite", package = "playdate-sprite", default-features = false }
sprite = { version = "0.2", path = "api/sprite", package = "playdate-sprite", default-features = false }
system = { version = "0.3", path = "api/system", package = "playdate-system", default-features = false }
sys = { version = "0.2", path = "api/sys", package = "playdate-sys", default-features = false }

Expand Down
35 changes: 12 additions & 23 deletions api/color/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "playdate-color"
version = "0.1.3"
version = "0.2.0"
readme = "README.md"
description = "High-level color API built on-top of Playdate API"
description = "Color extension for Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
categories = ["game-development", "api-bindings", "graphics", "no-std"]
edition.workspace = true
Expand All @@ -14,23 +14,12 @@ repository.workspace = true

[features]
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"]

# playdate-sys features, should be shared because it's build configuration:

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]
Expand All @@ -41,14 +30,14 @@ default-features = false
[package.metadata.docs.rs]
all-features = false
features = [
"bindings-derive-default",
"bindings-derive-eq",
"bindings-derive-copy",
"sys/bindings-derive-default",
"sys/bindings-derive-eq",
"sys/bindings-derive-copy",
"bindings-derive-debug",
"bindings-derive-hash",
"bindings-derive-ord",
"bindings-derive-partialeq",
"bindings-derive-partialord",
"sys/bindings-derive-hash",
"sys/bindings-derive-ord",
"sys/bindings-derive-partialeq",
"sys/bindings-derive-partialord",
]
rustdoc-args = ["--cfg", "docsrs", "--show-type-layout"]
default-target = "thumbv7em-none-eabihf"
Expand Down
Loading

0 comments on commit cd633e3

Please sign in to comment.