From 732566902f5fe33e7b52e1b3f48bad1251da9c0d Mon Sep 17 00:00:00 2001 From: Maxim Pestryakov Date: Wed, 15 Feb 2023 18:22:42 +0800 Subject: [PATCH] [Kotlin] Removed :generateCinterop task (#2934) --- kotlin/README.md | 2 -- ...=> convention.proto-generation.gradle.kts} | 30 ------------------- kotlin/wallet-core-kotlin/.gitignore | 1 - kotlin/wallet-core-kotlin/build.gradle.kts | 7 +++-- .../src/nativeInterop/cinterop/WalletCore.def | 0 tools/kotlin-build | 2 +- tools/kotlin-release | 2 +- 7 files changed, 6 insertions(+), 38 deletions(-) rename kotlin/build-logic/src/main/kotlin/{convention.file-generation.gradle.kts => convention.proto-generation.gradle.kts} (65%) create mode 100644 kotlin/wallet-core-kotlin/src/nativeInterop/cinterop/WalletCore.def diff --git a/kotlin/README.md b/kotlin/README.md index 42e4cf78a39..d80405f6046 100644 --- a/kotlin/README.md +++ b/kotlin/README.md @@ -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 diff --git a/kotlin/build-logic/src/main/kotlin/convention.file-generation.gradle.kts b/kotlin/build-logic/src/main/kotlin/convention.proto-generation.gradle.kts similarity index 65% rename from kotlin/build-logic/src/main/kotlin/convention.file-generation.gradle.kts rename to kotlin/build-logic/src/main/kotlin/convention.proto-generation.gradle.kts index 028fb3a9c2f..7775d61e4ed 100644 --- a/kotlin/build-logic/src/main/kotlin/convention.file-generation.gradle.kts +++ b/kotlin/build-logic/src/main/kotlin/convention.proto-generation.gradle.kts @@ -1,27 +1,5 @@ val libs = extensions.getByType().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("copyProtos") { val sourceDir = rootDir.parentFile.resolve("src/proto") val destinationDir = projectDir.resolve("build/tmp/proto") @@ -76,11 +54,3 @@ val generateProtosTask = task("generateProtos") { "--kotlin_out=$destinationDir", ) } - -task("generateFiles") { - dependsOn(generateCinteropTask) - dependsOn(generateProtosTask) - - workingDir(rootDir.parentFile) - commandLine("./codegen/bin/codegen") -} diff --git a/kotlin/wallet-core-kotlin/.gitignore b/kotlin/wallet-core-kotlin/.gitignore index 1f22b7e6731..a9e76bfd475 100644 --- a/kotlin/wallet-core-kotlin/.gitignore +++ b/kotlin/wallet-core-kotlin/.gitignore @@ -1,3 +1,2 @@ /src/**/generated/ /src/**/proto/ -/src/nativeInterop/ diff --git a/kotlin/wallet-core-kotlin/build.gradle.kts b/kotlin/wallet-core-kotlin/build.gradle.kts index 4af9f55bf0e..780048b49fa 100644 --- a/kotlin/wallet-core-kotlin/build.gradle.kts +++ b/kotlin/wallet-core-kotlin/build.gradle.kts @@ -6,7 +6,7 @@ plugins { kotlin("multiplatform") id("com.android.library") id("convention.maven-publish") - id("convention.file-generation") + id("convention.proto-generation") } kotlin { @@ -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()!!) } } } diff --git a/kotlin/wallet-core-kotlin/src/nativeInterop/cinterop/WalletCore.def b/kotlin/wallet-core-kotlin/src/nativeInterop/cinterop/WalletCore.def new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tools/kotlin-build b/tools/kotlin-build index 4eb14383f65..a64537b101f 100755 --- a/tools/kotlin-build +++ b/tools/kotlin-build @@ -3,6 +3,6 @@ set -e pushd kotlin -./gradlew :wallet-core-kotlin:generateFiles +./gradlew :wallet-core-kotlin:generateProtos ./gradlew :wallet-core-kotlin:assemble popd diff --git a/tools/kotlin-release b/tools/kotlin-release index 0eadf3fe30c..ce934855911 100755 --- a/tools/kotlin-release +++ b/tools/kotlin-release @@ -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