Skip to content

Commit

Permalink
Update deps and toolchain (#446)
Browse files Browse the repository at this point in the history
* update toolchain

* update `extract_if` usage in `cargo-playdate` crate

* fix wrong cast (i8 / u8 instead of char)

* fix codemagic.yaml (rem)

* update deps (minors via cargo lock only)

* update playdate-bindgen's deps

* rem deprecated rustfmt option

* fmt and minor bump changed crates
  • Loading branch information
boozook authored Jan 29, 2025
1 parent 48d3909 commit e5e3639
Show file tree
Hide file tree
Showing 19 changed files with 1,153 additions and 1,028 deletions.
1,985 changes: 1,097 additions & 888 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-sys"
version = "0.4.8"
version = "0.4.9"
build = "src/build.rs"
readme = "README.md"
description = "Low-level Playdate API bindings"
Expand Down
9 changes: 5 additions & 4 deletions api/sys/src/sys/proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ pub fn error<S: AsRef<str>>(text: S) -> ! {
if let Some(f) = unsafe { (*(*crate::sys::API).system).error } {
// Casting fn->void to fn->!
// This ugly cast is safe because of `!` is a magic compile-time marker, not a type.
let f: unsafe extern "C" fn(*const i8, ...) = f;
let p = core::ptr::addr_of!(f) as *const _ as *const unsafe extern "C" fn(*const i8, ...) -> !;
let f: unsafe extern "C" fn(*const core::ffi::c_char, ...) = f;
let p =
core::ptr::addr_of!(f) as *const _ as *const unsafe extern "C" fn(*const core::ffi::c_char, ...) -> !;
let f = unsafe { p.as_ref() }.unwrap();

if let Ok(s) = alloc::ffi::CString::new(text.as_ref()) {
unsafe { f(s.as_ptr() as *mut core::ffi::c_char) }
unsafe { f(s.as_ptr() as _) }
} else {
unsafe { f(text.as_ref().as_ptr() as *mut core::ffi::c_char) }
unsafe { f(text.as_ref().as_ptr() as _) }
}
} else {
// In case of `crate::sys::API` is missed (doesn't set) just abort the process.
Expand Down
2 changes: 1 addition & 1 deletion cargo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-playdate"
version = "0.5.5"
version = "0.5.6"
readme = "README.md"
description = "Build tool for neat yellow console."
keywords = ["playdate", "build", "cargo", "plugin", "cargo-subcommand"]
Expand Down
6 changes: 3 additions & 3 deletions cargo/src/assets/pdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ fn build_in(config: &Config, package_id: &PackageId, src: &Path, build: &Path, r

// remove temp files before possible failure:
fs_extra::remove_items(&[
src.join("pdex.bin"),
build.join("pdex.bin"),
build.join("pdxinfo"),
src.join("pdex.bin"),
build.join("pdex.bin"),
build.join("pdxinfo"),
])?;
status.exit_ok()?;
Ok(())
Expand Down
32 changes: 17 additions & 15 deletions cargo/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub fn build(cfg: &Config, tree: &MetaDeps) -> CargoResult<Vec<BuildProduct>> {

let mut targets_cache = HashMap::new();

artifacts.extract_if(|(art, roots)| {
artifacts.extract_if(.., |(art, roots)| {
let executable = art.executable.is_some();
let need_remove_roots = roots.len() > 1;

Expand All @@ -209,7 +209,7 @@ pub fn build(cfg: &Config, tree: &MetaDeps) -> CargoResult<Vec<BuildProduct>> {

let mut crate_types_cache = BTreeMap::new();

let removed = roots.extract_if(|root| {
let removed = roots.extract_if(.., |root| {
let tk = root.node().target().kind();
let ck = root.node().unit().platform;

Expand Down Expand Up @@ -292,7 +292,7 @@ pub fn build(cfg: &Config, tree: &MetaDeps) -> CargoResult<Vec<BuildProduct>> {
.export_dir
.clone()
.unwrap_or_else(|| cfg.workspace.target_dir().into_path_unlocked());
artifacts.extract_if(|(art, roots)| {
artifacts.extract_if(.., |(art, roots)| {
let various_ck: Vec<_> = {
let mut ck: Vec<_> = roots.iter().map(|r| &r.node().unit().platform).collect();
ck.sort();
Expand Down Expand Up @@ -341,15 +341,17 @@ pub fn build(cfg: &Config, tree: &MetaDeps) -> CargoResult<Vec<BuildProduct>> {
});

let removed = if let Some(ck) = ck_exact {
roots.extract_if(|root| {
roots.extract_if(.., |root| {
match root.node().unit().platform {
CompileKind::Host => false,
CompileKind::Target(ct) => ct.short_name() != ck,
}
})
.count()
} else if has_host {
roots.extract_if(|root| !matches!(root.node().unit().platform, CompileKind::Host))
roots.extract_if(.., |root| {
!matches!(root.node().unit().platform, CompileKind::Host)
})
.count()
} else {
0
Expand Down Expand Up @@ -798,16 +800,16 @@ fn build_library<Layout, S>(config: &Config,
// TODO: #feature=compat & --with-setup => gcc.arg(setup.c) and -l artifact.path
// TODO: use const `GCC_ARGS_LIB` from support::compile
gcc.args([
"-nostartfiles",
"-mthumb",
"-mcpu=cortex-m7",
"-mfloat-abi=hard",
"-mfpu=fpv5-sp-d16",
"-D__FPU_USED=1",
"-Wl,--cref,--gc-sections,--no-warn-mismatch,--emit-relocs",
"-fno-exceptions",
"-mword-relocations",
"-fno-common",
"-nostartfiles",
"-mthumb",
"-mcpu=cortex-m7",
"-mfloat-abi=hard",
"-mfpu=fpv5-sp-d16",
"-D__FPU_USED=1",
"-Wl,--cref,--gc-sections,--no-warn-mismatch,--emit-relocs",
"-fno-exceptions",
"-mword-relocations",
"-fno-common",
]);
gcc.arg(&link_map);
if let Some(d) = d {
Expand Down
4 changes: 2 additions & 2 deletions cargo/src/build/rustflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ impl Rustflags {
for target in [&device_target, &config.host_target] {
if let Some(existing) = existing.get(&target) {
if let Some(flags) = flags.get_mut(&CompileKind::Target(*target)) {
drained.extend(flags.extract_if(|flag| {
drained.extend(flags.extract_if(.., |flag| {
existing.val
.as_slice()
.iter()
.any(|f| f.as_str() == flag.as_ref())
}));
if existing.val.as_slice().iter().any(|f| f.contains("target-cpu")) {
drained.extend(flags.extract_if(|flag| flag.starts_with("-Ctarget-cpu=")));
drained.extend(flags.extract_if(.., |flag| flag.starts_with("-Ctarget-cpu=")));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cargo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn execute(config: &Config) -> CargoResult<()> {
let mut expected = config.possible_targets_ext()?;
expected.iter_mut().for_each(|(_, targets)| {
let dropped =
targets.extract_if(|target| {
targets.extract_if(.., |target| {
let cts = target.rustc_crate_types();
!if ck.is_playdate() {
cts.contains(&CrateType::Bin) ||
Expand Down Expand Up @@ -143,7 +143,7 @@ fn execute(config: &Config) -> CargoResult<()> {
}
});

expected.extract_if(|(_, targets)| targets.is_empty()).count();
expected.extract_if(.., |(_, targets)| targets.is_empty()).count();
if expected.is_empty() {
bail!("Nothing found to run");
}
Expand All @@ -155,7 +155,7 @@ fn execute(config: &Config) -> CargoResult<()> {
let mut products = build::build(config, &deps_tree)?;

// filter products with expected:
products.extract_if(|product| {
products.extract_if(.., |product| {
match product {
build::BuildProduct::Success { package_id,
name,
Expand Down
4 changes: 2 additions & 2 deletions cargo/src/utils/cargo/meta_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl<'t> MetaDeps<'t> {
// - units without pd-meta
// - units without assets in the pd-meta
// - remove units with id eq root's
let removed = deps.extract_if(|n| {
let removed = deps.extract_if(.., |n| {
n.package_id() == root.package_id() ||
n.meta
.and_then(|m| m.metadata.as_ref())
Expand All @@ -282,7 +282,7 @@ impl<'t> MetaDeps<'t> {
acc.entry(n.package_id()).and_modify(|v| *v += 1).or_insert(0);
acc
});
let removed = deps.extract_if(move |n| {
let removed = deps.extract_if(.., move |n| {
let v = dups[n.package_id()];
if v > 0 {
dups.insert(n.package_id(), v - 1);
Expand Down
79 changes: 0 additions & 79 deletions codemagic.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2024-09-07"
channel = "nightly-2025-01-28"
profile = "minimal"
targets = ["thumbv7em-none-eabihf"]
components = [
Expand Down
4 changes: 2 additions & 2 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version = "Two"
unstable_features = true
edition = "2018"
edition = "2024"
style_edition = "2024"


max_width = 114
Expand Down
8 changes: 4 additions & 4 deletions 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.11"
version = "0.1.12"
readme = "README.md"
description = "Bindgen configuration for Playdate API and utils."
keywords = ["playdate", "bindings", "ffi", "code-generation"]
Expand All @@ -16,9 +16,9 @@ repository.workspace = true
semver.workspace = true

# parser:
html2md = { version = "0.2.14", optional = true }
html5ever = { version = "0.26.0", optional = true }
markup5ever_rcdom = { version = "0.2.0", optional = true }
html2md = { version = "0.2.15", optional = true }
html5ever = { version = "0.27.0", optional = true }
markup5ever_rcdom = { version = "0.3.0", optional = true }
# doc-gen:
proc-macro2 = { version = "1.0", optional = true }
syn = { version = "2.0", optional = true } # +full, extra-traits, visit-mut
Expand Down
1 change: 1 addition & 0 deletions support/bindgen/src/gen/docs/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::DocsMap;


pub fn engage(bindings: &mut syn::File, root: &str, docs: &DocsMap) -> Result<()> {
// TODO: preserve bindings.attrs
let items = Cell::from_mut(&mut bindings.items[..]);
let items_cells = items.as_slice_of_cells();
if let Some(root) = find_struct(items_cells, root) {
Expand Down
2 changes: 1 addition & 1 deletion support/build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-build"
version = "0.4.0"
version = "0.4.1"
readme = "README.md"
description = "Utils that help to build package for Playdate"
keywords = ["playdate", "package", "encoding", "manifest", "assets"]
Expand Down
4 changes: 2 additions & 2 deletions support/build/src/assets/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn build_plan<'l, 'r, S>(env: &Env,
debug!("Possible ManyInto, resolved: {}", resolved.len());

// filter resolved includes:
let _excluded: Vec<_> = resolved.extract_if(|inc| {
let _excluded: Vec<_> = resolved.extract_if(.., |inc| {
let path = key.join(inc.target());
glob_matches_any(&path, &exclude_globs)
})
Expand Down Expand Up @@ -169,7 +169,7 @@ pub fn build_plan<'l, 'r, S>(env: &Env,

// filter resolved includes:
let is_not_empty = |inc: &Match| !inc.target().as_os_str().is_empty();
let excluded: Vec<_> = resolved.extract_if(|inc| {
let excluded: Vec<_> = resolved.extract_if(.., |inc| {
let target = target.join(inc.target());
!is_not_empty(inc) ||
glob_matches_any(&inc.source(), &exclude_globs) ||
Expand Down
21 changes: 6 additions & 15 deletions support/build/src/metadata/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,23 +1030,17 @@ mod tests {
assert!(!AssetsOptions::default_dependencies());
let src = r#" [assets] "#;
let m = toml::from_str::<Options>(src).unwrap();
assert_matches!(
m.assets,
AssetsOptions { dependencies: None,
.. }
);
assert_matches!(m.assets, AssetsOptions { dependencies: None,
.. });

// overrides default
let src = r#"
[assets]
dependencies = true
"#;
let m = toml::from_str::<Options>(src).unwrap();
assert_matches!(
m.assets,
AssetsOptions { dependencies: Some(true),
.. }
);
assert_matches!(m.assets, AssetsOptions { dependencies: Some(true),
.. });
}

#[test]
Expand Down Expand Up @@ -1157,11 +1151,8 @@ mod tests {
"#;
let m = toml::from_str::<MetadataInner>(src).unwrap();
assert!(m.assets.is_empty());
assert_matches!(
m.options.assets,
AssetsOptions { dependencies: Some(true),
.. }
);
assert_matches!(m.options.assets, AssetsOptions { dependencies: Some(true),
.. });
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion support/utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-build-utils"
version = "0.3.5"
version = "0.3.6"
readme = "README.md"
description = "Utils that help to build program with Rust and Playdate API"
keywords = ["playdate", "utility"]
Expand Down
Loading

0 comments on commit e5e3639

Please sign in to comment.