From 8a19d02b1a960ee88c107bdea342c5d66e3371eb Mon Sep 17 00:00:00 2001 From: Revertron Date: Fri, 19 Mar 2021 11:37:49 +0100 Subject: [PATCH] Added features to control building with or without GUI, or use Edge engine on Windows. --- Cargo.toml | 11 +++++++++-- src/main.rs | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 22c096d..8d885b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ rust-crypto = "^0.2" blakeout = "0.1.0" num_cpus = "1.13.0" byteorder = "1.3.2" -web-view = { version = "0.7.3", features = [] } tinyfiledialogs = "3.3.10" serde = { version = "1.0.123", features = ["derive"] } serde_json = "1.0.42" @@ -34,6 +33,9 @@ mio = { version = "0.7", features = ["os-poll", "net"] } # for DNS from hermes derive_more = "0.99.9" +# Optional dependencies regulated by features +web-view = { version = "0.7.3", features = [], optional = true } + [target.'cfg(windows)'.dependencies] thread-priority = "0.2.1" winapi = { version = "0.3.7", features = ["impl-default", "wincon", "shellscalingapi"]} @@ -58,4 +60,9 @@ opt-level = 2 [package.metadata.winres] ProductName="ALFIS" -FileDescription="Alternative Free Identity System" \ No newline at end of file +FileDescription="Alternative Free Identity System" + +[features] +webgui = ["web-view"] +edge = ["web-view/edge"] +default = ["webgui"] \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 8b7da15..d85e866 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,7 @@ use winapi::um::wincon::{ATTACH_PARENT_PROCESS, AttachConsole, FreeConsole}; use alfis::{Block, Bytes, Chain, Miner, Context, Network, Settings, dns_utils, Keystore}; use alfis::blockchain::BLOCK_DIFFICULTY; +#[cfg(webui)] mod web_ui; const SETTINGS_FILENAME: &str = "alfis.toml"; @@ -37,6 +38,7 @@ fn main() { let mut opts = Options::new(); opts.optflag("h", "help", "Print this help menu"); + #[cfg(webui)] opts.optflag("n", "nogui", "Run without graphic user interface"); opts.optflag("v", "verbose", "Show more debug messages"); opts.optflag("d", "debug", "Show trace messages, more than debug"); @@ -54,7 +56,10 @@ fn main() { return; } + #[cfg(webui)] let no_gui = opt_matches.opt_present("n"); + #[cfg(not(webui))] + let no_gui = true; let mut level = LevelFilter::Info; if opt_matches.opt_present("v") { @@ -111,6 +116,7 @@ fn main() { thread::sleep(sleep); } } else { + #[cfg(webui)] web_ui::run_interface(context.clone(), miner.clone()); }