diff --git a/Cargo.lock b/Cargo.lock index 02729d24..9efb5eca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,14 +5,6 @@ name = "adler32" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "aho-corasick" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "aho-corasick" version = "0.7.8" @@ -79,7 +71,7 @@ dependencies = [ "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "vte 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winpty 0.1.0", + "winpty 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -158,20 +150,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bindgen" -version = "0.33.2" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "clang-sys 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "which 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -245,10 +242,10 @@ dependencies = [ [[package]] name = "cexpr" -version = "0.2.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -266,10 +263,10 @@ dependencies = [ [[package]] name = "clang-sys" -version = "0.22.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -484,18 +481,6 @@ dependencies = [ "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "env_logger" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "env_logger" version = "0.7.1" @@ -694,7 +679,7 @@ dependencies = [ [[package]] name = "glob" -version = "0.2.11" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -958,14 +943,6 @@ name = "maybe-uninit" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "memchr" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "memchr" version = "2.3.0" @@ -1059,14 +1036,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "named_pipe" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "native-tls" version = "0.2.3" @@ -1118,14 +1087,6 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nom" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nom" version = "4.2.3" @@ -1398,11 +1359,6 @@ name = "quick-error" version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "quote" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "quote" version = "0.6.13" @@ -1583,18 +1539,6 @@ dependencies = [ "rust-argon2 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "regex" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex" version = "1.3.4" @@ -1606,14 +1550,6 @@ dependencies = [ "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "regex-syntax" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex-syntax" version = "0.6.14" @@ -1638,6 +1574,11 @@ dependencies = [ "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rustc_tools_util" version = "0.2.0" @@ -1803,6 +1744,11 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "signal-hook" version = "0.1.13" @@ -1948,14 +1894,6 @@ dependencies = [ "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" version = "1.0.1" @@ -1974,11 +1912,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ucd-util" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "unicase" version = "2.6.0" @@ -2033,11 +1966,6 @@ name = "urlocator" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "utf8-ranges" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "utf8parse" version = "0.2.0" @@ -2176,7 +2104,7 @@ dependencies = [ [[package]] name = "which" -version = "1.0.5" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2250,23 +2178,22 @@ dependencies = [ [[package]] name = "winpty" -version = "0.1.0" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "http_req 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "named_pipe 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winpty-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winpty-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "zip 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winpty-sys" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bindgen 0.33.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bindgen 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2347,7 +2274,6 @@ dependencies = [ [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" -"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" "checksum aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811" "checksum andrew 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e" "checksum android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" @@ -2360,7 +2286,7 @@ dependencies = [ "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" -"checksum bindgen 0.33.2 (registry+https://github.com/rust-lang/crates.io-index)" = "603ed8d8392ace9581e834e26bd09799bf1e989a79bd1aedbb893e72962bdc6e" +"checksum bindgen 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)" = "99de13bb6361e01e493b3db7928085dcc474b7ba4f5481818e53a89d76b8393f" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" "checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" @@ -2370,10 +2296,10 @@ dependencies = [ "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum calloop 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7aa2097be53a00de9e8fc349fea6d76221f398f5c4fa550d420669906962d160" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" -"checksum cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42aac45e9567d97474a834efdee3081b3c942b2205be932092f53354ce503d6c" +"checksum cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cgl 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" -"checksum clang-sys 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "939a1a34310b120d26eba35c29475933128b0ec58e24b43327f8dbe6036fc538" +"checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clipboard-win 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -2397,7 +2323,6 @@ dependencies = [ "checksum dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" "checksum dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bd1369e02db5e9b842a9b67bce8a2fcc043beafb2ae8a799dd482d46ea1ff0d" "checksum embed-resource 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bbaba4684ab0af1cbb3ef0b1f540ddc4b57b31940c920ea594efe09ab86e2a6c" -"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" "checksum euclid 0.20.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f852d320142e1cceb15dccef32ed72a9970b83109d8a4e24b1ab04d579f485d" "checksum expat-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" @@ -2419,7 +2344,7 @@ dependencies = [ "checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" "checksum gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a" "checksum gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" -"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum glutin 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf22d4e90c55d9be9f2ad52410e7a2c0d7e9c99d93a13df73a672e7ef4e8c7f7" "checksum glutin_egl_sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c" "checksum glutin_emscripten_sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1" @@ -2452,7 +2377,6 @@ dependencies = [ "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" "checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" "checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" "checksum miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" @@ -2462,12 +2386,10 @@ dependencies = [ "checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" -"checksum named_pipe 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9c443cce91fc3e12f017290db75dde490d685cdaaf508d7159d7cf41f0eb2b" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" "checksum nix 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd0eaf8df8bab402257e0a5c17a254e4cc1f72a93588a1ddfb5d356c801aa7cb" -"checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" "checksum notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" "checksum num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" @@ -2499,7 +2421,6 @@ dependencies = [ "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" "checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" -"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" @@ -2520,12 +2441,11 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" -"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" "checksum regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" -"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rust-argon2 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" +"checksum rustc-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" "checksum rustc_tools_util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b725dadae9fabc488df69a287f5a99c5eaf5d10853842a8a3dfac52476f544ee" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rusttype 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5" @@ -2545,6 +2465,7 @@ dependencies = [ "checksum servo-fontconfig 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a088f8d775a5c5314aae09bd77340bc9c67d72b9a45258be34c83548b4814cd9" "checksum servo-fontconfig-sys 4.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "62b3e166450f523f4db06c14f02a2d39e76d49b5d8cbd224338d93e3595c156c" "checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" +"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum signal-hook 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "10b9f3a1686a29f53cfd91ee5e3db3c12313ec02d33765f02c1a9645a1811e2c" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" @@ -2562,10 +2483,8 @@ dependencies = [ "checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" "checksum terminfo 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8e51065bafd2abe106b6036483b69d1741f4a1ec56ce8a2378de341637de689e" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum ucd-util 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5ccdc2daea7cf8bc50cd8710d170a9d816678e54943829c5082bb1594312cf8e" "checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" @@ -2574,7 +2493,6 @@ dependencies = [ "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" "checksum urlocator 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "317bb1e85e87e72c11cb9cda7cb8909ca174a21d0abeb0f6955b8f6b0178b164" -"checksum utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" "checksum utf8parse 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" "checksum vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" @@ -2592,7 +2510,7 @@ dependencies = [ "checksum wayland-protocols 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc286643656742777d55dc8e70d144fa4699e426ca8e9d4ef454f4bf15ffcf9" "checksum wayland-scanner 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93b02247366f395b9258054f964fe293ddd019c3237afba9be2ccbe9e1651c3d" "checksum wayland-sys 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d94e89a86e6d6d7c7c9b19ebf48a03afaac4af6bc22ae570e9a24124b75358f4" -"checksum which 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e84a603e7e0b1ce1aa1ee2b109c7be00155ce52df5081590d1ffb93f4f515cb2" +"checksum which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5475d47078209a02e60614f7ba5e645ef3ed60f771920ac1906d7c1cc65024c8" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" @@ -2600,7 +2518,8 @@ dependencies = [ "checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum winit 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "65a5c1a5ef76ac31cc97ad29489acdbed2178f3fc12ca00ee6cb11d60adb5a3a" -"checksum winpty-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dade7ecea144b3578a02925f93900f32370abfb8768630883971f4ef716b568" +"checksum winpty 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92c5a39bb2408a307dd5ab774039ec3f2c68d052970ae4dacc346101abe202b2" +"checksum winpty-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8a179a59760dc51d30b5e6eaf1bd6da88461f72f2616e962ddebef7e413210" "checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x11-clipboard 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e5e937afd03b64b7be4f959cc044e09260a47241b71e56933f37db097bf7859d" diff --git a/Cargo.toml b/Cargo.toml index 415ceb9f..fe1c8471 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ members = [ "alacritty", "alacritty_terminal", "font", - "winpty" ] [profile.release] diff --git a/alacritty_terminal/Cargo.toml b/alacritty_terminal/Cargo.toml index d935470d..62b9b6eb 100644 --- a/alacritty_terminal/Cargo.toml +++ b/alacritty_terminal/Cargo.toml @@ -31,7 +31,7 @@ nix = "0.16.1" signal-hook = { version = "0.1", features = ["mio-support"] } [target.'cfg(windows)'.dependencies] -winpty = { path = "../winpty" } +winpty = "0.2.0" mio-named-pipes = "0.1" miow = "0.3" winapi = { version = "0.3.7", features = [ diff --git a/winpty/Cargo.toml b/winpty/Cargo.toml deleted file mode 100644 index 02cc21c7..00000000 --- a/winpty/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "winpty" -version = "0.1.0" -authors = ["Zac Pullar-Strecker "] -license = "MIT" -description = "Safe rust bindings for winpty" -edition = "2018" - -[target.'cfg(windows)'.dependencies] -winpty-sys = "0.4.3" -bitflags = "1.0" - -[target.'cfg(windows)'.dev-dependencies] -named_pipe = "0.4.1" -winapi = { version = "0.3", features = ["winnt", "processthreadsapi"] } - -[target.'cfg(windows)'.build-dependencies] -tempfile = "3.0.4" -http_req = "0.5" -zip = "0.5" diff --git a/winpty/build.rs b/winpty/build.rs deleted file mode 100644 index ae141f7e..00000000 --- a/winpty/build.rs +++ /dev/null @@ -1,74 +0,0 @@ -#[cfg(windows)] -use std::fs::OpenOptions; -#[cfg(windows)] -use std::io; - -#[cfg(windows)] -use std::env; -#[cfg(windows)] -use std::fs::{copy, File}; -#[cfg(windows)] -use std::path::Path; - -#[cfg(windows)] -use http_req; -#[cfg(windows)] -use tempfile; -#[cfg(windows)] -use zip; - -#[cfg(windows)] -const WINPTY_PACKAGE_URL: &str = - "https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msvc2015.zip"; - -fn main() { - #[cfg(windows)] - { - // Path is relative to target/{profile}/build/alacritty-HASH/out - let file = Path::new(&env::var("OUT_DIR").unwrap()).join("../../../winpty-agent.exe"); - if !file.exists() { - aquire_winpty_agent(&file); - } - - // The working directory for `cargo test` is in the deps folder, not the debug/release root - copy(&file, file.parent().unwrap().join("deps/winpty-agent.exe")).unwrap(); - } -} - -#[cfg(windows)] -fn aquire_winpty_agent(out_path: &Path) { - let tmp_dir = tempfile::Builder::new().prefix("alacritty_build").tempdir().unwrap(); - - let mut file = OpenOptions::new() - .read(true) - .write(true) - .create(true) - .open(tmp_dir.path().join("winpty_package.zip")) - .unwrap(); - let mut redirects = 0; - let mut url = WINPTY_PACKAGE_URL.to_string(); - loop { - let res = http_req::request::get(url.clone(), &mut file).unwrap(); - if res.status_code().is_redirect() { - redirects += 1; - url = res.headers().get("Location").unwrap().to_string(); - if redirects > 5 { - panic!("Too many redirects"); - } - } else { - break; - } - } - - let mut archive = zip::ZipArchive::new(file).unwrap(); - - let target = match env::var("TARGET").unwrap().split('-').next().unwrap() { - "x86_64" => "x64", - "i386" => "ia32", - _ => panic!("architecture has no winpty binary"), - }; - - let mut winpty_agent = archive.by_name(&format!("{}/bin/winpty-agent.exe", target)).unwrap(); - - io::copy(&mut winpty_agent, &mut File::create(out_path).unwrap()).unwrap(); -} diff --git a/winpty/src/lib.rs b/winpty/src/lib.rs deleted file mode 100644 index f3b7aff9..00000000 --- a/winpty/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use, clippy::wrong_pub_self_convention)] - -#[cfg(windows)] -pub mod windows; - -#[cfg(windows)] -pub use crate::windows::*; diff --git a/winpty/src/windows.rs b/winpty/src/windows.rs deleted file mode 100644 index fb2b1e80..00000000 --- a/winpty/src/windows.rs +++ /dev/null @@ -1,438 +0,0 @@ -use std::ffi::{OsStr, OsString}; -use std::fmt::{self, Display, Formatter}; -use std::iter::once; -use std::os::windows::ffi::{OsStrExt, OsStringExt}; -use std::os::windows::io::RawHandle; -use std::path::{Path, PathBuf}; -use std::ptr::{null, null_mut}; -use std::result::Result; - -use bitflags::bitflags; - -use winpty_sys::*; - -#[derive(Copy, Clone, Debug)] -pub enum ErrorCode { - OutOfMemory, - SpawnCreateProcessFailed, - LostConnection, - AgentExeMissing, - Unspecified, - AgentDied, - AgentTimeout, - AgentCreationFailed, - UnknownError(u32), -} - -pub enum MouseMode { - None, - Auto, - Force, -} - -bitflags!( - pub struct SpawnFlags: u64 { - const AUTO_SHUTDOWN = 0x1; - const EXIT_AFTER_SHUTDOWN = 0x2; - } -); - -bitflags!( - pub struct ConfigFlags: u64 { - const CONERR = 0x1; - const PLAIN_OUTPUT = 0x2; - const COLOR_ESCAPES = 0x4; - } -); - -#[derive(Debug)] -pub struct Error { - code: ErrorCode, - message: String, -} - -// Check to see whether winpty gave us an error, and perform the necessary memory freeing -fn check_err(e: *mut winpty_error_t) -> Result<(), Error> { - unsafe { - let code = winpty_error_code(e); - let raw = winpty_error_msg(e); - let message = String::from_utf16_lossy(std::slice::from_raw_parts(raw, wcslen(raw))); - winpty_error_free(e); - - let code = match code { - WINPTY_ERROR_SUCCESS => return Ok(()), - WINPTY_ERROR_OUT_OF_MEMORY => ErrorCode::OutOfMemory, - WINPTY_ERROR_SPAWN_CREATE_PROCESS_FAILED => ErrorCode::SpawnCreateProcessFailed, - WINPTY_ERROR_LOST_CONNECTION => ErrorCode::LostConnection, - WINPTY_ERROR_AGENT_EXE_MISSING => ErrorCode::AgentExeMissing, - WINPTY_ERROR_UNSPECIFIED => ErrorCode::Unspecified, - WINPTY_ERROR_AGENT_DIED => ErrorCode::AgentDied, - WINPTY_ERROR_AGENT_TIMEOUT => ErrorCode::AgentTimeout, - WINPTY_ERROR_AGENT_CREATION_FAILED => ErrorCode::AgentCreationFailed, - code => ErrorCode::UnknownError(code), - }; - - Err(Error { code, message }) - } -} - -impl Display for Error { - fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { - write!(f, "Code: {:?}, Message: {}", self.code, self.message) - } -} - -impl std::error::Error for Error { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - None - } -} - -#[derive(Debug)] -/// Winpty agent config -pub struct Config(*mut winpty_config_t); - -impl Config { - pub fn new(flags: ConfigFlags) -> Result { - let mut err = null_mut() as *mut winpty_error_t; - let config = unsafe { winpty_config_new(flags.bits(), &mut err) }; - check_err(err)?; - - Ok(Self(config)) - } - - /// Set the initial size of the console window - pub fn set_initial_size(&mut self, cols: i32, rows: i32) { - unsafe { - winpty_config_set_initial_size(self.0, cols, rows); - } - } - - /// Set the mouse mode - pub fn set_mouse_mode(&mut self, mode: &MouseMode) { - let m = match mode { - MouseMode::None => WINPTY_MOUSE_MODE_NONE, - MouseMode::Auto => WINPTY_MOUSE_MODE_AUTO, - MouseMode::Force => WINPTY_MOUSE_MODE_FORCE, - }; - unsafe { - winpty_config_set_mouse_mode(self.0, m as i32); - } - } - - /// Amount of time to wait for the agent to startup and to wait for any given - /// agent RPC request. Must be greater than 0. Can be INFINITE. - // Might be a better way to represent this while still retaining infinite capability? - // Enum? - pub fn set_agent_timeout(&mut self, timeout: u32) { - unsafe { - winpty_config_set_agent_timeout(self.0, timeout); - } - } -} - -impl Drop for Config { - fn drop(&mut self) { - unsafe { - winpty_config_free(self.0); - } - } -} - -#[derive(Debug)] -/// A struct representing the winpty agent process -pub struct Winpty(*mut winpty_t); - -pub struct ChildHandles { - pub process: HANDLE, - pub thread: HANDLE, -} - -impl Winpty { - /// Starts the agent. This process will connect to the agent - /// over a control pipe, and the agent will open data pipes - /// (e.g. CONIN and CONOUT). - pub fn open(cfg: &Config) -> Result { - let mut err = null_mut() as *mut winpty_error_t; - let winpty = unsafe { winpty_open(cfg.0, &mut err) }; - check_err(err)?; - - Ok(Self(winpty)) - } - - /// Returns the handle to the winpty agent process - pub fn raw_handle(&mut self) -> RawHandle { - unsafe { winpty_agent_process(self.0) } - } - - /// Returns the name of the input pipe. - /// Pipe is half-duplex. - pub fn conin_name(&mut self) -> PathBuf { - unsafe { - let raw = winpty_conin_name(self.0); - OsString::from_wide(std::slice::from_raw_parts(raw, wcslen(raw))).into() - } - } - - /// Returns the name of the output pipe. - /// Pipe is half-duplex. - pub fn conout_name(&mut self) -> PathBuf { - unsafe { - let raw = winpty_conout_name(self.0); - OsString::from_wide(std::slice::from_raw_parts(raw, wcslen(raw))).into() - } - } - - /// Returns the name of the error pipe. - /// The name will only be valid if ConfigFlags::CONERR was specified. - /// Pipe is half-duplex. - pub fn conerr_name(&mut self) -> PathBuf { - unsafe { - let raw = winpty_conerr_name(self.0); - OsString::from_wide(std::slice::from_raw_parts(raw, wcslen(raw))).into() - } - } - - /// Change the size of the Windows console window. - /// - /// cols & rows MUST be greater than 0 - pub fn set_size(&mut self, cols: u16, rows: u16) -> Result<(), Error> { - assert!(cols > 0 && rows > 0); - let mut err = null_mut() as *mut winpty_error_t; - - unsafe { - winpty_set_size(self.0, i32::from(cols), i32::from(rows), &mut err); - } - - check_err(err) - } - - /// Get the list of processes running in the winpty agent. Returns <= count processes - /// - /// `count` must be greater than 0. Larger values cause a larger allocation. - // TODO: This should return Vec instead of Vec - pub fn console_process_list(&mut self, count: usize) -> Result, Error> { - assert!(count > 0); - - let mut err = null_mut() as *mut winpty_error_t; - let mut process_list = Vec::with_capacity(count); - - unsafe { - let len = winpty_get_console_process_list( - self.0, - process_list.as_mut_ptr(), - count as i32, - &mut err, - ) as usize; - process_list.set_len(len); - } - - check_err(err)?; - - Ok(process_list) - } - - /// Spawns the new process. - /// - /// spawn can only be called once per Winpty object. If it is called - /// before the output data pipe(s) is/are connected, then collected output is - /// buffered until the pipes are connected, rather than being discarded. - /// (https://blogs.msdn.microsoft.com/oldnewthing/20110107-00/?p=11803) - pub fn spawn(&mut self, cfg: &SpawnConfig) -> Result { - let mut handles = - ChildHandles { process: std::ptr::null_mut(), thread: std::ptr::null_mut() }; - - let mut create_process_error: DWORD = 0; - let mut err = null_mut() as *mut winpty_error_t; - - unsafe { - winpty_spawn( - self.0, - cfg.0 as *const winpty_spawn_config_s, - &mut handles.process as *mut _, - &mut handles.thread as *mut _, - &mut create_process_error as *mut _, - &mut err, - ); - } - - let mut result = check_err(err); - if let Err(Error { code: ErrorCode::SpawnCreateProcessFailed, message }) = &mut result { - *message = format!("{} (error code {})", message, create_process_error); - } - result.map(|_| handles) - } -} - -// winpty_t is thread-safe -unsafe impl Sync for Winpty {} -unsafe impl Send for Winpty {} - -impl Drop for Winpty { - fn drop(&mut self) { - unsafe { - winpty_free(self.0); - } - } -} - -#[derive(Debug)] -/// Information about a process for winpty to spawn -pub struct SpawnConfig(*mut winpty_spawn_config_t); - -impl SpawnConfig { - /// Creates a new spawnconfig - pub fn new( - spawnflags: SpawnFlags, - appname: Option<&str>, - cmdline: Option<&str>, - cwd: Option<&Path>, - env: Option<&str>, - ) -> Result { - let mut err = null_mut() as *mut winpty_error_t; - - fn to_wstring + ?Sized>(s: &S) -> Vec { - OsStr::new(s).encode_wide().chain(once(0)).collect() - } - - let appname = appname.map(to_wstring); - let cmdline = cmdline.map(to_wstring); - let cwd = cwd.map(to_wstring); - let env = env.map(to_wstring); - - let wstring_ptr = |opt: &Option>| opt.as_ref().map_or(null(), |ws| ws.as_ptr()); - let spawn_config = unsafe { - winpty_spawn_config_new( - spawnflags.bits(), - wstring_ptr(&appname), - wstring_ptr(&cmdline), - wstring_ptr(&cwd), - wstring_ptr(&env), - &mut err, - ) - }; - - check_err(err)?; - - Ok(Self(spawn_config)) - } -} - -impl Drop for SpawnConfig { - fn drop(&mut self) { - unsafe { - winpty_spawn_config_free(self.0); - } - } -} - -#[cfg(test)] -mod tests { - use named_pipe::PipeClient; - use winapi::um::processthreadsapi::OpenProcess; - use winapi::um::winnt::READ_CONTROL; - - use crate::{Config, ConfigFlags, SpawnConfig, SpawnFlags, Winpty}; - - #[test] - // Test that we can start a process in winpty - fn spawn_process() { - let mut winpty = - Winpty::open(&Config::new(ConfigFlags::empty()).expect("failed to create config")) - .expect("failed to create winpty instance"); - - winpty - .spawn( - &SpawnConfig::new(SpawnFlags::empty(), None, Some("cmd"), None, None) - .expect("failed to create spawn config"), - ) - .unwrap(); - } - - #[test] - // Test that pipes connected before winpty is spawned can be connected to - fn valid_pipe_connect_before() { - let mut winpty = - Winpty::open(&Config::new(ConfigFlags::empty()).expect("failed to create config")) - .expect("failed to create winpty instance"); - - // Check we can connect to both pipes - PipeClient::connect_ms(winpty.conout_name(), 1000) - .expect("failed to connect to conout pipe"); - PipeClient::connect_ms(winpty.conin_name(), 1000).expect("failed to connect to conin pipe"); - - winpty - .spawn( - &SpawnConfig::new(SpawnFlags::empty(), None, Some("cmd"), None, None) - .expect("failed to create spawn config"), - ) - .unwrap(); - } - - #[test] - // Test that pipes connected after winpty is spawned can be connected to - fn valid_pipe_connect_after() { - let mut winpty = - Winpty::open(&Config::new(ConfigFlags::empty()).expect("failed to create config")) - .expect("failed to create winpty instance"); - - winpty - .spawn( - &SpawnConfig::new(SpawnFlags::empty(), None, Some("cmd"), None, None) - .expect("failed to create spawn config"), - ) - .unwrap(); - - // Check we can connect to both pipes - PipeClient::connect_ms(winpty.conout_name(), 1000) - .expect("failed to connect to conout pipe"); - PipeClient::connect_ms(winpty.conin_name(), 1000).expect("failed to connect to conin pipe"); - } - - #[test] - fn resize() { - let mut winpty = - Winpty::open(&Config::new(ConfigFlags::empty()).expect("failed to create config")) - .expect("failed to create winpty instance"); - - winpty - .spawn( - &SpawnConfig::new(SpawnFlags::empty(), None, Some("cmd"), None, None) - .expect("failed to create spawn config"), - ) - .unwrap(); - - winpty.set_size(1, 1).unwrap(); - } - - #[test] - #[ignore] - // Test that each id returned by cosole_process_list points to an actual process - fn console_process_list_valid() { - let mut winpty = - Winpty::open(&Config::new(ConfigFlags::empty()).expect("failed to create config")) - .expect("failed to create winpty instance"); - - winpty - .spawn( - &SpawnConfig::new(SpawnFlags::empty(), None, Some("cmd"), None, None) - .expect("failed to create spawn config"), - ) - .unwrap(); - - let processes = - winpty.console_process_list(1000).expect("failed to get console process list"); - - // Check that each id is valid - processes.iter().for_each(|id| { - let handle = unsafe { - OpenProcess( - READ_CONTROL, // permissions - false as i32, // inheret - *id as u32, - ) - }; - assert!(!handle.is_null()); - }); - } -}