mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 03:33:28 +08:00
android: update 'debug' information support
This commit is contained in:
parent
b4ec8fe3ef
commit
3c1267dbe6
@ -9,7 +9,8 @@ if(DEFINED ANDROID_NDK_REVISION AND ANDROID_NDK_REVISION MATCHES "(1[56])([0-9]+
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# fixup -g option: https://github.com/opencv/opencv/issues/8460#issuecomment-434249750
|
# fixup -g option: https://github.com/opencv/opencv/issues/8460#issuecomment-434249750
|
||||||
if((INSTALL_CREATE_DISTRIB OR CMAKE_BUILD_TYPE STREQUAL "Release")
|
if(INSTALL_CREATE_DISTRIB
|
||||||
|
AND (NOT BUILD_WITH_DEBUG_INFO AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
AND NOT OPENCV_SKIP_ANDROID_G_OPTION_FIX
|
AND NOT OPENCV_SKIP_ANDROID_G_OPTION_FIX
|
||||||
)
|
)
|
||||||
if(" ${CMAKE_CXX_FLAGS} " MATCHES " -g ")
|
if(" ${CMAKE_CXX_FLAGS} " MATCHES " -g ")
|
||||||
|
@ -201,7 +201,7 @@ macro(add_android_project target path)
|
|||||||
LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}"
|
LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT (CMAKE_BUILD_TYPE MATCHES "debug"))
|
if(NOT BUILD_WITH_DEBUG_INFO AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${JNI_LIB_NAME}>")
|
add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${JNI_LIB_NAME}>")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -11,11 +11,14 @@ android {
|
|||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
packagingOptions{
|
packagingOptions {
|
||||||
doNotStrip '*.so'
|
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
|
packagingOptions {
|
||||||
|
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
|
||||||
|
}
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,15 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
packagingOptions {
|
||||||
|
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
|
||||||
|
}
|
||||||
|
}
|
||||||
release {
|
release {
|
||||||
|
packagingOptions {
|
||||||
|
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
|
||||||
|
}
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ if(ANDROID)
|
|||||||
|
|
||||||
# force strip library after the build command
|
# force strip library after the build command
|
||||||
# because samples and tests will make a copy of the library before install
|
# because samples and tests will make a copy of the library before install
|
||||||
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
if(NOT BUILD_WITH_DEBUG_INFO AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${the_module}>")
|
add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${the_module}>")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -143,6 +143,7 @@ class Builder:
|
|||||||
self.cmake_path = self.get_cmake()
|
self.cmake_path = self.get_cmake()
|
||||||
self.ninja_path = self.get_ninja()
|
self.ninja_path = self.get_ninja()
|
||||||
self.debug = True if config.debug else False
|
self.debug = True if config.debug else False
|
||||||
|
self.debug_info = True if config.debug_info else False
|
||||||
|
|
||||||
def get_cmake(self):
|
def get_cmake(self):
|
||||||
if not self.config.use_android_buildtools and check_executable(['cmake', '--version']):
|
if not self.config.use_android_buildtools and check_executable(['cmake', '--version']):
|
||||||
@ -217,6 +218,8 @@ class Builder:
|
|||||||
|
|
||||||
if self.debug:
|
if self.debug:
|
||||||
cmake_vars['CMAKE_BUILD_TYPE'] = "Debug"
|
cmake_vars['CMAKE_BUILD_TYPE'] = "Debug"
|
||||||
|
|
||||||
|
if self.debug_info: # Release with debug info
|
||||||
cmake_vars['BUILD_WITH_DEBUG_INFO'] = "ON"
|
cmake_vars['BUILD_WITH_DEBUG_INFO'] = "ON"
|
||||||
|
|
||||||
if self.config.extra_modules_path is not None:
|
if self.config.extra_modules_path is not None:
|
||||||
@ -234,7 +237,7 @@ class Builder:
|
|||||||
# full parallelism for C++ compilation tasks
|
# full parallelism for C++ compilation tasks
|
||||||
execute([self.ninja_path, "opencv_modules"])
|
execute([self.ninja_path, "opencv_modules"])
|
||||||
# limit parallelism for Gradle steps (avoid huge memory consumption)
|
# limit parallelism for Gradle steps (avoid huge memory consumption)
|
||||||
execute([self.ninja_path, '-j3', "install" if self.debug else "install/strip"])
|
execute([self.ninja_path, '-j3', "install" if (self.debug_info or self.debug) else "install/strip"])
|
||||||
|
|
||||||
def build_javadoc(self):
|
def build_javadoc(self):
|
||||||
classpaths = []
|
classpaths = []
|
||||||
@ -291,7 +294,8 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('--no_ccache', action="store_true", help="Do not use ccache during library build")
|
parser.add_argument('--no_ccache', action="store_true", help="Do not use ccache during library build")
|
||||||
parser.add_argument('--force_copy', action="store_true", help="Do not use file move during library build (useful for debug)")
|
parser.add_argument('--force_copy', action="store_true", help="Do not use file move during library build (useful for debug)")
|
||||||
parser.add_argument('--force_opencv_toolchain', action="store_true", help="Do not use toolchain from Android NDK")
|
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 for debug")
|
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)")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
log.basicConfig(format='%(message)s', level=log.DEBUG)
|
log.basicConfig(format='%(message)s', level=log.DEBUG)
|
||||||
|
@ -62,5 +62,32 @@ gradle.afterProject { project ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (you still need to re-build OpenCV with debug information to debug it)
|
||||||
|
if (true) {
|
||||||
|
gradle.println("Override doNotStrip-debug for the project ${project.name}")
|
||||||
|
project.android {
|
||||||
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
packagingOptions {
|
||||||
|
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (false || project.hasProperty("doNotStrip")) {
|
||||||
|
gradle.println("Override doNotStrip-release for the project ${project.name}")
|
||||||
|
project.android {
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
packagingOptions {
|
||||||
|
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user