From 6c0a0efd5b94c89d082c35b697008bdd3779dc51 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Wed, 4 Apr 2018 23:29:45 -0700 Subject: [PATCH] Convert core to library for easier testing --- server/Cargo.toml | 4 ++++ server/src/bin.rs | 26 ++++---------------------- server/src/lib.rs | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 server/src/lib.rs diff --git a/server/Cargo.toml b/server/Cargo.toml index d6000225..d8342563 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -6,6 +6,10 @@ description = "A tool to create robust Roblox projects" license = "MIT" repository = "https://github.com/LPGhatguy/rojo" +[lib] +name = "rojo_core" +path = "src/lib.rs" + [[bin]] name = "rojo" path = "src/bin.rs" diff --git a/server/src/bin.rs b/server/src/bin.rs index 1e9a62be..baf731c2 100644 --- a/server/src/bin.rs +++ b/server/src/bin.rs @@ -1,29 +1,11 @@ -#[macro_use] extern crate serde_derive; -#[macro_use] extern crate rouille; #[macro_use] extern crate clap; -#[macro_use] extern crate lazy_static; -extern crate notify; -extern crate rand; -extern crate serde; -extern crate serde_json; -extern crate regex; -pub mod rbx_session; -pub mod id; -pub mod web; -pub mod core; -pub mod project; -pub mod pathext; -pub mod vfs; -pub mod rbx; -pub mod middleware; -pub mod middlewares; -pub mod commands; +extern crate rojo_core; use std::path::{Path, PathBuf}; use std::process; -use pathext::canonicalish; +use rojo_core::pathext::canonicalish; fn main() { let matches = clap_app!(rojo => @@ -61,7 +43,7 @@ fn main() { let project_path = Path::new(sub_matches.value_of("PATH").unwrap_or(".")); let full_path = canonicalish(project_path); - commands::init(&full_path); + rojo_core::commands::init(&full_path); }, ("serve", sub_matches) => { let sub_matches = sub_matches.unwrap(); @@ -84,7 +66,7 @@ fn main() { } }; - commands::serve(&project_path, verbose, port); + rojo_core::commands::serve(&project_path, verbose, port); }, ("pack", _) => { eprintln!("'rojo pack' is not yet implemented!"); diff --git a/server/src/lib.rs b/server/src/lib.rs new file mode 100644 index 00000000..6c524342 --- /dev/null +++ b/server/src/lib.rs @@ -0,0 +1,20 @@ +#[macro_use] extern crate serde_derive; +#[macro_use] extern crate rouille; +#[macro_use] extern crate lazy_static; +extern crate notify; +extern crate rand; +extern crate serde; +extern crate serde_json; +extern crate regex; + +pub mod rbx_session; +pub mod id; +pub mod web; +pub mod core; +pub mod project; +pub mod pathext; +pub mod vfs; +pub mod rbx; +pub mod middleware; +pub mod middlewares; +pub mod commands;