Chore: 恢复 golang-android 插件自动构建 Go 内核
Build Unsigned / BuildUnsigned (push) Waiting to run

- 本地发布 Kr328/golang-android-plugin 1.0.4 (cc84891) 到 mavenLocal

- 恢复插件及 golang 配置,移除手工 GO_OUTPUT 与 jniLibs 配置

- 为 GolangBuildTask 注入 GOFLAGS=-ldflags=-checklinkname=0(Go 1.23+ 需要)

- 验证 assembleFossDebug:插件自动构建 4 个 ABI 的 libclash.so 并打包进 APK
This commit is contained in:
tongtong committed 2026-11-26 13:46:45 +08:00
1 parent dce9562944
commit 5e088748f9
3 files changed
+27 -32

No files matched your search

+25 -30
View File
@@ -1,5 +1,5 @@
//import com.github.kr328.golang.GolangBuildTask
//import com.github.kr328.golang.GolangPlugin
import com.github.kr328.golang.GolangBuildTask
import com.github.kr328.golang.GolangPlugin
import java.io.FileOutputStream
import java.net.URL
import java.time.Duration
@@ -8,7 +8,7 @@ plugins {
kotlin("android")
id("com.android.library")
id("kotlinx-serialization")
// id("golang-android")
id("golang-android")
}
val geoipDatabaseUrl =
@@ -17,22 +17,22 @@ val geoipInvalidate = Duration.ofDays(7)!!
val geoipOutput = buildDir.resolve("intermediates/golang_blob")
val golangSource = file("src/main/golang/native")
//golang {
// sourceSets {
// create("foss") {
// tags.set(listOf("foss"))
// srcDir.set(file("src/foss/golang"))
// }
// create("premium") {
// tags.set(listOf("premium", "without_gvisor", "without_system"))
// srcDir.set(file("src/premium/golang"))
// }
// all {
// fileName.set("libclash.so")
// packageName.set("cfa/native")
// }
// }
//}
golang {
sourceSets {
create("foss") {
tags.set(listOf("foss"))
srcDir.set(file("src/foss/golang"))
}
create("premium") {
tags.set(listOf("premium", "without_gvisor", "without_system"))
srcDir.set(file("src/premium/golang"))
}
all {
fileName.set("libclash.so")
packageName.set("cfa/native")
}
}
}
android {
productFlavors {
@@ -40,7 +40,7 @@ android {
externalNativeBuild {
cmake {
arguments("-DGO_SOURCE:STRING=${golangSource}")
arguments("-DGO_OUTPUT:STRING=${rootProject.buildDir}/golang")
arguments("-DGO_OUTPUT:STRING=${GolangPlugin.outputDirOf(project, null, null)}")
arguments("-DFLAVOR_NAME:STRING=$name")
}
}
@@ -52,13 +52,6 @@ android {
path = file("src/main/cpp/CMakeLists.txt")
}
}
sourceSets {
getByName("main") {
// 手动构建的 libclash.so 通过 jniLibs 打包进 APK(原 golang 插件被禁用后需手工提供)
jniLibs.srcDir(rootProject.buildDir.resolve("golang/fossDebug"))
}
}
}
dependencies {
@@ -70,9 +63,11 @@ dependencies {
}
afterEvaluate {
// tasks.withType(GolangBuildTask::class.java).forEach {
// it.inputs.dir(golangSource)
// }
tasks.withType(GolangBuildTask::class.java).forEach {
it.inputs.dir(golangSource)
// Go 1.23+ 会拦截旧版 x/net 对 syscall 的 linkname,插件本身不传该参数,这里补上
it.environment("GOFLAGS", "-ldflags=-checklinkname=0")
}
}
task("downloadGeoipDatabase") {