diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-11-20 20:03:12 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-10-19 22:54:23 +0200 |
commit | 0e848735f473e58b1428ff42c5d1e5a27335b1c9 (patch) | |
tree | 770c9ae3c2db263d4a200933bcb6bd048dcb787c /tunnel/build.gradle.kts | |
parent | 119b8d362bfb12eb3cb2198b4a7d8d67e7b67a52 (diff) |
tunnel: add gRPC over unix domain socket to the go backend
With gRPC it will be easier to extend the go backend API.
In this commit the Version function is reimplemented in gRPC.
Gitignore generated protobuf files.
Diffstat (limited to 'tunnel/build.gradle.kts')
-rw-r--r-- | tunnel/build.gradle.kts | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tunnel/build.gradle.kts b/tunnel/build.gradle.kts index 589d72da..6793c3ce 100644 --- a/tunnel/build.gradle.kts +++ b/tunnel/build.gradle.kts @@ -1,5 +1,6 @@ @file:Suppress("UnstableApiUsage") +import com.google.protobuf.gradle.* import org.gradle.api.tasks.testing.logging.TestLogEvent val pkg: String = providers.gradleProperty("wireguardPackageName").get() @@ -7,6 +8,7 @@ val pkg: String = providers.gradleProperty("wireguardPackageName").get() plugins { alias(libs.plugins.android.library) `maven-publish` + alias(libs.plugins.google.protobuf) signing } @@ -67,10 +69,66 @@ android { dependencies { implementation(libs.androidx.annotation) implementation(libs.androidx.collection) + implementation(libs.grpc.android) + implementation(libs.grpc.okhttp) + implementation(libs.grpc.protobuf.lite) + implementation(libs.grpc.stub) + compileOnly(libs.javax.annotation.api) compileOnly(libs.jsr305) testImplementation(libs.junit) } +protobuf { + protoc { + // The artifact spec for the Protobuf Compiler + artifact = "com.google.protobuf:protoc:${libs.versions.protoc.get()}" + } + plugins { + // Optional: an artifact spec for a protoc plugin, with "grpc" as + // the identifier, which can be referred to in the "plugins" + // container of the "generateProtoTasks" closure. + id("grpc") { + artifact = "io.grpc:protoc-gen-grpc-java:${libs.versions.protocgengrpc.get()}" + } + id("java") { + } + } + generateProtoTasks { + all().forEach { task -> + task.plugins{ + id("grpc") { + option("lite") + } + id("java") { + option("lite") + } + } + } + } +} + +afterEvaluate({ -> + // All custom configurations created by the protobuf plugin, + // are only available at this point. + var protoc = configurations.named("protobufToolsLocator_protoc") + var protocCache = "${gradle.gradleUserHomeDir}/caches/protoc-bin-${libs.versions.protoc.get()}" + + tasks.register("copyProtoc", Copy::class) { + // Used by tunnel/tools/libwg-go/Makefile run in tools/CMakeLists.txt + from(protoc) + into(protocCache) + rename("protoc-.*", "protoc") + setFileMode(7 * 64 + 7 * 8 + 5) // 0775 + } + + tasks.named("preBuild").get().dependsOn("copyProtoc") + + // Extract duration.proto used by external library in libwg.proto + tasks.named("preDebugBuild").get().dependsOn(tasks.named("extractIncludeDebugProto").get()) + tasks.named("preReleaseBuild").get().dependsOn(tasks.named("extractIncludeReleaseProto").get()) + println("done afterEvaluate") +}) + publishing { publications { register<MavenPublication>("release") { |