diff --git a/Cargo.toml b/Cargo.toml index dddfa2e6e..6566a2b68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,13 +20,15 @@ name = "ion" [dependencies] bitflags = "0.9.1" fnv = "1.0" -futures = "0.1" glob = "0.2" liner = "0.2" permutate = "0.3" unicode-segmentation = "1.2" smallvec = "0.4" smallstring = "0.1" + +[target.'cfg(not(target_os = "redox"))'.dependencies] +futures = "0.1" tokio-core = "0.1" tokio-signal = "0.1" diff --git a/src/main.rs b/src/main.rs index 4e2b527aa..ac48dbf0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,13 +8,14 @@ #[macro_use] extern crate bitflags; extern crate fnv; -extern crate futures; extern crate glob; extern crate liner; extern crate smallvec; extern crate smallstring; -extern crate tokio_core; -extern crate tokio_signal; + +#[cfg(not(target_os = "redox"))] extern crate futures; +#[cfg(not(target_os = "redox"))] extern crate tokio_core; +#[cfg(not(target_os = "redox"))] extern crate tokio_signal; #[cfg(all(unix, not(target_os = "redox")))] extern crate users as users_unix; @@ -30,36 +31,41 @@ use std::io::{stderr, Write, ErrorKind}; use builtins::Builtin; use shell::Shell; -use tokio_core::reactor::Core; -use futures::{Future, Stream}; +#[cfg(not(target_os = "redox"))] use tokio_core::reactor::Core; +#[cfg(not(target_os = "redox"))] use futures::{Future, Stream}; + use std::sync::mpsc; use std::thread; +fn inner_main(sigint_rx : mpsc::Receiver) { + let builtins = Builtin::map(); + let mut shell = Shell::new(&builtins, sigint_rx); + shell.evaluate_init_file(); + + if "1" == shell.variables.get_var_or_empty("HISTORY_FILE_ENABLED") { + shell.context.history.set_file_name(shell.variables.get_var("HISTORY_FILE")); + match shell.context.history.load_history() { + Ok(()) => { + // pass + } + Err(ref err) if err.kind() == ErrorKind::NotFound => { + let history_filename = shell.variables.get_var_or_empty("HISTORY_FILE"); + let _ = writeln!(stderr(), "ion: failed to find history file {}: {}", history_filename, err); + }, + Err(err) => { + let _ = writeln!(stderr(), "ion: failed to load history: {}", err); + } + } + } + shell.execute(); +} + + +#[cfg(not(target_os = "redox"))] fn main() { let (sigint_tx, sigint_rx) = mpsc::channel(); - thread::spawn(move || { - let builtins = Builtin::map(); - let mut shell = Shell::new(&builtins, sigint_rx); - shell.evaluate_init_file(); - - if "1" == shell.variables.get_var_or_empty("HISTORY_FILE_ENABLED") { - shell.context.history.set_file_name(shell.variables.get_var("HISTORY_FILE")); - match shell.context.history.load_history() { - Ok(()) => { - // pass - } - Err(ref err) if err.kind() == ErrorKind::NotFound => { - let history_filename = shell.variables.get_var_or_empty("HISTORY_FILE"); - let _ = writeln!(stderr(), "ion: failed to find history file {}: {}", history_filename, err); - }, - Err(err) => { - let _ = writeln!(stderr(), "ion: failed to load history: {}", err); - } - } - } - shell.execute(); - }); + thread::spawn(move || inner_main(sigint_rx)); let mut core = Core::new().unwrap(); let handle = core.handle(); @@ -71,3 +77,9 @@ fn main() { }); core.run(signal_handler).unwrap(); } + +#[cfg(target_os = "redox")] +fn main() { + let (_, sigint_rx) = mpsc::channel(); + inner_main(sigint_rx); +}