mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
Add no_samples_build option to Android SDK build
This commit is contained in:
parent
f6ec0cd827
commit
a897fc91ec
@ -964,7 +964,7 @@ if(BUILD_opencv_apps)
|
||||
endif()
|
||||
|
||||
# examples
|
||||
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES OR INSTALL_C_EXAMPLES)
|
||||
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES OR INSTALL_C_EXAMPLES)
|
||||
add_subdirectory(samples)
|
||||
endif()
|
||||
|
||||
@ -1199,7 +1199,7 @@ ocv_build_features_string(apps_status
|
||||
IF BUILD_EXAMPLES THEN "examples"
|
||||
IF BUILD_opencv_apps THEN "apps"
|
||||
IF BUILD_ANDROID_SERVICE THEN "android_service"
|
||||
IF BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN "android_examples"
|
||||
IF (BUILD_ANDROID_EXAMPLES OR INSTALL_ANDROID_EXAMPLES) AND CAN_BUILD_ANDROID_PROJECTS THEN "android_examples"
|
||||
ELSE "-")
|
||||
status(" Applications:" "${apps_status}")
|
||||
ocv_build_features_string(docs_status
|
||||
|
@ -105,17 +105,29 @@ macro(add_android_project target path)
|
||||
include ':${__dir}'
|
||||
")
|
||||
|
||||
# build apk
|
||||
set(APK_FILE "${ANDROID_BUILD_BASE_DIR}/${__dir}/build/outputs/apk/release/${__dir}-${ANDROID_ABI}-release-unsigned.apk")
|
||||
ocv_update(OPENCV_GRADLE_VERBOSE_OPTIONS "-i")
|
||||
add_custom_command(
|
||||
OUTPUT "${APK_FILE}" "${OPENCV_DEPHELPER}/android_sample_${__dir}"
|
||||
COMMAND ./gradlew ${OPENCV_GRADLE_VERBOSE_OPTIONS} "${__dir}:assemble"
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${OPENCV_DEPHELPER}/android_sample_${__dir}"
|
||||
WORKING_DIRECTORY "${ANDROID_BUILD_BASE_DIR}"
|
||||
DEPENDS ${depends} opencv_java_android
|
||||
COMMENT "Building OpenCV Android sample project: ${__dir}"
|
||||
)
|
||||
if (BUILD_ANDROID_EXAMPLES)
|
||||
# build apk
|
||||
set(APK_FILE "${ANDROID_BUILD_BASE_DIR}/${__dir}/build/outputs/apk/release/${__dir}-${ANDROID_ABI}-release-unsigned.apk")
|
||||
ocv_update(OPENCV_GRADLE_VERBOSE_OPTIONS "-i")
|
||||
add_custom_command(
|
||||
OUTPUT "${APK_FILE}" "${OPENCV_DEPHELPER}/android_sample_${__dir}"
|
||||
COMMAND ./gradlew ${OPENCV_GRADLE_VERBOSE_OPTIONS} "${__dir}:assemble"
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${OPENCV_DEPHELPER}/android_sample_${__dir}"
|
||||
WORKING_DIRECTORY "${ANDROID_BUILD_BASE_DIR}"
|
||||
DEPENDS ${depends} opencv_java_android
|
||||
COMMENT "Building OpenCV Android sample project: ${__dir}"
|
||||
)
|
||||
else() # install only
|
||||
# copy samples
|
||||
add_custom_command(
|
||||
OUTPUT "${OPENCV_DEPHELPER}/android_sample_${__dir}"
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${OPENCV_DEPHELPER}/android_sample_${__dir}"
|
||||
WORKING_DIRECTORY "${ANDROID_BUILD_BASE_DIR}"
|
||||
DEPENDS ${depends} opencv_java_android
|
||||
COMMENT "Copying OpenCV Android sample project: ${__dir}"
|
||||
)
|
||||
endif()
|
||||
|
||||
file(REMOVE "${OPENCV_DEPHELPER}/android_sample_${__dir}") # force rebuild after CMake run
|
||||
|
||||
add_custom_target(android_sample_${__dir} ALL DEPENDS "${OPENCV_DEPHELPER}/android_sample_${__dir}" SOURCES "${ANDROID_SAMPLE_MANIFEST_PATH}")
|
||||
|
@ -151,6 +151,7 @@ class Builder:
|
||||
self.ninja_path = self.get_ninja()
|
||||
self.debug = True if config.debug else False
|
||||
self.debug_info = True if config.debug_info else False
|
||||
self.no_samples_build = True if config.no_samples_build else False
|
||||
|
||||
def get_cmake(self):
|
||||
if not self.config.use_android_buildtools and check_executable(['cmake', '--version']):
|
||||
@ -217,7 +218,7 @@ class Builder:
|
||||
BUILD_TESTS="OFF",
|
||||
BUILD_PERF_TESTS="OFF",
|
||||
BUILD_DOCS="OFF",
|
||||
BUILD_ANDROID_EXAMPLES="ON",
|
||||
BUILD_ANDROID_EXAMPLES=("OFF" if self.no_samples_build else "ON"),
|
||||
INSTALL_ANDROID_EXAMPLES="ON",
|
||||
)
|
||||
if self.ninja_path != 'ninja':
|
||||
@ -243,8 +244,11 @@ class Builder:
|
||||
execute(cmd)
|
||||
# full parallelism for C++ compilation tasks
|
||||
execute([self.ninja_path, "opencv_modules"])
|
||||
# limit parallelism for Gradle steps (avoid huge memory consumption)
|
||||
execute([self.ninja_path, '-j3', "install" if (self.debug_info or self.debug) else "install/strip"])
|
||||
# limit parallelism for building samples (avoid huge memory consumption)
|
||||
if self.no_samples_build:
|
||||
execute([self.ninja_path, "install" if (self.debug_info or self.debug) else "install/strip"])
|
||||
else:
|
||||
execute([self.ninja_path, "-j1" if (self.debug_info or self.debug) else "-j3", "install" if (self.debug_info or self.debug) else "install/strip"])
|
||||
|
||||
def build_javadoc(self):
|
||||
classpaths = []
|
||||
@ -323,6 +327,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument('--force_opencv_toolchain', action="store_true", help="Do not use toolchain from Android NDK")
|
||||
parser.add_argument('--debug', action="store_true", help="Build 'Debug' binaries (CMAKE_BUILD_TYPE=Debug)")
|
||||
parser.add_argument('--debug_info', action="store_true", help="Build with debug information (useful for Release mode: BUILD_WITH_DEBUG_INFO=ON)")
|
||||
parser.add_argument('--no_samples_build', action="store_true", help="Do not build samples (speeds up build)")
|
||||
args = parser.parse_args()
|
||||
|
||||
log.basicConfig(format='%(message)s', level=log.DEBUG)
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
org.gradle.jvmargs=-Xmx2g
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
|
@ -38,7 +38,7 @@ endif()
|
||||
if(UNIX AND NOT ANDROID AND (HAVE_VA OR HAVE_VA_INTEL))
|
||||
add_subdirectory(va_intel)
|
||||
endif()
|
||||
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
|
||||
if(ANDROID AND (BUILD_ANDROID_EXAMPLES OR INSTALL_ANDROID_EXAMPLES))
|
||||
add_subdirectory(android)
|
||||
endif()
|
||||
if(INSTALL_PYTHON_EXAMPLES)
|
||||
|
Loading…
Reference in New Issue
Block a user