Skip to content

Commit

Permalink
[Kotlin] Removed :generateCinterop task (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPestryakov authored Feb 15, 2023
1 parent 9998a8a commit 7325669
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 38 deletions.
2 changes: 0 additions & 2 deletions kotlin/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
### Tasks:

- `./gradlew :wallet-core-kotlin:generateProtos` – Generates Kotlin classes for Protos
- `./gradlew :wallet-core-kotlin:generateCinterop` – Generates def file
- `./gradlew :wallet-core-kotlin:generateFiles` – Generates all the above and Kotlin accessors to the library
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

val generateCinteropTask = task("generateCinterop") {
doFirst {
val headersDir = rootDir.parentFile.resolve("include/TrustWalletCore")
val headers = headersDir
.listFiles { file -> file.extension == "h" }
.orEmpty()
.sortedBy { it.name }
.joinToString(separator = " ") { it.name }

val defFile = projectDir.resolve("src/nativeInterop/cinterop/walletCore.def")
defFile.parentFile.mkdirs()
defFile.writeText(
text =
"""
headers = $headers
package = com.trustwallet.core
""".trimIndent(),
)
}
}

val copyProtoTask = task<Copy>("copyProtos") {
val sourceDir = rootDir.parentFile.resolve("src/proto")
val destinationDir = projectDir.resolve("build/tmp/proto")
Expand Down Expand Up @@ -76,11 +54,3 @@ val generateProtosTask = task<JavaExec>("generateProtos") {
"--kotlin_out=$destinationDir",
)
}

task<Exec>("generateFiles") {
dependsOn(generateCinteropTask)
dependsOn(generateProtosTask)

workingDir(rootDir.parentFile)
commandLine("./codegen/bin/codegen")
}
1 change: 0 additions & 1 deletion kotlin/wallet-core-kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/src/**/generated/
/src/**/proto/
/src/nativeInterop/
7 changes: 4 additions & 3 deletions kotlin/wallet-core-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
kotlin("multiplatform")
id("com.android.library")
id("convention.maven-publish")
id("convention.file-generation")
id("convention.proto-generation")
}

kotlin {
Expand Down Expand Up @@ -71,8 +71,9 @@ kotlin {
nativeTargets.forEach { nativeTarget ->
nativeTarget.apply {
val main by compilations.getting
val walletCore by main.cinterops.creating {
includeDirs.allHeaders(rootDir.parentFile.resolve("include/TrustWalletCore"))
main.cinterops.create("WalletCore") {
packageName = "com.trustwallet.core"
headers(rootDir.parentFile.resolve("include/TrustWalletCore").listFiles()!!)
}
}
}
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion tools/kotlin-build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
set -e

pushd kotlin
./gradlew :wallet-core-kotlin:generateFiles
./gradlew :wallet-core-kotlin:generateProtos
./gradlew :wallet-core-kotlin:assemble
popd
2 changes: 1 addition & 1 deletion tools/kotlin-release
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo "Building $version"
export ANDROID_HOME="$HOME/Library/Android/sdk"

pushd kotlin
./gradlew :wallet-core-kotlin:generateFiles
./gradlew :wallet-core-kotlin:generateProtos
./gradlew :wallet-core-kotlin:assemble :wallet-core-kotlin:publish -Pversion="$version"
popd

Expand Down

0 comments on commit 7325669

Please sign in to comment.