fix build error and filter target arch (#443)

This commit is contained in:
ForestL 2025-02-10 19:56:23 +08:00 committed by GitHub
parent 57f043408f
commit a012d81cd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View File

@ -52,6 +52,10 @@ subprojects {
resValue("string", "release_name", "v$versionName")
resValue("integer", "release_code", "$versionCode")
ndk {
abiFilters += listOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
}
externalNativeBuild {
cmake {
abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
@ -164,6 +168,8 @@ subprojects {
abi {
isEnable = true
isUniversalApk = true
reset()
include("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
}
}
}
@ -189,4 +195,4 @@ tasks.wrapper {
file("gradle/wrapper/gradle-wrapper.properties")
.appendText("distributionSha256Sum=$sha256")
}
}
}

View File

@ -62,13 +62,17 @@ afterEvaluate {
}
}
val abis = listOf("armeabi-v7a" to "ArmeabiV7a", "arm64-v8a" to "Arm64V8a", "x86_64" to "X8664", "x86" to "X86")
val abis = listOf("arm64-v8a" to "Arm64V8a", "armeabi-v7a" to "ArmeabiV7a", "x86" to "X86", "x86_64" to "X8664")
androidComponents.onVariants { variant ->
afterEvaluate {
for ((abi, goAbi) in abis) {
val cmakeName = if (variant.buildType == "debug") "Debug" else "RelWithDebInfo"
tasks.getByName("buildCMake$cmakeName[$abi]").dependsOn(tasks.getByName("externalGolangBuild${variant.name.capitalizeUS()}$goAbi"))
val cmakeName = if (variant.buildType == "debug") "Debug" else "RelWithDebInfo"
abis.forEach { (abi, goAbi) ->
tasks.configureEach {
if (name.startsWith("buildCMake$cmakeName[$abi]")) {
dependsOn("externalGolangBuild${variant.name.capitalizeUS()}$goAbi")
println("Set up dependency: $name -> externalGolangBuild${variant.name.capitalizeUS()}$goAbi")
}
}
}
}
}