@@ -27,8 +27,9 @@ mod library;
27
27
28
28
type Result < T , E = Box < dyn std:: error:: Error > > = std:: result:: Result < T , E > ;
29
29
30
- static MODULES : OnceCell < Vec < String > > = OnceCell :: new ( ) ;
30
+ static MODULES : OnceCell < Vec < String > > = OnceCell :: new ( ) ; // replace with `OnceLock` when MSRV is 1.70.0
31
31
32
+ // replace `Lazy` with `LazyLock` when MSRV is 1.80.0
32
33
static OUT_DIR : Lazy < PathBuf > = Lazy :: new ( || PathBuf :: from ( env:: var_os ( "OUT_DIR" ) . expect ( "Can't read OUT_DIR env var" ) ) ) ;
33
34
static MANIFEST_DIR : Lazy < PathBuf > =
34
35
Lazy :: new ( || PathBuf :: from ( env:: var_os ( "CARGO_MANIFEST_DIR" ) . expect ( "Can't read CARGO_MANIFEST_DIR env var" ) ) ) ;
@@ -288,6 +289,78 @@ fn build_wrapper(opencv: &Library) {
288
289
let mut cc = build_compiler ( opencv) ;
289
290
eprintln ! ( "=== Compiler information: {:#?}" , cc. get_compiler( ) ) ;
290
291
let modules = MODULES . get ( ) . expect ( "MODULES not initialized" ) ;
292
+ static SUPPORTED_MODULES : [ & str ; 67 ] = [
293
+ "alphamat" ,
294
+ "aruco" ,
295
+ "aruco_detector" ,
296
+ "barcode" ,
297
+ "bgsegm" ,
298
+ "bioinspired" ,
299
+ "calib3d" ,
300
+ "ccalib" ,
301
+ "core" ,
302
+ "cudaarithm" ,
303
+ "cudabgsegm" ,
304
+ "cudacodec" ,
305
+ "cudafeatures2d" ,
306
+ "cudafilters" ,
307
+ "cudaimgproc" ,
308
+ "cudaobjdetect" ,
309
+ "cudaoptflow" ,
310
+ "cudastereo" ,
311
+ "cudawarping" ,
312
+ "cvv" ,
313
+ "dnn" ,
314
+ "dnn_superres" ,
315
+ "dpm" ,
316
+ "face" ,
317
+ "features2d" ,
318
+ "flann" ,
319
+ "freetype" ,
320
+ "fuzzy" ,
321
+ "gapi" ,
322
+ "hdf" ,
323
+ "hfs" ,
324
+ "highgui" ,
325
+ "img_hash" ,
326
+ "imgcodecs" ,
327
+ "imgproc" ,
328
+ "intensity_transform" ,
329
+ "line_descriptor" ,
330
+ "mcc" ,
331
+ "ml" ,
332
+ "objdetect" ,
333
+ "optflow" ,
334
+ "ovis" ,
335
+ "phase_unwrapping" ,
336
+ "photo" ,
337
+ "plot" ,
338
+ "quality" ,
339
+ "rapid" ,
340
+ "rgbd" ,
341
+ "saliency" ,
342
+ "sfm" ,
343
+ "shape" ,
344
+ "stereo" ,
345
+ "stitching" ,
346
+ "structured_light" ,
347
+ "superres" ,
348
+ "surface_matching" ,
349
+ "text" ,
350
+ "tracking" ,
351
+ "video" ,
352
+ "videoio" ,
353
+ "videostab" ,
354
+ "viz" ,
355
+ "wechat_qrcode" ,
356
+ "xfeatures2d" ,
357
+ "ximgproc" ,
358
+ "xobjdetect" ,
359
+ "xphoto" ,
360
+ ] ;
361
+ for module in SUPPORTED_MODULES {
362
+ println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_has_module_{module})" ) ; // replace with cargo:: syntax when MSRV is 1.77
363
+ }
291
364
for module in modules. iter ( ) {
292
365
println ! ( "cargo:rustc-cfg=ocvrs_has_module_{module}" ) ;
293
366
cc. file ( OUT_DIR . join ( format ! ( "{module}.cpp" ) ) ) ;
@@ -336,6 +409,9 @@ fn main() -> Result<()> {
336
409
337
410
let opencv = Library :: probe ( ) ?;
338
411
eprintln ! ( "=== OpenCV library configuration: {opencv:#?}" ) ;
412
+ println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_opencv_branch_4)" ) ; // replace with cargo:: syntax when MSRV is 1.77
413
+ println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_opencv_branch_34)" ) ; // replace with cargo:: syntax when MSRV is 1.77
414
+ println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_opencv_branch_32)" ) ; // replace with cargo:: syntax when MSRV is 1.77
339
415
if OPENCV_BRANCH_4 . matches ( & opencv. version ) {
340
416
println ! ( "cargo:rustc-cfg=ocvrs_opencv_branch_4" ) ;
341
417
} else if OPENCV_BRANCH_34 . matches ( & opencv. version ) {
0 commit comments