@@ -338,9 +338,14 @@ fn build_wrapper(mut cc: cc::Build) {
338338}
339339
340340fn main ( ) -> Result < ( ) > {
341- println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_opencv_branch_4)" ) ; // replace with cargo:: syntax when MSRV is 1.77
342- println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_opencv_branch_34)" ) ; // replace with cargo:: syntax when MSRV is 1.77
343- println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_opencv_branch_32)" ) ; // replace with cargo:: syntax when MSRV is 1.77
341+ let args = env:: args_os ( ) . skip ( 1 ) . peekable ( ) ;
342+ if matches ! ( handle_running_binding_generator( args) ?, GenerateFullBindings :: Stop ) {
343+ return Ok ( ( ) ) ;
344+ }
345+
346+ for branch in [ "4" , "34" , "32" ] . iter ( ) {
347+ println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_opencv_branch_{branch})" ) ; // replace with cargo:: syntax when MSRV is 1.77
348+ }
344349 for module in SUPPORTED_MODULES {
345350 println ! ( "cargo:rustc-check-cfg=cfg(ocvrs_has_module_{module})" ) ; // replace with cargo:: syntax when MSRV is 1.77
346351 }
@@ -349,12 +354,6 @@ fn main() -> Result<()> {
349354 return Ok ( ( ) ) ;
350355 }
351356
352- let args = env:: args_os ( ) . skip ( 1 ) . peekable ( ) ;
353- let build_script_path = env:: current_exe ( ) ?;
354- if matches ! ( handle_running_binding_generator( args) ?, GenerateFullBindings :: Stop ) {
355- return Ok ( ( ) ) ;
356- }
357-
358357 let pkg_version = env:: var ( "CARGO_PKG_VERSION" ) . unwrap_or_else ( |_| "unknown_crate_version" . to_string ( ) ) ;
359358 eprintln ! ( "=== Crate version: {pkg_version}" ) ;
360359 eprintln ! ( "=== Environment configuration:" ) ;
@@ -428,6 +427,7 @@ fn main() -> Result<()> {
428427 setup_rerun ( ) ?;
429428
430429 let ffi_export_suffix = format ! ( "_{}" , pkg_version. replace( "." , "_" ) ) ;
430+ let build_script_path = env:: current_exe ( ) ?;
431431 let binding_generator = BindingGenerator :: new ( build_script_path) ;
432432 binding_generator. generate_wrapper ( opencv_header_dir, & opencv, & ffi_export_suffix) ?;
433433 let cc = build_compiler ( & opencv, & ffi_export_suffix) ;
0 commit comments