]> Untitled Git - bdk-cli/commitdiff
Prevent building with more than one database feature enabled
authorSteve Myers <steve@notmandatory.org>
Sun, 20 Feb 2022 00:08:08 +0000 (16:08 -0800)
committerSteve Myers <steve@notmandatory.org>
Fri, 6 May 2022 18:29:09 +0000 (11:29 -0700)
build.rs

index 92e49460d05335a8b974293b82fc92c12042aa47..30c1796c13d3118ca59255f64df58e8c934d5c50 100644 (file)
--- a/build.rs
+++ b/build.rs
@@ -16,4 +16,21 @@ fn main() {
     if blockchain_features.len() > 1 {
         panic!("At most one blockchain client feature can be enabled but these features were enabled: {:?}", blockchain_features)
     }
+
+    let key_value_db =
+        env::var_os("CARGO_FEATURE_KEY_VALUE_DB").map(|_| "key-value-db".to_string());
+    let sqlite_db = env::var_os("CARGO_FEATURE_SQLITE_DB").map(|_| "sqlite-db".to_string());
+
+    let database_features: Vec<String> = vec![key_value_db, sqlite_db]
+        .iter()
+        .map(|f| f.to_owned())
+        .flatten()
+        .collect();
+
+    if database_features.len() > 1 {
+        panic!(
+            "At most one database feature can be enabled but these features were enabled: {:?}",
+            database_features
+        )
+    }
 }