From 43666e13083f3a999aecc45d6fa8864958fb9310 Mon Sep 17 00:00:00 2001 From: Michael Klatis Date: Wed, 27 Mar 2024 05:10:40 -0700 Subject: [PATCH] Merge pull request #25190 from klatism:android-config-flags-enhancement Add component disable flag to android build #25190 Adding --disable flag to android sdk build script. The flag allows to exclude components from build by concatting -DWITH_XXX cmake flag to the build command. Example : --disable OPENEXR (uppercase). - [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 - [X] 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platforms/android/build_sdk.py b/platforms/android/build_sdk.py index ba739a9495..6e03698a5e 100755 --- a/platforms/android/build_sdk.py +++ b/platforms/android/build_sdk.py @@ -161,6 +161,7 @@ class Builder: self.opencl = True if config.opencl else False self.no_kotlin = True if config.no_kotlin else False self.shared = True if config.shared else False + self.disable = args.disable def get_cmake(self): if not self.config.use_android_buildtools and check_executable(['cmake', '--version']): @@ -265,6 +266,10 @@ class Builder: cmake_vars['WITH_ANDROID_MEDIANDK'] = "OFF" cmake_vars.update(abi.cmake_vars) + + if len(self.disable) > 0: + cmake_vars.update({'WITH_%s' % f : "OFF" for f in self.disable}) + cmd += [ "-D%s='%s'" % (k, v) for (k, v) in cmake_vars.items() if v is not None] cmd.append(self.opencvdir) execute(cmd) @@ -375,6 +380,7 @@ if __name__ == "__main__": parser.add_argument('--no_kotlin', action="store_true", help="Disable Kotlin extensions") parser.add_argument('--shared', action="store_true", help="Build shared libraries") parser.add_argument('--no_media_ndk', action="store_true", help="Do not link Media NDK (required for video I/O support)") + 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"') args = parser.parse_args() log.basicConfig(format='%(message)s', level=log.DEBUG)