diff --git a/crates/biliup/Cargo.toml b/crates/biliup/Cargo.toml index f5cd8f2..ac1bbcc 100644 --- a/crates/biliup/Cargo.toml +++ b/crates/biliup/Cargo.toml @@ -48,15 +48,18 @@ m3u8-rs = "5.0.3" nom = "7" chrono = "0.4" byteorder = "1.4.3" -indexmap = "2.1.0" +indexmap = { version = "2.1.0", optional = true } regex = "1.6.0" async-trait = "0.1.57" humantime = "2.1.0" -axum = "0.7.3" -tower-http = { version = "0.5.0", features = ["cors"] } +axum = { version = "0.7.3", optional = true } +tower-http = { version = "0.5.0", features = ["cors"], optional = true} reqwest = { version = "0.11", default-features = false, features = ["json", "stream", "blocking", "deflate", "gzip", "rustls-tls"] } -sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "sqlite" ] } +sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "sqlite" ], optional = true} [build-dependencies] native-tls = { version = "0.2.11", features = ["vendored"] } openssl = { version = "0.10.42", features = ["vendored"] } + +[features] +server = ["indexmap", "axum", "tower-http", "sqlx"] diff --git a/crates/biliup/src/lib.rs b/crates/biliup/src/lib.rs index db485f7..973da36 100644 --- a/crates/biliup/src/lib.rs +++ b/crates/biliup/src/lib.rs @@ -9,6 +9,7 @@ use tracing::info; pub mod client; pub mod downloader; pub mod error; +#[cfg(feature = "server")] pub mod server; pub mod uploader; diff --git a/crates/bin/cli.rs b/crates/bin/cli.rs index 4ed641c..5828623 100644 --- a/crates/bin/cli.rs +++ b/crates/bin/cli.rs @@ -100,6 +100,7 @@ pub enum Commands { #[arg(long)] split_time: Option, }, + #[cfg(feature = "server")] /// 启动web服务,默认端口19159 Server { /// Specify bind address diff --git a/crates/bin/main.rs b/crates/bin/main.rs index 48df246..a4d24c3 100644 --- a/crates/bin/main.rs +++ b/crates/bin/main.rs @@ -1,5 +1,6 @@ mod cli; mod downloader; +#[cfg(feature = "server")] mod server; mod uploader; @@ -73,6 +74,7 @@ async fn main() -> Result<()> { split_size, split_time, } => download(&url, output, split_size, split_time).await?, + #[cfg(feature = "server")] Commands::Server { bind, port } => server::run((&bind, port)).await?, Commands::List { is_pubing,