Skip to content

Commit

Permalink
Merge pull request #294 from boozook/refactoring/support-opts
Browse files Browse the repository at this point in the history
Support crates minor refactoring: optimisations & clean garbage
  • Loading branch information
boozook authored Apr 13, 2024
2 parents 138383d + 094c840 commit 1aac703
Show file tree
Hide file tree
Showing 31 changed files with 293 additions and 282 deletions.
133 changes: 82 additions & 51 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion support/bindgen-cfg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-bindgen-cfg"
version = "0.1.3"
version = "0.1.4"
readme = "README.md"
description = "Minimal configuration for playdate-bindgen."
keywords = ["playdate", "bindings", "ffi", "code-generation"]
Expand Down
8 changes: 3 additions & 5 deletions support/bindgen-cfg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct Runner;

impl Runner {
/// Returns path and version of the `pdbindgen` executable if found.
pub fn find_tool<'t>(cfg: &'t Cfg) -> Option<(&'t Path, String)> {
pub fn find_tool(cfg: &Cfg) -> Option<(&Path, String)> {
Command::new(&cfg.bin).arg("-V")
.stdout(Stdio::piped())
.stderr(Stdio::inherit())
Expand Down Expand Up @@ -103,11 +103,10 @@ impl Runner {
});

// Easiest way to get existing SDK version:
let sdk_version = path.map(|path| {
let sdk_version = path.and_then(|path| {
std::fs::read_to_string(path.join("VERSION.txt")).ok()
.map(|s| s.trim().to_string())
})
.flatten()
.filter(|s| !s.is_empty());

// Alternative way is to execute the tool:
Expand Down Expand Up @@ -385,11 +384,10 @@ impl Target {
if var("TARGET")? == "thumbv7em-none-eabihf" {
Ok(Self::Playdate)
} else {
use core::mem::size_of;
use core::ffi::c_int;
let ptr = var("CARGO_CFG_TARGET_POINTER_WIDTH")?;
Ok(Self::Other { ptr,
c_int: size_of::<c_int>() * 8 })
c_int: c_int::BITS as usize })
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion support/bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-bindgen"
version = "0.1.7"
version = "0.1.8"
readme = "README.md"
description = "Bindgen configuration for Playdate API and utils."
keywords = ["playdate", "bindings", "ffi", "code-generation"]
Expand Down
Loading

0 comments on commit 1aac703

Please sign in to comment.