From 8fc83e2f2ff487b45d1e0e6570103e627b4e101c Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 20 Feb 2023 07:11:14 +0100 Subject: [PATCH] Fix(Modules) - Modules working and double build working --- Cargo.toml | 10 ++++++---- src/bin/ffcraft.rs | 5 +---- src/lib.rs | 13 ++++++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 070fd1c..cc49e95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,16 +17,18 @@ threadpool = "1.8.1" # For python bindings TODO: make it optionnal pyo3 = { version = "0.18.0", features = ["extension-module"] } +# [build] +# target = ["x86_64-unknown-linux-gnu", "x86_64-unknown-windows-gnu"] + [profile.release] panic = 'abort' opt-level = 3 lto = true vere0 = false -[lib_rust] -name = "xiv_craft_solver_rust" -path = "src/lib.rs" -# crate-type = ["cdylib"] +[features] +default = [] +verbose = [] [lib] name = "xiv_craft_solver" diff --git a/src/bin/ffcraft.rs b/src/bin/ffcraft.rs index 8fc1b35..fe86edc 100644 --- a/src/bin/ffcraft.rs +++ b/src/bin/ffcraft.rs @@ -17,7 +17,4 @@ fn main() { xiv_craft_solver::solve_craft(recipe,stats,params); () -} -// fn main() { -// unimplemented!(); -// } \ No newline at end of file +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index ea1e599..536c3b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,12 +71,14 @@ pub fn solve_craft<'a>(recipe: Recipe, stats: Stats, params: Parameters) -> Opti // Start a threadpool let pool = ThreadPool::new(params.threads); + #[cfg(feature = "verbose")] if params.verbose>0{ println!("Solving...\n"); println!("[P1] Starting phase 1..."); } let phase1_routes = solver::generate_routes_phase1(craft); + #[cfg(feature = "verbose")] if params.verbose>0{ println!("[P1] Found {} routes, testing them all...",phase1_routes.len()); if params.verbose>1{ @@ -109,6 +111,7 @@ pub fn solve_craft<'a>(recipe: Recipe, stats: Stats, params: Parameters) -> Opti let phase2_routes = arc_phase2_routes.lock().unwrap(); // Print the results if verbose + #[cfg(feature = "verbose")] if params.verbose>0{ println!("[P2] Found {} solutions, sorting",phase2_routes.len()); @@ -140,6 +143,7 @@ pub fn solve_craft<'a>(recipe: Recipe, stats: Stats, params: Parameters) -> Opti let top_route = match valid_routes.iter().max_by_key(|route| route.quality) { Some(top) => top, None => { + #[cfg(feature = "verbose")] println!("[P2] No route could finish the craft.\n[P2] Runtime {}ms. Now exiting...",now.elapsed().as_millis()); return None; }, @@ -162,13 +166,16 @@ pub fn solve_craft<'a>(recipe: Recipe, stats: Stats, params: Parameters) -> Opti content.push("\"focusedSynthesis\"".to_string()); } + #[cfg(feature = "verbose")] if params.verbose>2{ println!("[F] Top route {:?}",top_route); } - - println!("Quality: {}/{}", top_route.quality, top_route.recipe.quality); - println!("\t[{}]", content.join(", ")); + { + println!("Quality: {}/{}", top_route.quality, top_route.recipe.quality); + println!("\t[{}]", content.join(", ")); + } + // Wait for enter TODO: Remove println!(); println!("Program finished sucessfuly in {}ms and found {} solutions, [prog:{}]",