From ba523999d52e4a70cf76d34e62405ac45d449c9f Mon Sep 17 00:00:00 2001 From: Folyd Date: Thu, 27 Feb 2020 17:12:21 +0800 Subject: [PATCH] Split dependencies with feature flags --- rust/Cargo.lock | 1 - rust/Cargo.toml | 24 +++++++++++++++--------- rust/src/bin/books-index.rs | 2 ++ rust/src/bin/crates-index.rs | 2 ++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e061f01..89bae37 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -963,7 +963,6 @@ version = "0.1.0" dependencies = [ "csv 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "minifier 0.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 049602d..3f42372 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -4,18 +4,24 @@ version = "0.1.0" authors = ["Folyd "] edition = "2018" +[features] +crates-index = ["csv","semver","tar","libflate"] +books-index = ["futures","tokio","reqwest","select"] +default = ["crates-index"] + [dependencies] serde = "1.0.102" -tokio = { version="0.2", features=["macros", "time"] } -reqwest = { version="0.10" , features=["json"] } serde_json = "1.0.41" serde_derive = "1.0.102" -futures = "0.3.1" minifier = "0.0.33" -lazy_static = "1.4.0" unicode-segmentation = "1.6.0" -select = "0.4.3" -csv = "1.1.3" -semver = { version="0.9.0", features=["ci"] } -tar = "0.4.26" -libflate = "0.1.27" +# books-index +futures = { version = "0.3.1", optional=true } +tokio = { version="0.2", features=["macros", "time"], optional=true } +reqwest = { version="0.10" , features=["json"], optional=true } +select = { version= "0.4.3", optional=true } +# crates-index +csv = { version = "1.1.3", optional=true } +semver = { version="0.9.0", features=["ci"], optional=true } +tar = { version = "0.4.26", optional=true } +libflate = { version="0.1.27", optional=true } diff --git a/rust/src/bin/books-index.rs b/rust/src/bin/books-index.rs index 333cb0f..b3f38c3 100644 --- a/rust/src/bin/books-index.rs +++ b/rust/src/bin/books-index.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "books-index")] + use std::fs; use std::path::Path; diff --git a/rust/src/bin/crates-index.rs b/rust/src/bin/crates-index.rs index 74951f2..bb25065 100644 --- a/rust/src/bin/crates-index.rs +++ b/rust/src/bin/crates-index.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "crates-index")] + use std::collections::HashMap; use std::collections::HashSet; use std::env;