mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-16 12:02:18 +08:00
Improve: clean tun2socket build on tasks["clean"]
This commit is contained in:
parent
ca85a688cc
commit
12220789a3
|
@ -11,14 +11,12 @@ data class BuildConfig(
|
|||
val minSdkVersion: Int,
|
||||
) : Serializable {
|
||||
companion object {
|
||||
fun of(extension: BaseExtension, variant: BaseVariant): BuildConfig {
|
||||
fun of(abis: List<NativeAbi>, minSdkVersion: Int, variant: BaseVariant): BuildConfig {
|
||||
return BuildConfig(
|
||||
debug = variant.buildType.isDebuggable,
|
||||
premium = variant.flavorName == "premium",
|
||||
abis = extension.defaultConfig.externalNativeBuild.cmake.abiFilters
|
||||
.map { NativeAbi.parse(it) }
|
||||
.distinct(),
|
||||
minSdkVersion = extension.defaultConfig.minSdkVersion!!.apiLevel
|
||||
abis = abis,
|
||||
minSdkVersion = minSdkVersion
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,19 @@ class ClashBuildPlugin : Plugin<Project> {
|
|||
override fun apply(target: Project) {
|
||||
target.afterEvaluate {
|
||||
target.extensions.getByType(LibraryExtension::class.java).apply {
|
||||
val abis = defaultConfig.externalNativeBuild.cmake.abiFilters
|
||||
.map { NativeAbi.parse(it) }
|
||||
.distinct()
|
||||
val minSdkVersion = defaultConfig.minSdkVersion!!.apiLevel
|
||||
|
||||
target.tasks.register("cleanGolang", ClashCleanTask::class.java) {
|
||||
it.applyFrom(target, abis)
|
||||
|
||||
target.tasks.getByName("clean").dependsOn(it)
|
||||
}
|
||||
|
||||
libraryVariants.forEach { variant ->
|
||||
val config = BuildConfig.of(this, variant)
|
||||
val config = BuildConfig.of(abis, minSdkVersion, variant)
|
||||
val buildDir = target.golangBuild.resolve(variant.name)
|
||||
val capitalize = variant.name.capitalize(Locale.getDefault())
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.github.kr328.clash.tools
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Delete
|
||||
import golangSource
|
||||
|
||||
abstract class ClashCleanTask : Delete() {
|
||||
fun applyFrom(project: Project, abis: List<NativeAbi>) {
|
||||
val bridge = project.golangSource.resolve("tun2socket/bridge")
|
||||
|
||||
delete(bridge.resolve("build"))
|
||||
|
||||
abis.forEach {
|
||||
delete(bridge.resolve("build_android_${it.goArch}.go"))
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user