Skip to content

Commit

Permalink
Merge pull request #265 from boozook/sim-ctrl-async-std
Browse files Browse the repository at this point in the history
Improve sim ctrl: async-std support
  • Loading branch information
github-actions[bot] authored Apr 3, 2024
2 parents d97535d + 6860158 commit a88b1a0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 36 deletions.
53 changes: 27 additions & 26 deletions Cargo.lock

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

7 changes: 2 additions & 5 deletions cargo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-playdate"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.3"
readme = "README.md"
description = "Build tool for neat yellow console."
keywords = ["playdate", "build", "cargo", "plugin", "cargo-subcommand"]
Expand Down Expand Up @@ -66,6 +66,7 @@ features = ["clap", "tokio", "async-std", "tokio-serial"]

[dependencies.simulator]
workspace = true
features = ["async-std"]

[dependencies.clap]
workspace = true
Expand All @@ -92,7 +93,3 @@ rand = "0.8"

[target.'cfg(unix)'.dev-dependencies]
nix = { version = "0.28", features = ["signal"] }


[features]
default = []
11 changes: 10 additions & 1 deletion support/sim-ctrl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-simulator-utils"
version = "0.1.0"
version = "0.1.1"
readme = "README.md"
description = "Cross-platform utils to deal with Playdate Simulator."
keywords = ["playdate", "sdk", "utils"]
Expand All @@ -26,3 +26,12 @@ features = ["process"]
default-features = false
workspace = true
optional = true

[dependencies.async-std]
features = ["futures-lite", "unstable", "default"]
workspace = true
optional = true


[features]
tokio = ["dep:tokio", "async-std?/tokio1"]
13 changes: 9 additions & 4 deletions support/sim-ctrl/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ use utils::toolchain::sdk::Sdk;

#[cfg_attr(feature = "tracing", tracing::instrument)]
pub async fn run(pdx: &Path, sdk: Option<&Path>) -> Result<(), Error> {
#[cfg(all(feature = "tokio", not(feature = "async-std")))]
use tokio::process::Command;
#[cfg(feature = "async-std")]
use async_std::process::Command;

#[allow(unused_mut)]
let mut cmd = command(&pdx, sdk.as_deref())?;
#[cfg(feature = "tokio")]
let mut cmd = tokio::process::Command::from(cmd);
#[cfg(any(feature = "tokio", feature = "async-std"))]
let mut cmd = Command::from(cmd);

trace!("executing: {cmd:?}");

#[cfg(feature = "tokio")]
#[cfg(any(feature = "tokio", feature = "async-std"))]
cmd.status().await?.exit_ok()?;
#[cfg(not(feature = "tokio"))]
#[cfg(all(not(feature = "tokio"), not(feature = "async-std")))]
cmd.status()?.exit_ok()?;

Ok(())
Expand Down

0 comments on commit a88b1a0

Please sign in to comment.