Skip to content

Commit 921fa4a

Browse files
committed
Cleanup
1 parent 639e0c8 commit 921fa4a

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

binding-generator/src/class.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
255255
}
256256

257257
pub fn all_bases(&self) -> HashSet<Class<'tu, 'ge>> {
258+
#![allow(clippy::mutable_key_type)]
258259
#[allow(clippy::unnecessary_to_owned)]
259260
self
260261
.bases()
@@ -276,6 +277,7 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
276277
}
277278

278279
pub fn descendants(&self) -> HashSet<Class<'tu, 'ge>> {
280+
#![allow(clippy::mutable_key_type)]
279281
match self {
280282
&Self::Clang { gen_env, .. } => gen_env
281283
.descendants_of(&self.cpp_name(CppNameStyle::Reference))
@@ -287,6 +289,7 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
287289
}
288290

289291
pub fn all_descendants(&self) -> HashSet<Class<'tu, 'ge>> {
292+
#![allow(clippy::mutable_key_type)]
290293
self
291294
.descendants()
292295
.into_iter()
@@ -299,6 +302,7 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
299302
}
300303

301304
pub fn all_family(&self) -> HashSet<Class<'tu, 'ge>> {
305+
#![allow(clippy::mutable_key_type)]
302306
fn collect<'tu, 'ge>(out: &mut HashSet<Class<'tu, 'ge>>, cls: Class<'tu, 'ge>) {
303307
if out.insert(cls.clone()) {
304308
#[allow(clippy::unnecessary_to_owned)]

build.rs

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ mod library;
2727

2828
type Result<T, E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
2929

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
3131

32+
// replace `Lazy` with `LazyLock` when MSRV is 1.80.0
3233
static OUT_DIR: Lazy<PathBuf> = Lazy::new(|| PathBuf::from(env::var_os("OUT_DIR").expect("Can't read OUT_DIR env var")));
3334
static MANIFEST_DIR: Lazy<PathBuf> =
3435
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) {
288289
let mut cc = build_compiler(opencv);
289290
eprintln!("=== Compiler information: {:#?}", cc.get_compiler());
290291
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+
}
291364
for module in modules.iter() {
292365
println!("cargo:rustc-cfg=ocvrs_has_module_{module}");
293366
cc.file(OUT_DIR.join(format!("{module}.cpp")));
@@ -336,6 +409,9 @@ fn main() -> Result<()> {
336409

337410
let opencv = Library::probe()?;
338411
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
339415
if OPENCV_BRANCH_4.matches(&opencv.version) {
340416
println!("cargo:rustc-cfg=ocvrs_opencv_branch_4");
341417
} else if OPENCV_BRANCH_34.matches(&opencv.version) {

build/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ fn collect_generated_bindings(modules: &[String], target_module_dir: &Path, manu
223223
write_module_include(&mut hub_rs, module)?;
224224
let module_filename = format!("{module}.rs");
225225
let module_src_file = OUT_DIR.join(&module_filename);
226-
let mut module_rs = BufWriter::new(File::create(&target_module_dir.join(&module_filename))?);
226+
let mut module_rs = BufWriter::new(File::create(target_module_dir.join(&module_filename))?);
227227
// Need to wrap modules inside `mod { }` because they have top-level comments (//!) and those don't play well when
228228
// module file is include!d (as opposed to connecting the module with `mod` from the parent module).
229229
// The same doesn't apply to `sys` and `types` below because they don't contain top-level comments.

src/opencv.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
unused_parens
1010
)]
1111
#[allow(
12+
clippy::doc_lazy_continuation,
1213
clippy::double_must_use,
1314
clippy::excessive_precision,
1415
clippy::let_and_return,

0 commit comments

Comments
 (0)