Skip to content

Commit

Permalink
Problem: cfg module doesn't really belong to sit-core
Browse files Browse the repository at this point in the history
The main thought here is that `cfg` defines structures
that are used by code outside of `sit-core` (namely, `sit` crate).

Solution: move `cfg` to the `sit` crate
  • Loading branch information
yrashk committed Oct 7, 2018
1 parent be1ec55 commit d142a1a
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 19 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
@@ -1,3 +1,6 @@
[workspace]

members = ["sit-core", "sit"]

[profile.release]
lto = true
2 changes: 0 additions & 2 deletions sit-core/Cargo.toml
Expand Up @@ -26,7 +26,6 @@ sha-1 = { version = "0.7", optional = true }
uuid = { version = "0.5", features = ["v4"], optional = true }
memmap = { version = "0.6", optional = true}
cesu8 = { version = "1.1", optional = true }
git2 = { version = "0.7", optional = true, default-features = false }
relative-path = "0.3"

[dev-dependencies]
Expand All @@ -45,5 +44,4 @@ duktape-reducers = ["duktape", "cesu8"]
duktape = []
duktape-mmap = ["memmap"]
windows7 = []
git = ["git2"]
deprecated-item-api = []
1 change: 0 additions & 1 deletion sit-core/src/lib.rs
Expand Up @@ -63,4 +63,3 @@ pub mod reducers;
pub use reducers::Reducer;
#[cfg(feature = "duktape")]
pub mod duktape;
pub mod cfg;
6 changes: 4 additions & 2 deletions sit/Cargo.toml
Expand Up @@ -35,7 +35,8 @@ blake2 = { version = "0.7", optional = true }
hex = { version = "0.3", optional = true }
lazy_static = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
sit-core = { path = "../sit-core", version = "0.5.0-pre", features = ["git"] }
git2 = { version = "0.7", optional = true, default-features = false }
sit-core = { path = "../sit-core", version = "0.5.0-pre" }

[dev-dependencies]
cli_test_dir = "0.1.5"
Expand All @@ -47,7 +48,8 @@ include_dir = "0.1"
fs_extra = "1.1"

[features]
default = ["deprecated-items", "web"]
default = ["deprecated-items", "web", "git"]
windows7 = ["sit-core/windows7"]
deprecated-items = ["sit-core/deprecated-item-api"]
web = ["rouille", "mime_guess", "digest", "blake2", "hex", "lazy_static", "serde_derive" ]
git = ["git2"]
1 change: 1 addition & 0 deletions sit-core/src/cfg.rs → sit/src/cfg.rs
@@ -1,4 +1,5 @@
//! Client configuration
#[cfg(feature = "git")]
use std::path::PathBuf;

#[derive(Clone, Serialize, Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion sit/src/command_items.rs
@@ -1,5 +1,6 @@
use clap::ArgMatches;
use sit_core::{self, reducers::duktape::DuktapeReducer, Repository, record::RecordContainerReduction, cfg::Configuration};
use sit_core::{self, reducers::duktape::DuktapeReducer, Repository, record::RecordContainerReduction};
use cfg::Configuration;
use serde_json;
use rayon::prelude::*;
use super::get_named_expression;
Expand Down
2 changes: 1 addition & 1 deletion sit/src/command_record.rs
Expand Up @@ -3,7 +3,7 @@ use chrono::prelude::*;
use clap::{self, ArgMatches};
use dunce;
use serde_json;
use sit_core::cfg::{self, Configuration};
use cfg::{self, Configuration};
use sit_core::{
record::{BoxedOrderedFiles, OrderedFiles, RecordOwningContainer},
Record, Repository
Expand Down
3 changes: 2 additions & 1 deletion sit/src/command_records.rs
@@ -1,5 +1,6 @@
use clap::ArgMatches;
use sit_core::{Repository, Record, cfg::Configuration, record::RecordContainer, record::OrderedFiles, path::HasPath};
use sit_core::{Repository, Record, record::RecordContainer, record::OrderedFiles, path::HasPath};
use cfg::Configuration;
use serde_json;
use super::get_named_expression;
use jmespath;
Expand Down
4 changes: 2 additions & 2 deletions sit/src/command_reduce.rs
@@ -1,7 +1,7 @@
use clap::{ArgMatches, Values};
use sit_core::{self, Repository, record::RecordContainerReduction, repository, cfg::Configuration,
use sit_core::{self, Repository, record::RecordContainerReduction, repository,
reducers::duktape, path::{HasPath, ResolvePath}};

use cfg::Configuration;
use serde_json;
use super::get_named_expression;
use jmespath;
Expand Down
8 changes: 5 additions & 3 deletions sit/src/command_web.rs
@@ -1,5 +1,6 @@
use clap::{self, ArgMatches};
use sit_core::{Repository, cfg::Configuration, repository};
use sit_core::{Repository, repository};
use cfg::Configuration;
use std::path::PathBuf;

pub fn command<MI: 'static + Send + Sync >(repo: Repository<MI>, matches: &ArgMatches, main_matches: ArgMatches<'static>, config: Configuration) -> i32
Expand All @@ -13,6 +14,7 @@ pub fn command<MI: 'static + Send + Sync >(repo: Repository<MI>, matches: &ArgMa
}

mod webapp {
use cfg;
#[allow(dead_code)]
mod assets {
include!(concat!(env!("OUT_DIR"), "/web_assets.rs"));
Expand Down Expand Up @@ -140,7 +142,7 @@ mod webapp {
}


fn new_record<C: RecordOwningContainer, MI>(container: &C, request: &Request, repo: &Repository<MI>, config: &sit_core::cfg::Configuration, matches: &ArgMatches) -> Result<C::Record, String> {
fn new_record<C: RecordOwningContainer, MI>(container: &C, request: &Request, repo: &Repository<MI>, config: &cfg::Configuration, matches: &ArgMatches) -> Result<C::Record, String> {
let mut multipart = get_multipart_input(request).expect("multipart request");
let mut link = true;
let mut used_files = vec![];
Expand Down Expand Up @@ -274,7 +276,7 @@ mod webapp {
}


pub fn start<A: ToSocketAddrs, MI: 'static + Send + Sync>(addr: A, config: sit_core::cfg::Configuration, repo: Repository<MI>, readonly: bool, overlays: Vec<&str>, matches: ArgMatches<'static>)
pub fn start<A: ToSocketAddrs, MI: 'static + Send + Sync>(addr: A, config: cfg::Configuration, repo: Repository<MI>, readonly: bool, overlays: Vec<&str>, matches: ArgMatches<'static>)
where MI: sit_core::repository::ModuleIterator<PathBuf, sit_core::repository::Error> {
let mut overlays: Vec<_> = overlays.iter().map(|o| PathBuf::from(o)).collect();
let assets: PathBuf = repo.path().join("web").into();
Expand Down
5 changes: 4 additions & 1 deletion sit/src/lib.rs
@@ -1,7 +1,10 @@
extern crate sit_core;
extern crate which;
#[cfg(feature = "git")] extern crate git2;
#[macro_use] extern crate serde_derive;
extern crate serde_json;
#[macro_use] extern crate derive_error;
mod cli;
mod module_iter;

pub mod cfg;
pub use module_iter::{ScriptModuleIterator, ScriptModule};
8 changes: 4 additions & 4 deletions sit/src/main.rs
Expand Up @@ -17,8 +17,8 @@ extern crate walkdir;
extern crate yaml_rust;

extern crate config;
use sit_core::cfg;

mod cfg;
mod rebuild;
use rebuild::rebuild_repository;
mod command_config;
Expand Down Expand Up @@ -75,9 +75,9 @@ extern crate hex;
#[cfg(feature="web")]
#[macro_use]
extern crate lazy_static;
#[cfg(feature="web")]
#[macro_use]
extern crate serde_derive;

#[cfg(feature = "git")] extern crate git2;
#[macro_use] extern crate serde_derive;

use std::collections::HashMap;
pub fn get_named_expression<S: AsRef<str>, MI>(name: S, repo: &sit_core::Repository<MI>,
Expand Down

0 comments on commit d142a1a

Please sign in to comment.