Skip to content

Commit

Permalink
Merge pull request #157 from boozook/api/sys-build-time
Browse files Browse the repository at this point in the history
Significantly reduce playdate-sys build time
  • Loading branch information
boozook authored Oct 5, 2023
2 parents 5b9b3f5 + 5c2d42b commit 7a21d1d
Show file tree
Hide file tree
Showing 60 changed files with 903 additions and 290,193 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,11 @@ jobs:
# TODO: check & stop if there's no changes or mb. save SDK version cached

- name: Host
run: |
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" -vv
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --release
run: cargo build -p=playdate-sys --features="${{ matrix.features.v }}" -vv

- name: Device
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --target=thumbv7em-none-eabihf
cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --target=thumbv7em-none-eabihf --release
run: cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --target=thumbv7em-none-eabihf

- name: Format
run: rustfmt api/sys/gen/*.rs
Expand Down
47 changes: 34 additions & 13 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"support/*",
# "components/*"
]
default-members = ["cargo", "support/tool"]
default-members = ["cargo", "support/tool", "support/bindgen"]
exclude = ["cargo/tests/crates/**/*"]


Expand All @@ -31,10 +31,11 @@ sprite = { version = "0.2", path = "api/sprite", package = "playdate-sprite", de
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 }

tool = { version = "0.1", path = "support/tool", package = "playdate-tool" }
build = { version = "0.2", path = "support/build", package = "playdate-build", default-features = false }
utils = { version = "0.1", path = "support/utils", package = "playdate-build-utils", default-features = false }
bindgen = { version = "0.1", path = "support/bindgen", package = "playdate-bindgen", default-features = false }
tool = { version = "0.1", path = "support/tool", package = "playdate-tool" }
bindgen-cfg = { version = "0.1", path = "support/bindgen-cfg", package = "playdate-bindgen-cfg", default-features = false }

# Deps that used multiple times,
# This is to prevent various versions in the deps-tree for faster compilation time
Expand All @@ -44,7 +45,7 @@ semver = "1.0"
regex = "1"
log = "0.4"
env_logger = "0.10"
clap = "4.3"
clap = "4.4"
serde = "1.0"
serde_json = "1.0"
toml = "0.7"
toml = "0.8"
19 changes: 9 additions & 10 deletions api/sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-sys"
version = "0.2.5"
version = "0.2.6"
build = "src/build.rs"
readme = "README.md"
description = "Low-level Playdate API bindings"
Expand Down Expand Up @@ -31,11 +31,11 @@ try-trait-v2 = [] # impl `FromResidual` for `EventLoopCtrl`
error-ctx = [] # errors with context (incomplete feature)


bindgen-runtime = ["bindgen", "bindgen/runtime"] # runtime linking (dlopen)
bindgen-static = ["bindgen", "bindgen/static"] # static linking to clang
bindgen-logging = ["bindgen/logging"]
bindgen-pretty-please = ["bindgen/pretty-please"]
bindgen-which-rustfmt = ["bindgen/which-rustfmt"]
bindgen-runtime = ["bindgen/runtime"] # runtime linking (dlopen)
bindgen-static = ["bindgen/static"] # static linking to clang
# parse docs from the SDK, gen doc-comments
bindings-documentation = ["bindgen/documentation"] # generate docs for bindings

Expand All @@ -53,16 +53,15 @@ bindings-derive-constparamty = [] # derive `ConstParamTy`


[dependencies]
arrayvec = { version = "0.7.4", default-features = false, optional = true }
arrayvec = { version = "0.7", default-features = false, optional = true }


[build-dependencies]
semver.workspace = true

# TODO: make bindgen optional:
# if no bindgen => use pre-built or find installed bindgen and call
[build-dependencies.bindgen]
# optional = true
optional = true
workspace = true
default-features = false

[build-dependencies.bindgen-cfg]
workspace = true
default-features = false

Expand Down
26 changes: 12 additions & 14 deletions api/sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ To prevent this behavior to use only _pre-built_ bindings set env var `IGNORE_EX

There's `bindgen` used to generate bindings, and some features are re-exported:

- use `bindgen-runtime` to on/off bindgen uses runtime linking (dlopen) with libclang. [More in bindgen docs][bindgen-clang].
- use `bindgen-runtime` to on/off bindgen uses runtime linking (dlopen) with libclang.
Same for `bindgen-static`.
[More in bindgen docs][bindgen-clang].
- use features like `bindings-derive-{name}` to ask bindgen to derive `{name}` to all entities if it possible
- <details><summary>full list of derive- features</summary>

Expand Down Expand Up @@ -247,22 +249,22 @@ You can add functionality that based on this package. Just create a new your oun

I must repeat myself, I apologize for intruding.

⚠️ If you want to create a library that based on this library, please __share all features of this package__
to allow everyone to properly configure entire dependency tree.
⚠️ If you want to create a library that based on this library, please __share following features of this package__
to allow everyone to properly configure entire dependency tree:
- `bindgen-runtime`
- `bindgen-static`

_This makes kind of paramount importance if a user is using several of these extensions and it can be a mess if they dictate different configurations for this package._

- `cargo new name-of-your-extension`
- `cargo add playdate-sys`
- copy & paste all features from Cargo.toml of this package into your Cargo.toml like this:
- copy & paste all features mentioned above into your Cargo.toml like this:
```toml
[features]
default = ["playdate-sys/default"]
lang-items = ["playdate-sys/lang-items"]
allocator = ["playdate-sys/allocator"]
bindgen-runtime = ["playdate-sys/bindgen-runtime"]
bindgen-static = ["playdate-sys/bindgen-static"]
bindings-derive-debug = ["playdate-sys/bindings-derive-debug"]
bindings-derive-default = ["playdate-sys/bindings-derive-default"]
...
```

For example see existing crates in the [repo/api][repo-api].
Expand Down Expand Up @@ -291,15 +293,11 @@ DERIVES_DEF=bindings-derive-debug
FEATURES_DEF=--features=bindings-documentation,$DERIVES_DEF
FEATURES_ALL=--features=bindings-documentation,$DERIVES_ALL

cargo build -p=playdate-sys $FEATURES_DEF -vv
cargo build -p=playdate-sys $FEATURES_DEF --release
cargo build -p=playdate-sys $FEATURES_DEF
cargo build -p=playdate-sys $FEATURES_DEF --target=thumbv7em-none-eabihf
cargo build -p=playdate-sys $FEATURES_DEF --target=thumbv7em-none-eabihf --release

cargo build -p=playdate-sys $FEATURES_ALL -vv
cargo build -p=playdate-sys $FEATURES_ALL --release
cargo build -p=playdate-sys $FEATURES_ALL
cargo build -p=playdate-sys $FEATURES_ALL --target=thumbv7em-none-eabihf
cargo build -p=playdate-sys $FEATURES_ALL --target=thumbv7em-none-eabihf --release

# optionally format bindings:
rustfmt ./api/sys/gen/*.rs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<T> ::core::default::Default for __BindgenUnionField<T> {
}
impl<T> ::core::clone::Clone for __BindgenUnionField<T> {
#[inline]
fn clone(&self) -> Self { Self::new() }
fn clone(&self) -> Self { *self }
}
impl<T> ::core::marker::Copy for __BindgenUnionField<T> {}
impl<T> ::core::fmt::Debug for __BindgenUnionField<T> {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<T> ::core::default::Default for __BindgenUnionField<T> {
}
impl<T> ::core::clone::Clone for __BindgenUnionField<T> {
#[inline]
fn clone(&self) -> Self { Self::new() }
fn clone(&self) -> Self { *self }
}
impl<T> ::core::marker::Copy for __BindgenUnionField<T> {}
impl<T> ::core::fmt::Debug for __BindgenUnionField<T> {
Expand Down
File renamed without changes.
Loading

0 comments on commit 7a21d1d

Please sign in to comment.