android: update 'debug' information support

pull/14582/head
Alexander Alekhin 6 years ago
parent b4ec8fe3ef
commit 3c1267dbe6
  1. 3
      cmake/android/OpenCVDetectAndroidSDK.cmake
  2. 4
      cmake/android/android_ant_projects.cmake
  3. 7
      modules/java/android_sdk/android_gradle_lib/build.gradle
  4. 8
      modules/java/android_sdk/build.gradle.in
  5. 2
      modules/java/jni/CMakeLists.txt
  6. 8
      platforms/android/build_sdk.py
  7. 27
      samples/android/build.gradle.in

@ -9,7 +9,8 @@ if(DEFINED ANDROID_NDK_REVISION AND ANDROID_NDK_REVISION MATCHES "(1[56])([0-9]+
endif()
# 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
)
if(" ${CMAKE_CXX_FLAGS} " MATCHES " -g ")

@ -201,8 +201,8 @@ macro(add_android_project target path)
LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}"
)
if (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}>")
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}>")
endif()
endif()
endif()

@ -11,11 +11,14 @@ android {
buildTypes {
debug {
packagingOptions{
doNotStrip '*.so'
packagingOptions {
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
}
}
release {
packagingOptions {
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}

@ -102,7 +102,15 @@ android {
}
buildTypes {
debug {
packagingOptions {
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
}
}
release {
packagingOptions {
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}

@ -77,7 +77,7 @@ if(ANDROID)
# force strip library after the build command
# 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}>")
endif()
endif()

@ -143,6 +143,7 @@ class Builder:
self.cmake_path = self.get_cmake()
self.ninja_path = self.get_ninja()
self.debug = True if config.debug else False
self.debug_info = True if config.debug_info else False
def get_cmake(self):
if not self.config.use_android_buildtools and check_executable(['cmake', '--version']):
@ -217,6 +218,8 @@ class Builder:
if self.debug:
cmake_vars['CMAKE_BUILD_TYPE'] = "Debug"
if self.debug_info: # Release with debug info
cmake_vars['BUILD_WITH_DEBUG_INFO'] = "ON"
if self.config.extra_modules_path is not None:
@ -234,7 +237,7 @@ class Builder:
# 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 else "install/strip"])
execute([self.ninja_path, '-j3', "install" if (self.debug_info or self.debug) else "install/strip"])
def build_javadoc(self):
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('--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('--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()
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…
Cancel
Save