855b17c2ee
修复 Android 版本编译出错问题,详细请看https://github.com/nicolastinkl/UUVPN/issues
69 lines
1.6 KiB
Kotlin
69 lines
1.6 KiB
Kotlin
import com.github.kr328.golang.GolangBuildTask
|
|
import com.github.kr328.golang.GolangPlugin
|
|
import java.io.FileOutputStream
|
|
import java.net.URL
|
|
import java.time.Duration
|
|
|
|
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 {
|
|
// 设置cmake版本
|
|
// version = "3.31.6" //macos下不需要指定 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)
|
|
}
|
|
}
|