From 6feb1f8b824ce35d1c32629f3bd5dda25f204445 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Adri=C3=A1n=20Arroyo=20Calle?= Date: Sun, 22 May 2022 13:18:11 +0200 Subject: [PATCH] Fix build on Windows 10 --- Cargo.lock | 68 +++++++++++++++++++--------------------- Cargo.toml | 2 +- README.md | 8 +++-- src/bin/scryer-prolog.rs | 16 +++------- 4 files changed, 43 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0de5eae8..e914dcd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,12 +144,6 @@ version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -250,6 +244,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ctrlc" +version = "3.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b37feaa84e6861e00a1f5e5aa8da3ee56d605c9992d33e082786754828e20865" +dependencies = [ + "nix 0.24.1", + "winapi", +] + [[package]] name = "difflib" version = "0.4.0" @@ -271,7 +275,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "dirs-sys-next", ] @@ -365,7 +369,7 @@ version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46e245f4c8ec30c6415c56cb132c07e69e74f1942f6b4a4061da748b49f486ca" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "rustix", "windows-sys 0.30.0", ] @@ -470,7 +474,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] @@ -662,7 +666,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -713,7 +717,7 @@ version = "5.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f404a90a744e32e8be729034fc33b90cf2a56418fbf594d69aa3c0214ad414e5" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "lexical-core", ] @@ -725,7 +729,7 @@ checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ "arrayvec", "bitflags", - "cfg-if 1.0.0", + "cfg-if", "ryu", "static_assertions", ] @@ -769,7 +773,7 @@ version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -906,28 +910,26 @@ dependencies = [ [[package]] name = "nix" -version = "0.15.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" dependencies = [ "bitflags", "cc", - "cfg-if 0.1.10", + "cfg-if", "libc", - "void", + "memoffset", ] [[package]] name = "nix" -version = "0.23.1" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" +checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9" dependencies = [ "bitflags", - "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", - "memoffset", ] [[package]] @@ -1022,7 +1024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" dependencies = [ "bitflags", - "cfg-if 1.0.0", + "cfg-if", "foreign-types", "libc", "once_cell", @@ -1094,7 +1096,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "instant", "libc", "redox_syscall", @@ -1108,7 +1110,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "redox_syscall", "smallvec", @@ -1565,7 +1567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db7826789c0e25614b03e5a54a0717a86f9ff6e6e5247f92b369472869320039" dependencies = [ "bitflags", - "cfg-if 1.0.0", + "cfg-if", "clipboard-win", "dirs-next", "fd-lock", @@ -1623,6 +1625,7 @@ dependencies = [ "chrono", "cpu-time", "crossterm", + "ctrlc", "dirs-next", "divrem", "fxhash", @@ -1636,7 +1639,6 @@ dependencies = [ "libc", "modular-bitfield", "native-tls", - "nix 0.15.0", "num-rug-adapter", "openssl", "ordered-float", @@ -1949,7 +1951,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fastrand", "libc", "redox_syscall", @@ -2092,7 +2094,7 @@ version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "pin-project-lite", "tracing-core", ] @@ -2166,12 +2168,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - [[package]] name = "wait-timeout" version = "0.2.0" @@ -2220,7 +2216,7 @@ version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] diff --git a/Cargo.toml b/Cargo.toml index 680280d8..283081f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ lazy_static = "1.4.0" lexical = "5.2.2" libc = "0.2.62" modular-bitfield = "0.11.2" -nix = "0.15.0" +ctrlc = "3.2.2" num-rug-adapter = { version = "0.1.6", optional = true } ordered-float = "2.6.0" phf = { version = "0.9", features = ["macros"] } diff --git a/README.md b/README.md index bc31310c..a3151439 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ strings. ## Installing Scryer Prolog -### Native Install (Unix Only) +### Native Install First, install the latest stable version of [Rust](https://www.rust-lang.org/en-US/install.html) using your @@ -125,9 +125,13 @@ $> cargo run [--release] The optional `--release` flag will perform various optimizations, producing a faster executable. +On Windows, Scryer Prolog is easier to build inside a [MSYS2](https://www.msys2.org/) +environment as some crates may require native C compilation. However, +the resulting binary does not need MSYS2 to run. When executing Scryer in a shell, it is recommended to use a more advanced shell than mintty (the default MSYS2 shell). The [Windows Terminal](https://github.com/microsoft/terminal) works correctly. + Scryer Prolog must be built with **Rust 1.57 and up**. -### Docker Install (All Platforms) +### Docker Install First, install [Docker](https://docs.docker.com/get-docker/) on Linux, Windows, or Mac. diff --git a/src/bin/scryer-prolog.rs b/src/bin/scryer-prolog.rs index 3fb2e09d..eae00fe2 100644 --- a/src/bin/scryer-prolog.rs +++ b/src/bin/scryer-prolog.rs @@ -1,19 +1,11 @@ fn main() { - use nix::sys::signal; + use std::sync::atomic::Ordering; use scryer_prolog::*; - let handler = signal::SigHandler::Handler(handle_sigint); - unsafe { signal::signal(signal::Signal::SIGINT, handler) }.unwrap(); + ctrlc::set_handler(move || { + scryer_prolog::machine::INTERRUPT.store(true, Ordering::Relaxed); + }).unwrap(); let mut wam = machine::Machine::new(); wam.run_top_level(); } - -pub extern "C" fn handle_sigint(signal: libc::c_int) { - use nix::sys::signal; - use std::sync::atomic::Ordering; - let signal = signal::Signal::from_c_int(signal).unwrap(); - if signal == signal::Signal::SIGINT { - scryer_prolog::machine::INTERRUPT.store(true, Ordering::Relaxed); - } -} -- 2.54.0