Skip to content

Commit 186686b

Browse files
cursoragentlovasoa
andcommitted
Add odbc feature and conditional odbc-sys dependency
Co-authored-by: contact <[email protected]>
1 parent df242b4 commit 186686b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Cargo.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ lto = "fat"
1717
panic = "abort"
1818
codegen-units = 2
1919

20+
[features]
21+
# Build variants
22+
# - default (odbc-dynamic): ODBC enabled, dynamically linked (works on Linux, macOS, Windows)
23+
# - odbc-static: ODBC enabled, statically linked to the driver manager (Linux only)
24+
# - disable ODBC entirely: use `--no-default-features`
25+
default = ["odbc-dynamic"]
26+
odbc = ["sqlx/odbc"]
27+
odbc-dynamic = ["odbc"]
28+
odbc-static = ["odbc", "odbc-sys/static"]
29+
2030
[dependencies]
2131
sqlx = { package = "sqlx-oldapi", git = "https://github.com/sqlpage/sqlx-oldapi", version = "0.6.49-beta.6", default-features = false, features = [
2232
"any",
@@ -26,7 +36,6 @@ sqlx = { package = "sqlx-oldapi", git = "https://github.com/sqlpage/sqlx-oldapi"
2636
"postgres",
2737
"mysql",
2838
"mssql",
29-
"odbc",
3039
"chrono",
3140
"bigdecimal",
3241
"json",
@@ -75,6 +84,7 @@ clap = { version = "4.5.17", features = ["derive"] }
7584
tokio-util = "0.7.12"
7685
openidconnect = { version = "4.0.0", default-features = false }
7786
encoding_rs = "0.8.35"
87+
odbc-sys = { version = "0.27", optional = true }
7888

7989
[build-dependencies]
8090
awc = { version = "3", features = ["rustls-0_23-webpki-roots"] }
@@ -84,8 +94,4 @@ libflate = "2"
8494
futures-util = "0.3.21"
8595

8696
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
87-
# Enable static linking of unixODBC only on Linux/Unix, not on Windows/macOS
88-
odbc-sys = { version = "0.27", features = ["static"] }
89-
90-
[target.'cfg(any(target_os = "windows", target_os = "macos"))'.dependencies]
91-
odbc-sys = { version = "0.27" }
97+
odbc-sys = { version = "0.27", optional = true, features = [] }

0 commit comments

Comments
 (0)