@@ -7,21 +7,34 @@ const OS: &str = "linux";
77#[ cfg( not( any( target_os = "linux" , target_os = "macos" ) ) ) ]
88const OS : & str = "undefined" ;
99
10- #[ cfg( feature = "electrs_0_8_10" ) ]
11- const VERSION : & str = "v0.8.10" ;
10+ // An explicit version of Electrs must be selected by enabling some feature.
11+ // We check this here instead of in `lib.rs` because this file is included in `build.rs`.
12+ #[ cfg( all(
13+ not( feature = "electrs_0_8_10" ) ,
14+ not( feature = "electrs_0_9_1" ) ,
15+ not( feature = "electrs_0_9_11" ) ,
16+ not( feature = "electrs_0_10_6" ) ,
17+ not( feature = "esplora_a33e97e1" ) ,
18+ ) ) ]
19+ compile_error ! ( "enable a feature in order to select the version of Electrs to use" ) ;
1220
13- #[ cfg( feature = "esplora_a33e97e1" ) ]
14- const VERSION : & str = "esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254" ;
21+ #[ cfg( feature = "electrs_0_10_6" ) ]
22+ const VERSION : & str = "v0.10.6" ;
23+
24+ #[ cfg( all( feature = "electrs_0_9_11" , not( feature = "electrs_0_10_6" ) ) ) ]
25+ const VERSION : & str = "v0.9.11" ;
1526
16- #[ cfg( feature = "electrs_0_9_1" ) ]
27+ #[ cfg( all ( feature = "electrs_0_9_1" , not ( feature = "electrs_0_9_11" ) ) ) ]
1728const VERSION : & str = "v0.9.1" ;
1829
19- #[ cfg( feature = "electrs_0_9_11" ) ]
20- const VERSION : & str = "v0.9.11 " ;
30+ #[ cfg( all ( feature = "electrs_0_8_10" , not ( feature = "electrs_0_9_1" ) ) ) ]
31+ const VERSION : & str = "v0.8.10 " ;
2132
22- #[ cfg( feature = "electrs_0_10_6" ) ]
23- const VERSION : & str = "v0.10.6 " ;
33+ #[ cfg( all ( feature = "esplora_a33e97e1" , not ( feature = "electrs_0_8_10" ) ) ) ]
34+ const VERSION : & str = "esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254 " ;
2435
36+ /// This is meaningless but we need it otherwise we can't get far enough into
37+ /// the build process to trigger the `compile_error!` above.
2538#[ cfg( not( any(
2639 feature = "electrs_0_8_10" ,
2740 feature = "electrs_0_9_1" ,
@@ -31,10 +44,6 @@ const VERSION: &str = "v0.10.6";
3144) ) ) ]
3245const VERSION : & str = "NA" ;
3346
34- #[ allow( unused) ] // this is not used in `build.rs`
35- pub const USE_LEGACY_COOKIE : bool =
36- cfg ! ( all( feature = "esplora_a33e97e1" , not( feature = "electrs_0_8_10" ) ) ) ;
37-
3847pub const HAS_FEATURE : bool = cfg ! ( any(
3948 feature = "electrs_0_8_10" ,
4049 feature = "electrs_0_9_1" ,
@@ -44,3 +53,20 @@ pub const HAS_FEATURE: bool = cfg!(any(
4453) ) ;
4554
4655pub fn electrs_name ( ) -> String { format ! ( "electrs_{}_{}" , OS , VERSION ) }
56+
57+ pub ( crate ) const IS_ELECTRS_0_8_10 : bool =
58+ cfg ! ( all( feature = "electrs_0_8_10" , not( feature = "electrs_0_9_1" ) ) ) ;
59+
60+ pub ( crate ) const IS_ELECTRS_0_9_1 : bool =
61+ cfg ! ( all( feature = "electrs_0_9_1" , not( feature = "electrs_0_9_11" ) ) ) ;
62+
63+ const IS_ESPLORA : bool = cfg ! ( all( feature = "esplora_a33e97e1" , not( feature = "electrs_0_8_10" ) ) ) ;
64+
65+ #[ allow( unused) ] // this is not used in `build.rs`
66+ pub const USE_LEGACY_COOKIE : bool = IS_ESPLORA ;
67+
68+ #[ allow( unused) ] // this is not used in `build.rs`
69+ pub const USE_JSONRPC_IMPORT : bool = IS_ELECTRS_0_8_10 || IS_ESPLORA ;
70+
71+ #[ allow( unused) ] // this is not used in `build.rs`
72+ pub const USE_VERBOSE_ARG : bool = IS_ELECTRS_0_8_10 || IS_ELECTRS_0_9_1 || IS_ESPLORA ;
0 commit comments