From db91c35360ad2e0ded011dd5c9a3e3c655aac678 Mon Sep 17 00:00:00 2001 From: Alexander Koz <888526+boozook@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:52:13 +0100 Subject: [PATCH] Fix `cargo-playdate run`, add async-std reactor support (#260) add async-std reactor support, fix `cargo-playdate run` --- Cargo.lock | 464 +++++++++++++++++++++++++-- Cargo.toml | 3 +- cargo/Cargo.toml | 5 +- support/device/Cargo.toml | 22 +- support/device/src/device/methods.rs | 9 +- support/device/src/install.rs | 9 +- support/device/src/mount/linux.rs | 6 +- support/device/src/mount/mac.rs | 16 +- support/device/src/mount/methods.rs | 12 + support/device/src/mount/win.rs | 6 +- support/tool/Cargo.toml | 4 +- 11 files changed, 508 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 94fea4c8..02841c43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -131,6 +131,181 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" +dependencies = [ + "concurrent-queue", + "event-listener 5.2.0", + "event-listener-strategy 0.5.1", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10b3e585719c2358d2660232671ca8ca4ddb4be4ce8a1842d6c2dc8685303316" +dependencies = [ + "async-lock 3.3.0", + "async-task", + "concurrent-queue", + "fastrand 2.0.2", + "futures-lite 2.3.0", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.2.0", + "async-executor", + "async-io 2.3.2", + "async-lock 3.3.0", + "blocking", + "futures-lite 2.3.0", + "once_cell", + "tokio", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884" +dependencies = [ + "async-lock 3.3.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.3.0", + "parking", + "polling 3.6.0", + "rustix 0.38.32", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +dependencies = [ + "event-listener 4.0.3", + "event-listener-strategy 0.4.0", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" +dependencies = [ + "async-io 1.13.0", + "async-lock 2.8.0", + "async-signal", + "blocking", + "cfg-if", + "event-listener 3.1.0", + "futures-lite 1.13.0", + "rustix 0.38.32", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-signal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" +dependencies = [ + "async-io 2.3.2", + "async-lock 2.8.0", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 0.38.32", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-channel 1.9.0", + "async-global-executor", + "async-io 1.13.0", + "async-lock 2.8.0", + "async-process", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite 1.13.0", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -153,6 +328,12 @@ dependencies = [ "syn 2.0.57", ] +[[package]] +name = "async-task" +version = "4.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" + [[package]] name = "async-trait" version = "0.1.79" @@ -316,6 +497,22 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +dependencies = [ + "async-channel 2.2.0", + "async-lock 3.3.0", + "async-task", + "fastrand 2.0.2", + "futures-io", + "futures-lite 2.3.0", + "piper", + "tracing", +] + [[package]] name = "bstr" version = "1.9.1" @@ -513,7 +710,7 @@ dependencies = [ [[package]] name = "cargo-playdate" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" dependencies = [ "anstyle", "anyhow", @@ -527,7 +724,7 @@ dependencies = [ "dirs", "env_logger", "fs_extra", - "futures-lite", + "futures-lite 2.3.0", "log", "nix 0.28.0", "once_cell", @@ -730,6 +927,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "concurrent-queue" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console-api" version = "0.6.0" @@ -943,7 +1149,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "socket2", + "socket2 0.5.6", "windows-sys 0.52.0", ] @@ -965,9 +1171,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "pem-rfc7468", @@ -1142,6 +1348,65 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.3", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" +dependencies = [ + "event-listener 5.2.0", + "pin-project-lite", +] + [[package]] name = "fallible-iterator" version = "0.3.0" @@ -1160,6 +1425,15 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + [[package]] name = "fastrand" version = "2.0.2" @@ -1284,13 +1558,28 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + [[package]] name = "futures-lite" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand", + "fastrand 2.0.2", "futures-core", "futures-io", "parking", @@ -1731,7 +2020,7 @@ dependencies = [ "itoa", "libc", "memmap2", - "rustix", + "rustix 0.38.32", "smallvec", "thiserror", ] @@ -1893,7 +2182,7 @@ dependencies = [ "gix-command", "gix-config-value", "parking_lot 0.12.1", - "rustix", + "rustix 0.38.32", "thiserror", ] @@ -2093,7 +2382,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0066432d4c277f9877f091279a597ea5331f68ca410efc874f0bdfb1cd348f92" dependencies = [ - "fastrand", + "fastrand 2.0.2", "unicode-normalization", ] @@ -2144,6 +2433,18 @@ dependencies = [ "regex-syntax 0.8.3", ] +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "group" version = "0.13.0" @@ -2357,7 +2658,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.5.6", "tokio", "tower-service", "tracing", @@ -2563,6 +2864,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + [[package]] name = "lazy-regex" version = "3.1.0" @@ -2728,6 +3038,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd1bc4d24ad230d21fb898d1116b1801d7adfc449d42026475862ab48b11e70e" +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -2749,6 +3065,9 @@ name = "log" version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +dependencies = [ + "value-bag", +] [[package]] name = "mac" @@ -3034,7 +3353,7 @@ dependencies = [ "io-kit-sys", "log", "once_cell", - "rustix", + "rustix 0.38.32", "slab", "windows-sys 0.48.0", ] @@ -3380,6 +3699,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.2", + "futures-io", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -3484,12 +3814,13 @@ dependencies = [ [[package]] name = "playdate-device" -version = "0.1.0" +version = "0.2.0" dependencies = [ + "async-std", "clap", "const-hex", "futures", - "futures-lite", + "futures-lite 2.3.0", "hex", "lfs-core", "log", @@ -3603,13 +3934,13 @@ dependencies = [ [[package]] name = "playdate-tool" -version = "0.2.1" +version = "0.2.2" dependencies = [ "clap", "console-subscriber", "env_logger", "futures", - "futures-lite", + "futures-lite 2.3.0", "log", "miette", "playdate-device", @@ -3649,6 +3980,37 @@ dependencies = [ "time", ] +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 0.38.32", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "pori" version = "0.0.0" @@ -3948,6 +4310,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "rustix" +version = "0.37.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + [[package]] name = "rustix" version = "0.38.32" @@ -3957,7 +4333,7 @@ dependencies = [ "bitflags 2.5.0", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.13", "windows-sys 0.52.0", ] @@ -4264,6 +4640,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "socket2" version = "0.5.6" @@ -4415,8 +4801,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand", - "rustix", + "fastrand 2.0.2", + "rustix 0.38.32", "windows-sys 0.52.0", ] @@ -4437,7 +4823,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix", + "rustix 0.38.32", "windows-sys 0.48.0", ] @@ -4544,7 +4930,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.5.6", "tokio-macros", "tracing", "windows-sys 0.48.0", @@ -4917,6 +5303,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "value-bag" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74797339c3b98616c009c7c3eb53a0ce41e85c8ec66bd3db96ed132d20cfdee8" + [[package]] name = "vcpkg" version = "0.2.15" @@ -4929,6 +5321,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "waker-fn" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" + [[package]] name = "walkdir" version = "2.5.0" @@ -4979,6 +5377,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.92" @@ -5023,6 +5433,16 @@ dependencies = [ "walkdir", ] +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "which" version = "4.4.2" @@ -5032,7 +5452,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix", + "rustix 0.38.32", ] [[package]] @@ -5043,7 +5463,7 @@ checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" dependencies = [ "either", "home", - "rustix", + "rustix 0.38.32", "winsafe", ] diff --git a/Cargo.toml b/Cargo.toml index a153a16c..495bdb2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ sys = { version = "0.3", path = "api/sys", package = "playdate-sys", default-fea 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.2", path = "support/utils", package = "playdate-build-utils", default-features = false } -device = { version = "0.1", path = "support/device", package = "playdate-device" } +device = { version = "0.2", path = "support/device", package = "playdate-device" } simulator = { version = "0.1", path = "support/sim-ctrl", package = "playdate-simulator-utils", default-features = false } bindgen = { version = "0.1", path = "support/bindgen", package = "playdate-bindgen", default-features = false } bindgen-cfg = { version = "0.1", path = "support/bindgen-cfg", package = "playdate-bindgen-cfg", default-features = false } @@ -49,3 +49,4 @@ toml = "0.8" futures-lite = "2.3" thiserror = "1.0" tokio = { version = "1.37", default-features = false } +async-std = { version = "1.12", default-features = false } diff --git a/cargo/Cargo.toml b/cargo/Cargo.toml index dca9ec30..ac5c8c69 100644 --- a/cargo/Cargo.toml +++ b/cargo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-playdate" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" readme = "README.md" description = "Build tool for neat yellow console." keywords = ["playdate", "build", "cargo", "plugin", "cargo-subcommand"] @@ -62,10 +62,9 @@ features = ["assets-report", "toml"] [dependencies.device] workspace = true -features = ["clap", "async", "tokio-serial", "tokio"] +features = ["clap", "tokio", "async-std", "tokio-serial"] [dependencies.simulator] -# features = ["tokio"] workspace = true [dependencies.clap] diff --git a/support/device/Cargo.toml b/support/device/Cargo.toml index 139b06a0..a9884f13 100644 --- a/support/device/Cargo.toml +++ b/support/device/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-device" -version = "0.1.0" +version = "0.2.0" readme = "README.md" description = "Cross-platform interface Playdate device, async & blocking." keywords = ["playdate", "usb", "serial"] @@ -39,6 +39,19 @@ features = ["fs", "process", "time", "io-std"] workspace = true optional = true +[dependencies.async-std] +features = [ + "std", + "log", + "gloo-timers", + "futures-lite", + "pin-project-lite", + "unstable", + "default", +] +workspace = true +optional = true + [dependencies.futures-lite] version = "2.3" @@ -75,6 +88,7 @@ features = [ [features] -default = ["async"] -async = ["futures", "tokio", "tokio-serial"] -tokio-serial = ["dep:tokio-serial", "tokio?/io-util", "tokio?/rt"] +default = ["tokio", "tokio-serial"] +tokio-serial = ["futures", "dep:tokio-serial", "tokio?/io-util", "tokio?/rt"] +tokio = ["futures", "dep:tokio", "async-std?/tokio1"] # use async-std reactor +async-std = ["futures", "dep:async-std"] # use async-std reactor and features diff --git a/support/device/src/device/methods.rs b/support/device/src/device/methods.rs index 6226e005..d0311f7b 100644 --- a/support/device/src/device/methods.rs +++ b/support/device/src/device/methods.rs @@ -1,6 +1,3 @@ -#![cfg(feature = "tokio")] - - use crate::retry::{IterTime, Retries}; use crate::usb::mode::Mode; use crate::error::Error; @@ -30,6 +27,7 @@ pub async fn wait_mode_change(mut dev: Device, to: Mode, retry: Retries(drive: &'dev MountedDevice, path: &Path, force: bool) -> Result> { - #[cfg(feature = "tokio")] + #[cfg(all(feature = "tokio", not(feature = "async-std")))] use tokio::process::Command; - #[cfg(not(feature = "tokio"))] + #[cfg(feature = "async-std")] + use async_std::process::Command; + #[cfg(all(not(feature = "tokio"), not(feature = "async-std")))] use std::process::Command; @@ -87,9 +89,10 @@ pub async fn install<'dev>(drive: &'dev MountedDevice, async { if cfg!(unix) { let mut cmd = Command::new("cp"); + cmd.arg("-r"); if force { - cmd.arg("-r"); + cmd.arg("-f"); } cmd.arg(path); diff --git a/support/device/src/mount/linux.rs b/support/device/src/mount/linux.rs index 8064f0ab..ecd56578 100644 --- a/support/device/src/mount/linux.rs +++ b/support/device/src/mount/linux.rs @@ -99,12 +99,14 @@ mod unmount { } } - #[cfg(feature = "tokio")] impl UnmountAsync for Volume { #[cfg_attr(feature = "tracing", tracing::instrument())] async fn unmount(&self) -> Result<(), Error> { - use tokio::process::Command; use futures_lite::future::ready; + #[cfg(all(feature = "tokio", not(feature = "async-std")))] + use tokio::process::Command; + #[cfg(feature = "async-std")] + use async_std::process::Command; Command::from(eject(self)).status() diff --git a/support/device/src/mount/mac.rs b/support/device/src/mount/mac.rs index 63be857a..c51d1e1a 100644 --- a/support/device/src/mount/mac.rs +++ b/support/device/src/mount/mac.rs @@ -47,15 +47,19 @@ mod unmount { } } - #[cfg(feature = "tokio")] + impl UnmountAsync for Volume { #[cfg_attr(feature = "tracing", tracing::instrument())] async fn unmount(&self) -> Result<(), Error> { - tokio::process::Command::from(cmd(self)).status() - .await? - .exit_ok() - .map(|_| trace!("unmounted {self}")) - .map_err(Into::into) + #[cfg(all(feature = "tokio", not(feature = "async-std")))] + use tokio::process::Command; + #[cfg(feature = "async-std")] + use async_std::process::Command; + Command::from(cmd(self)).status() + .await? + .exit_ok() + .map(|_| trace!("unmounted {self}")) + .map_err(Into::into) } } diff --git a/support/device/src/mount/methods.rs b/support/device/src/mount/methods.rs index 1c4eef3e..f06c92e4 100644 --- a/support/device/src/mount/methods.rs +++ b/support/device/src/mount/methods.rs @@ -40,6 +40,7 @@ pub async fn wait_fs_available(mount: &MountedDevice, retry: Retries) -> R debug!("retries: {retries_num} * {iter_ms:?} ≈ {total:?}."); let mut counter = retries_num; + #[cfg(all(feature = "tokio", not(feature = "async-std")))] let mut interval = tokio::time::interval(iter_ms); let check = || { @@ -70,7 +71,12 @@ pub async fn wait_fs_available(mount: &MountedDevice, retry: Retries) -> R counter } != 0 { + #[cfg(all(not(feature = "async-std"), feature = "tokio"))] interval.tick().await; + #[cfg(feature = "async-std")] + async_std::task::sleep(iter_ms).await; + #[cfg(all(not(feature = "tokio"), not(feature = "async-std")))] + std::thread::sleep(iter_ms); if check() { return Ok(()); @@ -262,6 +268,7 @@ async fn wait_mount_point(dev: Device, retry: Retries) -> Result(dev: Device, retry: Retries) -> Result Result<(), Error> { - use tokio::process::Command; use futures_lite::future::ready; + #[cfg(all(feature = "tokio", not(feature = "async-std")))] + use tokio::process::Command; + #[cfg(feature = "async-std")] + use async_std::process::Command; futures::future::lazy(|_| winapi::unmount(self.letter)).or_else(|err| { if std::env::var_os("SHELL").is_some() { diff --git a/support/tool/Cargo.toml b/support/tool/Cargo.toml index 08c2d2ec..6b5be73d 100644 --- a/support/tool/Cargo.toml +++ b/support/tool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-tool" -version = "0.2.1" +version = "0.2.2" readme = "README.md" description = "Tool for interaction with Playdate device and sim." keywords = ["playdate", "usb", "utility"] @@ -46,7 +46,7 @@ workspace = true # PD: [dependencies.device] -features = ["async", "tokio", "clap", "tokio-serial"] +features = ["clap", "tokio", "tokio-serial"] workspace = true [dependencies.simulator]