From 72cc3fecb6e7e6bf42110beca279f9e6945ecbee Mon Sep 17 00:00:00 2001 From: Dece Date: Sat, 18 Apr 2020 17:43:55 +0200 Subject: [PATCH] ironring: split lib and bin code --- Cargo.toml | 7 ++++++- ffi_tests.py | 8 ++++++++ src/{main.rs => bin/ironring.rs} | 11 +---------- src/lib.rs | 11 +++++++++++ 4 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 ffi_tests.py rename src/{main.rs => bin/ironring.rs} (97%) create mode 100644 src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index a9405c0..c93aca8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,12 @@ version = "0.1.0" authors = ["Dece "] edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "rir" +crate-type = ["lib", "cdylib"] + +[[bin]] +name = "ironring" [dependencies] clap = "2.33" diff --git a/ffi_tests.py b/ffi_tests.py new file mode 100644 index 0000000..5b1f52a --- /dev/null +++ b/ffi_tests.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +"""Import hash from the rir dynamic lib.""" + +import sys +from ctypes import cdll + +lib = cdll.LoadLibrary(sys.argv[1]) +#print(lib.name_hashes.hash("/chr/c0000.anibnd.dcx")) diff --git a/src/main.rs b/src/bin/ironring.rs similarity index 97% rename from src/main.rs rename to src/bin/ironring.rs index a516f78..6ae63f2 100644 --- a/src/main.rs +++ b/src/bin/ironring.rs @@ -5,16 +5,7 @@ use std::process; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; -mod name_hashes; -mod parsers { - pub mod bhd; -} -mod unpackers { - pub mod bhd; -} -mod utils { - pub mod fs; -} +use rir::{name_hashes, unpackers}; fn main() { let default_namefilepath: &str = &get_default_namefilepath(); diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..199c32f --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,11 @@ +pub mod name_hashes; +pub mod parsers { + pub mod bhd; +} +pub mod unpackers { + pub mod bhd; +} +pub mod utils { + pub mod fs; +} +