@@ -6,6 +6,7 @@ use std::time::Instant;
6
6
7
7
use binding_generator:: handle_running_binding_generator;
8
8
use docs:: handle_running_in_docsrs;
9
+ use enums:: { InherentFeature , SUPPORTED_INHERENT_FEATURES , SUPPORTED_MODULES } ;
9
10
use generator:: BindingGenerator ;
10
11
use header:: IncludePath ;
11
12
use library:: Library ;
@@ -19,6 +20,8 @@ mod binding_generator;
19
20
pub mod cmake_probe;
20
21
#[ path = "build/docs.rs" ]
21
22
mod docs;
23
+ #[ path = "build/enums.rs" ]
24
+ mod enums;
22
25
#[ path = "build/generator.rs" ]
23
26
mod generator;
24
27
#[ path = "build/header.rs" ]
@@ -63,84 +66,6 @@ static AFFECTING_ENV_VARS: [&str; 18] = [
63
66
64
67
static SUPPORTED_OPENCV_BRANCHES : [ ( & str , & str ) ; 3 ] = [ ( "~3.4" , "34" ) , ( "~4" , "4" ) , ( "~5" , "5" ) ] ;
65
68
66
- static SUPPORTED_MODULES : [ SupportedModule ; 73 ] = [
67
- SupportedModule :: ThreeD ,
68
- SupportedModule :: AlphaMat ,
69
- SupportedModule :: Aruco ,
70
- SupportedModule :: ArucoDetector ,
71
- SupportedModule :: Barcode ,
72
- SupportedModule :: BgSegm ,
73
- SupportedModule :: Bioinspired ,
74
- SupportedModule :: Calib ,
75
- SupportedModule :: Calib3d ,
76
- SupportedModule :: CCalib ,
77
- SupportedModule :: Core ,
78
- SupportedModule :: CudaArithm ,
79
- SupportedModule :: CudaBgSegm ,
80
- SupportedModule :: CudaCodec ,
81
- SupportedModule :: CudaFeatures2d ,
82
- SupportedModule :: CudaFilters ,
83
- SupportedModule :: CudaImgProc ,
84
- SupportedModule :: CudaLegacy ,
85
- SupportedModule :: CudaObjDetect ,
86
- SupportedModule :: CudaOptFlow ,
87
- SupportedModule :: CudaStereo ,
88
- SupportedModule :: CudaWarping ,
89
- SupportedModule :: Cvv ,
90
- SupportedModule :: Dnn ,
91
- SupportedModule :: DnnSuperRes ,
92
- SupportedModule :: Dpm ,
93
- SupportedModule :: Face ,
94
- SupportedModule :: Features ,
95
- SupportedModule :: Features2d ,
96
- SupportedModule :: Flann ,
97
- SupportedModule :: Freetype ,
98
- SupportedModule :: Fuzzy ,
99
- SupportedModule :: Gapi ,
100
- SupportedModule :: Hdf ,
101
- SupportedModule :: Hfs ,
102
- SupportedModule :: HighGui ,
103
- SupportedModule :: ImgHash ,
104
- SupportedModule :: ImgCodecs ,
105
- SupportedModule :: ImgProc ,
106
- SupportedModule :: IntensityTransform ,
107
- SupportedModule :: LineDescriptor ,
108
- SupportedModule :: Mcc ,
109
- SupportedModule :: Ml ,
110
- SupportedModule :: ObjDetect ,
111
- SupportedModule :: OptFlow ,
112
- SupportedModule :: Ovis ,
113
- SupportedModule :: PhaseUnwrapping ,
114
- SupportedModule :: Photo ,
115
- SupportedModule :: Plot ,
116
- SupportedModule :: Quality ,
117
- SupportedModule :: Rapid ,
118
- SupportedModule :: Rgbd ,
119
- SupportedModule :: Saliency ,
120
- SupportedModule :: Sfm ,
121
- SupportedModule :: Shape ,
122
- SupportedModule :: Signal ,
123
- SupportedModule :: Stereo ,
124
- SupportedModule :: Stitching ,
125
- SupportedModule :: StructuredLight ,
126
- SupportedModule :: SuperRes ,
127
- SupportedModule :: SurfaceMatching ,
128
- SupportedModule :: Text ,
129
- SupportedModule :: Tracking ,
130
- SupportedModule :: Video ,
131
- SupportedModule :: VideoIo ,
132
- SupportedModule :: VideoStab ,
133
- SupportedModule :: Viz ,
134
- SupportedModule :: WechatQrCode ,
135
- SupportedModule :: XFeatures2d ,
136
- SupportedModule :: XImgProc ,
137
- SupportedModule :: XObjDetect ,
138
- SupportedModule :: XPhoto ,
139
- SupportedModule :: XStereo ,
140
- ] ;
141
-
142
- static SUPPORTED_INHERENT_FEATURES : [ & str ; 3 ] = [ "hfloat" , "opencl" , "cuda" ] ;
143
-
144
69
/// The contents of these vars will be present in the debug log, but will not cause the source rebuild
145
70
static DEBUG_ENV_VARS : [ & str ; 1 ] = [ "PATH" ] ;
146
71
@@ -227,18 +152,23 @@ fn emit_opencv_branch(opencv: &Library) {
227
152
}
228
153
229
154
fn emit_inherent_features ( opencv : & Library ) {
155
+ let mut fake_features = Vec :: with_capacity ( 2 ) ;
230
156
if VersionReq :: parse ( ">=4.10" )
231
157
. expect ( "Static version requirement" )
232
158
. matches ( & opencv. version )
233
159
{
234
- // hfloat is not an actual OpenCV feature specified in the cvconfig.h, but something that's supported starting with 4.10
235
- println ! ( "cargo::rustc-cfg=ocvrs_has_inherent_feature_hfloat" ) ;
236
- }
237
- for inherent_feature in & opencv. inherent_features {
238
- if SUPPORTED_INHERENT_FEATURES . contains ( & inherent_feature . as_str ( ) ) {
239
- println ! ( "cargo::rustc-cfg=ocvrs_has_inherent_feature_{inherent_feature}" ) ;
160
+ fake_features . push ( InherentFeature :: Hfloat ) ;
161
+ if VersionReq :: parse ( ">=4.11" )
162
+ . expect ( "Static version requirement" )
163
+ . matches ( & opencv. version )
164
+ {
165
+ fake_features . push ( InherentFeature :: AlgorithmHint ) ;
240
166
}
241
167
}
168
+ let detected_supported_inherent_features = opencv. inherent_features . iter ( ) . flat_map ( |f| InherentFeature :: try_from_str ( f) ) ;
169
+ for inherent_feature in detected_supported_inherent_features. chain ( fake_features) {
170
+ println ! ( "cargo::rustc-cfg=ocvrs_has_inherent_feature_{}" , inherent_feature. as_str( ) ) ;
171
+ }
242
172
}
243
173
244
174
fn emit_modules ( modules : & [ SupportedModule ] ) {
@@ -360,7 +290,10 @@ fn main() -> Result<()> {
360
290
println ! ( "cargo::rustc-check-cfg=cfg(ocvrs_has_module_{})" , module. opencv_name( ) ) ;
361
291
}
362
292
for inherent_feature in SUPPORTED_INHERENT_FEATURES {
363
- println ! ( "cargo::rustc-check-cfg=cfg(ocvrs_has_inherent_feature_{inherent_feature})" ) ;
293
+ println ! (
294
+ "cargo::rustc-check-cfg=cfg(ocvrs_has_inherent_feature_{})" ,
295
+ inherent_feature. as_str( )
296
+ ) ;
364
297
}
365
298
366
299
if matches ! ( handle_running_in_docsrs( ) , GenerateFullBindings :: Stop ) {
0 commit comments