copy necessary headers instead of conditional include
MODIFY
build.rs
build.rs
@@ -98,6 +98,8 @@ fn build_wrapper(opencv_header_dir: &PathBuf) -> Result<(), Box<dyn Error>> {
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
let out_dir_as_str = out_dir.to_str().unwrap();
let mut hub_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?).join("src");
+ let target_hub_dir = hub_dir.join("opencv");
+ let target_module_dir = target_hub_dir.join("hub");
let manual_dir = hub_dir.join("manual");
if cfg!(feature = "opencv-32") {
hub_dir.push("opencv_32");
@@ -371,6 +373,17 @@ fn build_wrapper(opencv_header_dir: &PathBuf) -> Result<(), Box<dyn Error>> {
for entry in glob(&format!("{}/*.rs", out_dir_as_str))? {
let _ = fs::remove_file(entry?);
}
+ for entry in glob(&format!("{}/*.rs", target_module_dir.to_str().unwrap()))? {
+ let _ = fs::remove_file(entry?);
+ }
+ for entry in glob(&format!("{}/*.rs", hub_dir.to_str().unwrap()))? {
+ let entry = entry?;
+ let _ = fs::copy(&entry, target_hub_dir.join(entry.file_name().unwrap()))?;
+ }
+ for entry in glob(&format!("{}/*.rs", module_dir.to_str().unwrap()))? {
+ let entry = entry?;
+ let _ = fs::copy(&entry, target_module_dir.join(entry.file_name().unwrap()))?;
+ }
Ok(())
}

MODIFY
src/lib.rs
src/lib.rs
extern crate cpp;
pub use error::{Error, Result};
-#[cfg(feature = "opencv-34")]
-pub use opencv_34::hub::*;
-#[cfg(feature = "opencv-41")]
-pub use opencv_41::hub::*;
+
+pub use crate::opencv::hub::*;
#[macro_use]
mod templ;
-#[cfg(feature = "opencv-34")]
-mod opencv_34;
-#[cfg(feature = "opencv-41")]
-mod opencv_41;
+mod opencv;
mod manual;
mod error;

ADD
src/opencv/.gitignore
+hub.rs
+hub/*.rs

ADD
src/opencv/mod.rs
+#[allow(unused_imports, non_snake_case, dead_code)]
+#[allow(non_upper_case_globals, overflowing_literals)]
+#[allow(non_camel_case_types)]
+pub mod hub;

copy necessary headers instead of conditional include