protobufs finally are functional
This commit is contained in:
parent
2acde837c7
commit
89a64f6d6d
|
@ -27,7 +27,7 @@ android {
|
||||||
// Note: we use string primitives for dependencies rather than something fancy (like buildSrc
|
// Note: we use string primitives for dependencies rather than something fancy (like buildSrc
|
||||||
// variables) so that we can leverage the built-in lint check that alerts us about new versions
|
// variables) so that we can leverage the built-in lint check that alerts us about new versions
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(kotlin("stdlib-jdk7", KotlinCompilerVersion.VERSION))
|
implementation(kotlin("stdlib-jdk7", KotlinCompilerVersion.VERSION))
|
||||||
implementation(project(":zcash-android-welding"))
|
implementation(project(":zcash-android-welding"))
|
||||||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
|
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
|
||||||
implementation("androidx.appcompat:appcompat:1.0.0")
|
implementation("androidx.appcompat:appcompat:1.0.0")
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||||
|
|
||||||
|
apply(from = "custom-tasks.gradle.kts")
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("com.android.library")
|
||||||
id("kotlin-android-extensions")
|
id("kotlin-android-extensions")
|
||||||
|
@ -24,17 +26,15 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets["main"].java.srcDirs("build/generated/source/wire")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(kotlin("stdlib-jdk7", KotlinCompilerVersion.VERSION))
|
implementation(kotlin("stdlib-jdk7", KotlinCompilerVersion.VERSION))
|
||||||
|
implementation("com.squareup.wire:wire-runtime:2.3.0-RC1")
|
||||||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
|
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
|
||||||
implementation("com.android.support:appcompat-v7:28.0.0")
|
implementation("com.android.support:appcompat-v7:28.0.0")
|
||||||
testImplementation("junit:junit:4.12")
|
testImplementation("junit:junit:4.12")
|
||||||
androidTestImplementation("com.android.support.test:runner:1.0.2")
|
androidTestImplementation("com.android.support.test:runner:1.0.2")
|
||||||
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
|
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
val protoSrcDir = "src/main/proto"
|
||||||
|
val protoDestDir = "build/generated/source/wire"
|
||||||
|
val jniSrcDir = "src/main/rust"
|
||||||
|
val jniDestDir = "build/rust/target"
|
||||||
|
|
||||||
|
|
||||||
|
fun fileTreeWith(dir: String, vararg include: String): ConfigurableFileTree {
|
||||||
|
return fileTree(mapOf("dir" to dir, "include" to include))
|
||||||
|
}
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath("com.squareup.wire:wire-compiler:2.3.0-RC1")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
val generateProtobufClasses: TaskProvider<Task> = tasks.register("generateProtobufClasses").apply {
|
||||||
|
configure {
|
||||||
|
doFirst {
|
||||||
|
println("**** CREATING PROTOS ****")
|
||||||
|
delete(protoDestDir)
|
||||||
|
mkdir(protoDestDir)
|
||||||
|
}
|
||||||
|
description = "Generate Java classes from protocol buffer (.proto) schema files for use with Square's Wire library"
|
||||||
|
|
||||||
|
fileTreeWith(protoSrcDir, "**/*.proto").forEach { file ->
|
||||||
|
doLast {
|
||||||
|
javaexec {
|
||||||
|
main = "com.squareup.wire.WireCompiler"
|
||||||
|
classpath = buildscript.configurations.getByName("classpath")
|
||||||
|
args = listOf("--proto_path=$protoSrcDir", "--java_out=$protoDestDir", file.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inputs.files(fileTreeWith(protoSrcDir, "**/*.proto"))
|
||||||
|
outputs.files(fileTreeWith(protoDestDir, "**"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val generateJniLibs: TaskProvider<Task> = tasks.register("generateJniLibs").apply {
|
||||||
|
configure {
|
||||||
|
doFirst {
|
||||||
|
println("**** CREATING JNI LIBS ****")
|
||||||
|
delete(jniDestDir)
|
||||||
|
mkdir(jniDestDir)
|
||||||
|
}
|
||||||
|
description = "Generate *.so files for connecting to the Rust wallet logic through the JNI"
|
||||||
|
doLast {
|
||||||
|
exec {
|
||||||
|
commandLine("./build-rust.sh")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inputs.files(fileTreeWith(jniSrcDir, "**/*"))
|
||||||
|
outputs.files(fileTreeWith(jniDestDir, "**/*.so"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks["preBuild"]!!.dependsOn(generateProtobufClasses)
|
||||||
|
tasks["preBuild"]!!.dependsOn(generateJniLibs)
|
|
@ -0,0 +1,6 @@
|
||||||
|
package cash.z.wallet.sdk.proto;
|
||||||
|
message WalletData {
|
||||||
|
required string name = 1;
|
||||||
|
required int32 id = 2;
|
||||||
|
optional string emails = 3;
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ pub extern "C" fn test_response(input: *const c_char) -> c_int {
|
||||||
magic_number
|
magic_number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// JNI interface
|
/// JNI interface
|
||||||
#[cfg(target_os="android")]
|
#[cfg(target_os="android")]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|
Loading…
Reference in New Issue