mirror of https://github.com/auygun/kaliber.git
Get ABI codes from productFlavors and remove hard-coded strings
This commit is contained in:
parent
05252bfae8
commit
5f8f70ed53
12
README.md
12
README.md
|
@ -34,16 +34,16 @@ ninja -C out/debug demo
|
|||
|
||||
### Android:
|
||||
Build "hello_world" in debug mode for all ABIs and install. GN will be run by
|
||||
Gradle so no setup is required.
|
||||
Gradle so no setup is required. Location of gn and ninja executables can be
|
||||
specified via "gn" and "ninja" properties (-Pgn="path/gn").
|
||||
```text
|
||||
cd build/android
|
||||
./gradlew :app:installHelloWorldDebug
|
||||
./gradlew :app:installHelloWorldAllArchsDebug
|
||||
```
|
||||
Build "demo" in debug mode for x86_64 ABI and install. "targetArchs" can be set
|
||||
to any combination of Arm7, Arm8, X86_64, X86. Location of gn and ninja
|
||||
executables can also be specified via "gn" and "ninja" properties.
|
||||
Build "demo" in debug mode for x86_64 ABI and install. Valid ABI targets are
|
||||
Arm, Arm64, X86, X64, AllArchs, ArmOnly, X86Only.
|
||||
```text
|
||||
./gradlew :app:installDemoDebug -PtargetArchs="X86_64"
|
||||
./gradlew :app:installDemoX64Debug
|
||||
```
|
||||
|
||||
### Generate Visual Studio solution:
|
||||
|
|
|
@ -17,10 +17,6 @@ abstract class WriteFileTask extends DefaultTask {
|
|||
}
|
||||
|
||||
class Utils implements Plugin<Project> {
|
||||
final def ABI_CODES = ["Arm": "armeabi-v7a",
|
||||
"Arm64": "arm64-v8a",
|
||||
"X64": "x86_64",
|
||||
"X86": "x86"].asImmutable()
|
||||
final def ARCH_CODES = ["armeabi-v7a": "Arm",
|
||||
"arm64-v8a": "Arm64",
|
||||
"x86_64": "X64",
|
||||
|
@ -83,6 +79,17 @@ class Utils implements Plugin<Project> {
|
|||
return outList
|
||||
}
|
||||
|
||||
def getAbiCodeFor(String arch) {
|
||||
def outStr = ''
|
||||
project.android.productFlavors.find { flavor ->
|
||||
if (flavor.name.capitalize() == arch) {
|
||||
outStr = flavor.ndk.abiFilters.first()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return outStr
|
||||
}
|
||||
|
||||
def getGnTargetFor(String game) {
|
||||
def outStr = ''
|
||||
project.android.productFlavors.find { flavor ->
|
||||
|
@ -282,7 +289,7 @@ utils.addTask('copyJniLibsFor') { String taskName, String buildType, String arch
|
|||
include "lib${utils.getGnTargetFor(game)}.so"
|
||||
rename "lib${utils.getGnTargetFor(game)}.so", "libkaliber.so"
|
||||
}
|
||||
into "${utils.getJniLibsDir(buildType)}/${utils.ABI_CODES[arch]}"
|
||||
into "${utils.getJniLibsDir(buildType)}/${utils.getAbiCodeFor(arch)}"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,9 +298,10 @@ tasks.configureEach { task ->
|
|||
|
||||
def match = task.name =~ /^merge/ + variantPattern + /JniLibFolders$/
|
||||
if (match) {
|
||||
android.productFlavors.find { flavor ->
|
||||
if (flavor.dimension == 'arch' && flavor.name.capitalize() == match.group(2)) {
|
||||
flavor.ndk.abiFilters.each { abi ->
|
||||
android.productFlavors.find { arch ->
|
||||
if (arch.dimension == 'arch' && arch.name.capitalize() == match.group(2)) {
|
||||
// Depends on each arch type for multi-arch build flavors.
|
||||
arch.ndk.abiFilters.each { abi ->
|
||||
task.dependsOn "copyJniLibsFor${match.group(1)}${utils.ARCH_CODES[abi]}${match.group(3)}"
|
||||
}
|
||||
return true
|
||||
|
@ -303,9 +311,10 @@ tasks.configureEach { task ->
|
|||
}
|
||||
match = task.name =~ /^merge/ + variantPattern + /Assets$/
|
||||
if (match) {
|
||||
android.productFlavors.find { flavor ->
|
||||
if (flavor.dimension == 'arch' && flavor.name.capitalize() == match.group(2)) {
|
||||
flavor.ndk.abiFilters.each { abi ->
|
||||
android.productFlavors.find { arch ->
|
||||
if (arch.dimension == 'arch' && arch.name.capitalize() == match.group(2)) {
|
||||
// Depends on each arch type for multi-arch build flavors.
|
||||
arch.ndk.abiFilters.each { abi ->
|
||||
task.dependsOn "copyAssetsFor${match.group(1)}${utils.ARCH_CODES[abi]}${match.group(3)}"
|
||||
}
|
||||
return true
|
||||
|
@ -315,9 +324,10 @@ tasks.configureEach { task ->
|
|||
}
|
||||
match = task.name =~ /^lintVitalAnalyze/ + variantPattern + /$/
|
||||
if (match) {
|
||||
android.productFlavors.find { flavor ->
|
||||
if (flavor.dimension == 'arch' && flavor.name.capitalize() == match.group(2)) {
|
||||
flavor.ndk.abiFilters.each { abi ->
|
||||
android.productFlavors.find { arch ->
|
||||
if (arch.dimension == 'arch' && arch.name.capitalize() == match.group(2)) {
|
||||
// Depends on each arch type for multi-arch build flavors.
|
||||
arch.ndk.abiFilters.each { abi ->
|
||||
task.dependsOn "copyAssetsFor${match.group(1)}${utils.ARCH_CODES[abi]}${match.group(3)}"
|
||||
}
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue