mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2025-04-03 13:53:34 +03:00
Improve: clean tun2socket build on tasks["clean"]
This commit is contained in:
parent
ca85a688cc
commit
12220789a3
3 changed files with 32 additions and 6 deletions
|
@ -11,14 +11,12 @@ data class BuildConfig(
|
||||||
val minSdkVersion: Int,
|
val minSdkVersion: Int,
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
companion object {
|
companion object {
|
||||||
fun of(extension: BaseExtension, variant: BaseVariant): BuildConfig {
|
fun of(abis: List<NativeAbi>, minSdkVersion: Int, variant: BaseVariant): BuildConfig {
|
||||||
return BuildConfig(
|
return BuildConfig(
|
||||||
debug = variant.buildType.isDebuggable,
|
debug = variant.buildType.isDebuggable,
|
||||||
premium = variant.flavorName == "premium",
|
premium = variant.flavorName == "premium",
|
||||||
abis = extension.defaultConfig.externalNativeBuild.cmake.abiFilters
|
abis = abis,
|
||||||
.map { NativeAbi.parse(it) }
|
minSdkVersion = minSdkVersion
|
||||||
.distinct(),
|
|
||||||
minSdkVersion = extension.defaultConfig.minSdkVersion!!.apiLevel
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,19 @@ class ClashBuildPlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
target.afterEvaluate {
|
target.afterEvaluate {
|
||||||
target.extensions.getByType(LibraryExtension::class.java).apply {
|
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 ->
|
libraryVariants.forEach { variant ->
|
||||||
val config = BuildConfig.of(this, variant)
|
val config = BuildConfig.of(abis, minSdkVersion, variant)
|
||||||
val buildDir = target.golangBuild.resolve(variant.name)
|
val buildDir = target.golangBuild.resolve(variant.name)
|
||||||
val capitalize = variant.name.capitalize(Locale.getDefault())
|
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…
Add table
Reference in a new issue