Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve sim ctrl: async-std support #265

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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