mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 20:50:25 +08:00
Merge pull request #22684 from alalek:android_update
android: update build scripts
This commit is contained in:
commit
7d1589d407
@ -3,7 +3,7 @@ set(ANDROID_GRADLE_PLUGIN_VERSION "3.2.1" CACHE STRING "Android Gradle Plugin ve
|
||||
message(STATUS "Android Gradle Plugin version: ${ANDROID_GRADLE_PLUGIN_VERSION}")
|
||||
|
||||
set(KOTLIN_PLUGIN_VERSION "1.4.10" CACHE STRING "Kotlin Plugin version")
|
||||
message(STATUS "kotlin Plugin version: ${KOTLIN_GRADLE_PLUGIN_VERSION}")
|
||||
message(STATUS "Kotlin Plugin version: ${KOTLIN_PLUGIN_VERSION}")
|
||||
|
||||
if(BUILD_KOTLIN_EXTENSIONS)
|
||||
set(KOTLIN_PLUGIN_DECLARATION "apply plugin: 'kotlin-android'" CACHE STRING "Kotlin Plugin version")
|
||||
@ -50,9 +50,11 @@ endif()
|
||||
#string(REPLACE "\n" "\n${__spaces}" ANDROID_ABI_FILTER "${__spaces}${ANDROID_BUILD_ABI_FILTER}")
|
||||
#string(REPLACE REGEX "[ ]+$" "" ANDROID_ABI_FILTER "${ANDROID_ABI_FILTER}")
|
||||
set(ANDROID_ABI_FILTER "${ANDROID_BUILD_ABI_FILTER}")
|
||||
set(ANDROID_STRICT_BUILD_CONFIGURATION "true")
|
||||
configure_file("${OpenCV_SOURCE_DIR}/samples/android/build.gradle.in" "${ANDROID_BUILD_BASE_DIR}/build.gradle" @ONLY)
|
||||
|
||||
set(ANDROID_ABI_FILTER "${ANDROID_INSTALL_ABI_FILTER}")
|
||||
set(ANDROID_STRICT_BUILD_CONFIGURATION "false")
|
||||
configure_file("${OpenCV_SOURCE_DIR}/samples/android/build.gradle.in" "${ANDROID_TMP_INSTALL_BASE_DIR}/${ANDROID_INSTALL_SAMPLES_DIR}/build.gradle" @ONLY)
|
||||
install(FILES "${ANDROID_TMP_INSTALL_BASE_DIR}/${ANDROID_INSTALL_SAMPLES_DIR}/build.gradle" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}" COMPONENT samples)
|
||||
|
||||
@ -80,6 +82,15 @@ foreach(fname ${GRADLE_WRAPPER_FILES})
|
||||
install(FILES "${OpenCV_SOURCE_DIR}/platforms/android/gradle-wrapper/${fname}" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples ${__permissions})
|
||||
endforeach()
|
||||
|
||||
# force reusing of the same CMake version
|
||||
if(NOT OPENCV_SKIP_ANDROID_FORCE_CMAKE)
|
||||
if(NOT DEFINED _CMAKE_INSTALL_DIR)
|
||||
get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
|
||||
get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
|
||||
endif()
|
||||
ocv_update_file("${ANDROID_BUILD_BASE_DIR}/local.properties" "cmake.dir=${_CMAKE_INSTALL_DIR}")
|
||||
endif()
|
||||
|
||||
file(WRITE "${ANDROID_BUILD_BASE_DIR}/settings.gradle" "
|
||||
include ':opencv'
|
||||
")
|
||||
@ -94,6 +105,7 @@ include ':opencv'
|
||||
project(':opencv').projectDir = new File(opencvsdk + '/sdk')
|
||||
")
|
||||
|
||||
ocv_check_environment_variables(OPENCV_GRADLE_VERBOSE_OPTIONS)
|
||||
|
||||
macro(add_android_project target path)
|
||||
get_filename_component(__dir "${path}" NAME)
|
||||
|
@ -35,6 +35,7 @@ task clean(type: Delete) {
|
||||
// }
|
||||
//}
|
||||
|
||||
def opencv_strict_build_configuration = @ANDROID_STRICT_BUILD_CONFIGURATION@;
|
||||
|
||||
gradle.afterProject { project ->
|
||||
if (project.pluginManager.hasPlugin('com.android.application')
|
||||
@ -90,5 +91,14 @@ gradle.afterProject { project ->
|
||||
}
|
||||
}
|
||||
|
||||
// Android Gradle Plugin (AGP) 3.5+ is required
|
||||
// https://github.com/android/ndk-samples/wiki/Configure-NDK-Path
|
||||
def isNdkVersionSupported = project.android.metaClass.getProperties().find { it.name == 'ndkVersion' } != null
|
||||
if ((false || opencv_strict_build_configuration) && isNdkVersionSupported) {
|
||||
gradle.println("Override ndkVersion for the project ${project.name}")
|
||||
project.android {
|
||||
ndkVersion '@ANDROID_NDK_REVISION@'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user