For Android - change the JNI location.
This commit is contained in:
parent
d241ac7f80
commit
8aa25d6468
@ -100,11 +100,11 @@ dependencies {
|
||||
android.libraryVariants.whenObjectAdded {
|
||||
val config = name
|
||||
packageLibraryProvider.get().apply {
|
||||
// Customize bundle task to also zip the headers; and the static archive (for STATIC lib type)
|
||||
// Customize bundle task to also zip the Urho3D headers and libraries
|
||||
File(android.externalNativeBuild.cmake.buildStagingDirectory, "cmake/$config").list()?.forEach { abi ->
|
||||
listOf("include", "lib").forEach {
|
||||
from(File(android.externalNativeBuild.cmake.buildStagingDirectory, "cmake/$config/$abi/$it")) {
|
||||
into("jni/$abi/$it")
|
||||
into("urho3d/$config/$abi/$it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,25 +74,22 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D AND TARGET Urho3D)
|
||||
set (URHO3D_COMPILE_RESULT TRUE)
|
||||
else ()
|
||||
if (ANDROID)
|
||||
set (SKIP_COMPILE_TEST TRUE)
|
||||
string (TOLOWER ${CMAKE_BUILD_TYPE} config)
|
||||
if (BUILD_STAGING_DIR)
|
||||
# Another special case where library location is already known to be in the build tree of Urho3D project
|
||||
set (URHO3D_HOME ${BUILD_STAGING_DIR}/cmake/${config}/${ANDROID_ABI})
|
||||
if (URHO3D_LIB_TYPE STREQUAL STATIC)
|
||||
set (URHO3D_LIBRARIES ${URHO3D_HOME}/lib/libUrho3D.a)
|
||||
else ()
|
||||
set (URHO3D_LIBRARIES ${URHO3D_HOME}/lib/libUrho3D.so)
|
||||
endif ()
|
||||
elseif (JNI_DIR)
|
||||
# Using Urho3D AAR from Maven repository
|
||||
set (URHO3D_HOME ${JNI_DIR}/cmake/${config}/jni/${ANDROID_ABI})
|
||||
if (URHO3D_LIB_TYPE STREQUAL STATIC)
|
||||
set (URHO3D_LIBRARIES ${URHO3D_HOME}/lib/libUrho3D.a)
|
||||
else ()
|
||||
set (URHO3D_LIBRARIES ${URHO3D_HOME}/libUrho3D.so)
|
||||
endif ()
|
||||
set (URHO3D_HOME ${JNI_DIR}/urho3d/${config}/${ANDROID_ABI})
|
||||
else ()
|
||||
message (FATAL_ERROR "Neither 'BUILD_STAGING_DIR' nor 'JNI_DIR' is set")
|
||||
endif ()
|
||||
if (URHO3D_LIB_TYPE STREQUAL STATIC)
|
||||
set (URHO3D_LIBRARIES ${URHO3D_HOME}/lib/libUrho3D.a)
|
||||
else ()
|
||||
set (URHO3D_LIBRARIES ${URHO3D_HOME}/lib/libUrho3D.so)
|
||||
endif ()
|
||||
set (SKIP_COMPILE_TEST TRUE)
|
||||
elseif (NOT URHO3D_HOME AND DEFINED ENV{URHO3D_HOME})
|
||||
# Library location would be searched (based on URHO3D_HOME variable if provided and in system-wide default location)
|
||||
file (TO_CMAKE_PATH "$ENV{URHO3D_HOME}" URHO3D_HOME)
|
||||
|
35
rakefile
35
rakefile
@ -355,6 +355,12 @@ rootProject.name = "#{name}"
|
||||
end
|
||||
|
||||
def build_gradle_kts(name)
|
||||
ndk_version = '21.3.6528147'
|
||||
cmake_version = '3.17.3+'
|
||||
build_staging_dir = '.cxx'
|
||||
sdk_version = 30
|
||||
min_sdk_version = 18
|
||||
aar_version = '1.8-ALPHA-SNAPSHOT'
|
||||
type = ENV.fetch('URHO3D_LIB_TYPE', 'STATIC').downcase
|
||||
<<-EOF
|
||||
plugins {
|
||||
@ -364,11 +370,11 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
ndkVersion = "21.3.6528147"
|
||||
compileSdkVersion(30)
|
||||
ndkVersion = "#{ndk_version}"
|
||||
compileSdkVersion(#{sdk_version})
|
||||
defaultConfig {
|
||||
minSdkVersion(18)
|
||||
targetSdkVersion(30)
|
||||
minSdkVersion(#{min_sdk_version})
|
||||
targetSdkVersion(#{sdk_version})
|
||||
applicationId = "io.urho3d.#{name}"
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
@ -377,7 +383,7 @@ android {
|
||||
cmake {
|
||||
arguments.apply {
|
||||
System.getenv("ANDROID_CCACHE")?.let { add("-D ANDROID_CCACHE=$it") }
|
||||
add("-D JNI_DIR=${project.file(".cxx")}")
|
||||
add("-D JNI_DIR=${project.file("#{build_staging_dir}")}")
|
||||
// Pass along matching env-vars as CMake build options
|
||||
addAll(project.file("script/.build-options")
|
||||
.readLines()
|
||||
@ -409,9 +415,9 @@ android {
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
version = "3.17.3+"
|
||||
version = "#{cmake_version}"
|
||||
path = project.file("CMakeLists.txt")
|
||||
setBuildStagingDirectory(".cxx")
|
||||
setBuildStagingDirectory("#{build_staging_dir}")
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
@ -445,8 +451,8 @@ val urhoDebugImpl by configurations.creating { isCanBeResolved = true }
|
||||
configurations.debugImplementation.get().extendsFrom(urhoDebugImpl)
|
||||
|
||||
dependencies {
|
||||
urhoReleaseImpl("io.urho3d:urho3d-lib-#{type}:1.8-ALPHA-SNAPSHOT")
|
||||
urhoDebugImpl("io.urho3d:urho3d-lib-#{type}-debug:1.8-ALPHA-SNAPSHOT")
|
||||
urhoReleaseImpl("io.urho3d:urho3d-lib-#{type}:#{aar_version}")
|
||||
urhoDebugImpl("io.urho3d:urho3d-lib-#{type}-debug:#{aar_version}")
|
||||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$embeddedKotlinVersion")
|
||||
implementation("androidx.core:core-ktx:1.3.2")
|
||||
@ -466,13 +472,10 @@ afterEvaluate {
|
||||
dependsOn(unzipTaskName)
|
||||
}
|
||||
register<Copy>(unzipTaskName) {
|
||||
val dir = File(android.externalNativeBuild.cmake.buildStagingDirectory, "cmake/${config.toLowerCase()}")
|
||||
if (!dir.exists()) {
|
||||
val aar = configurations["urho${config}Impl"].resolve().first { it.name.startsWith("urho3d-lib") }
|
||||
from(zipTree(aar))
|
||||
include("jni/**")
|
||||
into(dir)
|
||||
}
|
||||
val aar = configurations["urho${config}Impl"].resolve().first { it.name.startsWith("urho3d-lib") }
|
||||
from(zipTree(aar))
|
||||
include("urho3d/**")
|
||||
into(android.externalNativeBuild.cmake.buildStagingDirectory)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user