How to propagate `#[cfg(ocvrs_has_module_xxx)]` to user crates
Hi I'm not sure if this is a general rust question, or something related specifically to this build.rs.
I see that modules are generated based on what the found opencv library what compiled with. So if let's say sfm is disabled, no function for the opencv::sfm modules will exists.
How to get access to that in my crate so I can do some fallback if the function wasn't generated on avoid build failure?
From my small understanding:
-
cfgcan be defined by abuild.rs, but then I would have to reimplement all of theLibrary::probe()logic. - How can I consume the library used in the build script of this repo?
An alternative would be to use features flags, but I would like to keep that as last resort.
That information is unfortunately not readily available to the dependent crates in cargo. I have manually implemented some helper macros for the OpenCV branch detection, e.g. opencv_branch_4. Maybe generating those can be automated in the build script together with the similar ones for the modules.
I see what you mean! I don't have time to investigate on that or work on a PR right now. For my use case right now I will just force the correct module to be here for now. But I will definitely need something like that on the future, so maybe I will put some work into it.
Thank for the quick reply!
Forgot to mention this, but it was implemented a while ago in v0.95.0 using opencv_has_module_<MODULE_NAME>! macros