From a8a3b93043a1cbcf392cbef568e92ecc0a78d0ce Mon Sep 17 00:00:00 2001 From: Ivan Avdeev Date: Mon, 21 Apr 2025 17:33:14 +0300 Subject: [PATCH] Merge pull request #27239 from avdivan:4.x Android-SDK: check flag IPP package #27239 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- platforms/android/build_sdk.py | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/platforms/android/build_sdk.py b/platforms/android/build_sdk.py index 3a920c78f1..be78722334 100755 --- a/platforms/android/build_sdk.py +++ b/platforms/android/build_sdk.py @@ -380,7 +380,40 @@ def get_ndk_dir(): return android_sdk_ndk_bundle return None +def check_cmake_flag_enabled(cmake_file, flag_name, strict=True): + print(f"Checking build flag '{flag_name}' in: {cmake_file}") + + if not os.path.isfile(cmake_file): + msg = f"ERROR: File {cmake_file} does not exist." + if strict: + print(msg) + sys.exit(1) + else: + print("WARNING:", msg) + return + with open(cmake_file, 'r') as file: + for line in file: + if line.strip().startswith(f"{flag_name}="): + value = line.strip().split('=')[1] + if value == '1': + print(f"{flag_name}=1 found. Support is enabled.") + return + else: + msg = f"ERROR: {flag_name} is set to {value}, expected 1." + if strict: + print(msg) + sys.exit(1) + else: + print("WARNING:", msg) + return + msg = f"ERROR: {flag_name} not found in {os.path.basename(cmake_file)}." + if strict: + print(msg) + sys.exit(1) + else: + print("WARNING:", msg) + #=================================================================================================== if __name__ == "__main__": @@ -407,6 +440,7 @@ if __name__ == "__main__": parser.add_argument('--no_media_ndk', action="store_true", help="Do not link Media NDK (required for video I/O support)") parser.add_argument('--hwasan', action="store_true", help="Enable Hardware Address Sanitizer on ARM64") parser.add_argument('--disable', metavar='FEATURE', default=[], action='append', help='OpenCV features to disable (add WITH_*=OFF). To disable multiple, specify this flag again, e.g. "--disable TBB --disable OPENMP"') + parser.add_argument('--no-strict-dependencies',action='store_false',dest='strict_dependencies',help='Disable strict dependency checking (default: strict mode ON)') args = parser.parse_args() log.basicConfig(format='%(message)s', level=log.DEBUG) @@ -485,9 +519,15 @@ if __name__ == "__main__": os.chdir(builder.libdest) builder.clean_library_build_dir() builder.build_library(abi, do_install, args.no_media_ndk) + + #Check HAVE_IPP x86 / x86_64 + if abi.haveIPP(): + log.info("Checking HAVE_IPP for ABI: %s", abi.name) + check_cmake_flag_enabled(os.path.join(builder.libdest,"CMakeVars.txt"), "HAVE_IPP", strict=args.strict_dependencies) builder.gather_results() - + + if args.build_doc: builder.build_javadoc()