feat(build): gate DuckDB behind optional feature, support --no-default-features
This commit is contained in:
@@ -50,6 +50,18 @@ cargo fmt --check
|
||||
cargo check --workspace --locked
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> DuckDB compiles from source and takes a while. Skip it during routine
|
||||
> development when you're not touching DuckDB features:
|
||||
>
|
||||
> ```bash
|
||||
> cargo check --workspace --no-default-features
|
||||
> cargo test --workspace --no-default-features
|
||||
> pnpm tauri dev -- --no-default-features
|
||||
> ```
|
||||
>
|
||||
> Release builds and CI should always include DuckDB (omit the flag).
|
||||
|
||||
For package changes, also run:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -246,9 +246,16 @@ pnpm dev:tauri
|
||||
> skip it to speed up local builds:
|
||||
>
|
||||
> ```bash
|
||||
> # Fast checks (skip DuckDB)
|
||||
> cargo check --no-default-features
|
||||
> cargo test --no-default-features
|
||||
>
|
||||
> # Tauri dev without DuckDB
|
||||
> pnpm tauri dev -- --no-default-features
|
||||
> ```
|
||||
>
|
||||
> The `--no-default-features` flag only affects local development.
|
||||
> Release builds (`pnpm tauri build`) always include DuckDB.
|
||||
|
||||
Web version:
|
||||
|
||||
|
||||
@@ -241,6 +241,20 @@ pnpm install
|
||||
pnpm dev:tauri
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> DuckDB 从源码编译较慢。如果不涉及 DuckDB 功能,可以跳过以加速本地构建:
|
||||
>
|
||||
> ```bash
|
||||
> # 快速检查(跳过 DuckDB)
|
||||
> cargo check --no-default-features
|
||||
> cargo test --no-default-features
|
||||
>
|
||||
> # Tauri 开发模式跳过 DuckDB
|
||||
> pnpm tauri dev -- --no-default-features
|
||||
> ```
|
||||
>
|
||||
> `--no-default-features` 仅影响本地开发,发布构建(`pnpm tauri build`)始终包含 DuckDB。
|
||||
|
||||
Web 版本:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -12,6 +12,10 @@ rust-version = "1.77.2"
|
||||
name = "dbx_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[features]
|
||||
default = ["duckdb-bundled"]
|
||||
duckdb-bundled = ["duckdb", "dbx-core/duckdb-bundled"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.5.6", features = [] }
|
||||
|
||||
@@ -40,7 +44,7 @@ tauri-plugin-window-state = "2"
|
||||
redis = { version = "0.32.2", features = ["tokio-comp", "tls-rustls", "tokio-rustls-comp", "cluster-async"] }
|
||||
rustls = { version = "0.23", features = ["aws-lc-rs"] }
|
||||
portpicker = "0.1.1"
|
||||
duckdb = "1.3.2"
|
||||
duckdb = { version = "1.3.2", optional = true }
|
||||
tiberius = { version = "0.12.3", default-features = false, features = ["tds73", "chrono", "rust_decimal", "rustls", "sql-browser-tokio"] }
|
||||
tokio-util = { version = "0.7", features = ["compat"] }
|
||||
reqwest = { version = "0.12", features = ["json", "stream"] }
|
||||
@@ -51,6 +55,6 @@ russh = "0.60"
|
||||
csv = "1.4.0"
|
||||
calamine = "0.30.1"
|
||||
zip = "4.6.1"
|
||||
dbx-core = { path = "../crates/dbx-core" }
|
||||
dbx-core = { path = "../crates/dbx-core", default-features = false }
|
||||
font-kit = "0.14.3"
|
||||
tauri-plugin-clipboard-manager = "2.3.2"
|
||||
|
||||
@@ -318,6 +318,7 @@ pub async fn test_connection(state: State<'_, Arc<AppState>>, config: Connection
|
||||
drop(con);
|
||||
Ok("Connection successful".to_string())
|
||||
}
|
||||
#[cfg(feature = "duckdb-bundled")]
|
||||
DatabaseType::DuckDb => {
|
||||
if state.duckdb_existing_pool_is_usable_for_config(&config).await? {
|
||||
Ok("Connection successful".to_string())
|
||||
@@ -327,6 +328,8 @@ pub async fn test_connection(state: State<'_, Arc<AppState>>, config: Connection
|
||||
Ok("Connection successful".to_string())
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "duckdb-bundled"))]
|
||||
DatabaseType::DuckDb => Err("DuckDB support not compiled (enable duckdb-bundled feature)".to_string()),
|
||||
DatabaseType::MongoDb => {
|
||||
let native_err = match db::mongo_driver::connect(&url, connect_timeout, idle_timeout).await {
|
||||
Ok(client) => {
|
||||
@@ -522,6 +525,7 @@ pub async fn connect_db(state: State<'_, Arc<AppState>>, config: ConnectionConfi
|
||||
};
|
||||
con
|
||||
}
|
||||
#[cfg(feature = "duckdb-bundled")]
|
||||
DatabaseType::DuckDb => {
|
||||
let con = db::duckdb_driver::connect_path(&expand_tilde(&db_config.host))?;
|
||||
{
|
||||
@@ -532,6 +536,8 @@ pub async fn connect_db(state: State<'_, Arc<AppState>>, config: ConnectionConfi
|
||||
}
|
||||
PoolKind::DuckDb(con)
|
||||
}
|
||||
#[cfg(not(feature = "duckdb-bundled"))]
|
||||
DatabaseType::DuckDb => return Err("DuckDB support not compiled (enable duckdb-bundled feature)".to_string()),
|
||||
DatabaseType::MongoDb => {
|
||||
let native_err = match db::mongo_driver::connect(&url, connect_timeout, idle_timeout).await {
|
||||
Ok(client) => {
|
||||
|
||||
@@ -276,6 +276,7 @@ pub fn build_create_database_sql(options: dbx_core::db_admin_sql::CreateDatabase
|
||||
Ok(dbx_core::db_admin_sql::build_create_database_sql(options))
|
||||
}
|
||||
|
||||
#[cfg(feature = "duckdb-bundled")]
|
||||
#[tauri::command]
|
||||
pub fn build_duckdb_attach_database_sql(
|
||||
options: dbx_core::db_admin_sql::DuckDbAttachDatabaseSqlOptions,
|
||||
|
||||
@@ -394,6 +394,7 @@ pub fn run() {
|
||||
commands::query::build_search_result_where,
|
||||
commands::query::build_rename_object_sql,
|
||||
commands::query::build_create_database_sql,
|
||||
#[cfg(feature = "duckdb-bundled")]
|
||||
commands::query::build_duckdb_attach_database_sql,
|
||||
commands::query::build_drop_object_sql,
|
||||
commands::query::build_drop_table_sql,
|
||||
|
||||
Reference in New Issue
Block a user