From 669634f19f7e2d2c03561490caac16545a19f9a3 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 20 Feb 2023 06:45:53 +0100 Subject: [PATCH] Fix(Modules) - Finally managed to get both to compile --- Cargo.lock | 2 +- Cargo.toml | 16 +++++++++++----- pyproject.toml | 2 +- src/bin/bin.rs | 25 ------------------------- src/bin/ffcraft.rs | 23 +++++++++++++++++++++++ src/lib.rs | 2 +- 6 files changed, 37 insertions(+), 33 deletions(-) delete mode 100644 src/bin/bin.rs create mode 100644 src/bin/ffcraft.rs diff --git a/Cargo.lock b/Cargo.lock index e0a3aa2..9d5c6dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -552,7 +552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] -name = "xiv_craft_solver_lib" +name = "xiv_craft_solver" version = "0.1.2" dependencies = [ "clap", diff --git a/Cargo.toml b/Cargo.toml index df8eb9d..070fd1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "xiv_craft_solver_lib" +name = "xiv_craft_solver" version = "0.1.2" edition = "2021" authors = ["谭俊健","Dandaedre"] @@ -21,15 +21,21 @@ pyo3 = { version = "0.18.0", features = ["extension-module"] } panic = 'abort' opt-level = 3 lto = true +vere0 = false + +[lib_rust] +name = "xiv_craft_solver_rust" +path = "src/lib.rs" +# crate-type = ["cdylib"] [lib] -name = "xiv_craft_solver_lib" +name = "xiv_craft_solver" path = "src/lib.rs" -crate-type = ["cdylib"] +crate-type = ["cdylib","rlib"] [[bin]] -name = "xiv_craft_solver" -path = "src/bin/bin.rs" +name = "ffcraft" +path = "src/bin/ffcraft.rs" [tool.maturin] python-source = "python" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 538e4e2..e75ad35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["maturin>=0.14,<0.15"] build-backend = "maturin" [project] -name = "ffxiv" +name = "xiv_craft_solver" requires-python = ">=3.7" classifiers = [ "Programming Language :: Rust", diff --git a/src/bin/bin.rs b/src/bin/bin.rs deleted file mode 100644 index 5e54b26..0000000 --- a/src/bin/bin.rs +++ /dev/null @@ -1,25 +0,0 @@ -// // #![warn(missing_docs,unsafe_code,unstable_features,)] -// #[allow(dead_code)] - -// use clap::Parser; -// use xiv_craft_solver_lib; - -// #[derive(Debug)] -// struct CustomError(String); - -// fn main() { -// let args = xiv_craft_solver_lib::Args::parse(); -// let params = xiv_craft_solver_lib::Parameters{ -// depth: args.depth, -// threads: args.threads, -// verbose: args.verbose, -// }; - -// let (recipe,stats) = xiv_craft_solver_lib::load_from_config(&args.recipe_name, &args.file_name, &args.character_name); -// xiv_craft_solver_lib::solve_craft(recipe,stats,params); - -// () -// } -fn main() { - unimplemented!(); -} \ No newline at end of file diff --git a/src/bin/ffcraft.rs b/src/bin/ffcraft.rs new file mode 100644 index 0000000..8fc1b35 --- /dev/null +++ b/src/bin/ffcraft.rs @@ -0,0 +1,23 @@ +// #![warn(missing_docs,unsafe_code,unstable_features,)] +use clap::Parser; +use xiv_craft_solver; + +#[derive(Debug)] +struct CustomError(String); + +fn main() { + let args = xiv_craft_solver::Args::parse(); + let params = xiv_craft_solver::Parameters{ + depth: args.depth, + threads: args.threads, + verbose: args.verbose, + }; + + let (recipe,stats) = xiv_craft_solver::load_from_config(&args.recipe_name, &args.file_name, &args.character_name); + xiv_craft_solver::solve_craft(recipe,stats,params); + + () +} +// fn main() { +// unimplemented!(); +// } \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 8aa5c31..ea1e599 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,7 @@ pub fn pouet()-> &'static str { /// A Python module implemented in Rust. #[pymodule] -fn xiv_craft_solver_lib(_py: Python, m: &PyModule) -> PyResult<()> { +fn xiv_craft_solver(_py: Python, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(pouet, m)?)?; Ok(()) }