mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2025-02-17 15:23:15 +03:00
78 lines
2.1 KiB
Plaintext
78 lines
2.1 KiB
Plaintext
import android.databinding.tool.ext.capitalizeUS
|
|
import com.github.kr328.golang.GolangBuildTask
|
|
import com.github.kr328.golang.GolangPlugin
|
|
|
|
plugins {
|
|
kotlin("android")
|
|
id("com.android.library")
|
|
id("kotlinx-serialization")
|
|
id("golang-android")
|
|
}
|
|
|
|
val golangSource = file("src/main/golang/native")
|
|
|
|
golang {
|
|
sourceSets {
|
|
create("alpha") {
|
|
tags.set(listOf("foss","with_gvisor","cmfa"))
|
|
srcDir.set(file("src/foss/golang"))
|
|
}
|
|
create("meta") {
|
|
tags.set(listOf("foss","with_gvisor","cmfa"))
|
|
srcDir.set(file("src/foss/golang"))
|
|
}
|
|
all {
|
|
fileName.set("libclash.so")
|
|
packageName.set("cfa/native")
|
|
}
|
|
}
|
|
}
|
|
|
|
android {
|
|
productFlavors {
|
|
all {
|
|
externalNativeBuild {
|
|
cmake {
|
|
arguments("-DGO_SOURCE:STRING=${golangSource}")
|
|
arguments("-DGO_OUTPUT:STRING=${GolangPlugin.outputDirOf(project, null, null)}")
|
|
arguments("-DFLAVOR_NAME:STRING=$name")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
externalNativeBuild {
|
|
cmake {
|
|
path = file("src/main/cpp/CMakeLists.txt")
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(project(":common"))
|
|
|
|
implementation(libs.androidx.core)
|
|
implementation(libs.kotlin.coroutine)
|
|
implementation(libs.kotlin.serialization.json)
|
|
}
|
|
|
|
afterEvaluate {
|
|
tasks.withType(GolangBuildTask::class.java).forEach {
|
|
it.inputs.dir(golangSource)
|
|
}
|
|
}
|
|
|
|
val abis = listOf("arm64-v8a" to "Arm64V8a", "armeabi-v7a" to "ArmeabiV7a", "x86" to "X86", "x86_64" to "X8664")
|
|
|
|
androidComponents.onVariants { variant ->
|
|
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")
|
|
}
|
|
}
|
|
}
|
|
} |