Skip to content

Commit

Permalink
[Kotlin] JVM support (#3407)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPestryakov authored Sep 4, 2023
1 parent a369164 commit 0e794d2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ if (${ANDROID})
file(GLOB_RECURSE specific_sources
jni/kotlin/*.h
jni/kotlin/*.c
kotlin/wallet-core-kotlin/src/androidMain/cpp/generated/*.h
kotlin/wallet-core-kotlin/src/androidMain/cpp/generated/*.c
kotlin/wallet-core-kotlin/src/commonAndroidJvmMain/cpp/generated/*.h
kotlin/wallet-core-kotlin/src/commonAndroidJvmMain/cpp/generated/*.c
)
else ()
file(GLOB_RECURSE specific_sources jni/android/*.h jni/android/*.c)
Expand Down
6 changes: 3 additions & 3 deletions codegen/lib/code_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def render_kotlin_common
end

def render_kotlin_android
render_template(header: nil, template: 'kotlin_android.erb', output_subfolder: 'kotlin/wallet-core-kotlin/src/androidMain/generated/com/trustwallet/core', extension: 'kt')
render_template(header: nil, template: 'kotlin_android.erb', output_subfolder: 'kotlin/wallet-core-kotlin/src/commonAndroidJvmMain/generated/com/trustwallet/core', extension: 'kt')
end

def render_kotlin_ios
Expand All @@ -126,11 +126,11 @@ def render_kotlin_js_accessors
end

def render_kotlin_jni_h
render_template(header: 'copyright_header.erb', template: 'kotlin_jni_h.erb', output_subfolder: 'kotlin/wallet-core-kotlin/src/androidMain/cpp/generated', extension: 'h')
render_template(header: 'copyright_header.erb', template: 'kotlin_jni_h.erb', output_subfolder: 'kotlin/wallet-core-kotlin/src/commonAndroidJvmMain/cpp/generated', extension: 'h')
end

def render_kotlin_jni_c
render_template(header: 'copyright_header.erb', template: 'kotlin_jni_c.erb', output_subfolder: 'kotlin/wallet-core-kotlin/src/androidMain/cpp/generated', extension: 'c')
render_template(header: 'copyright_header.erb', template: 'kotlin_jni_c.erb', output_subfolder: 'kotlin/wallet-core-kotlin/src/commonAndroidJvmMain/cpp/generated', extension: 'c')
end

def render(file, locals = {})
Expand Down
21 changes: 16 additions & 5 deletions kotlin/wallet-core-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ kotlin {
publishLibraryVariants = listOf("release")
}

jvm()

val nativeTargets =
listOf(
iosArm64(),
Expand All @@ -37,9 +39,6 @@ kotlin {
}
}

val androidMain by getting {
kotlin.srcDir(projectDir.resolve("src/androidMain/generated"))
}
val commonMain by getting {
kotlin.srcDirs(
projectDir.resolve("src/commonMain/generated"),
Expand All @@ -50,18 +49,30 @@ kotlin {
api(libs.wire.runtime)
}
}

val androidMain by getting
val jvmMain by getting
create("commonAndroidJvmMain") {
kotlin.srcDir(projectDir.resolve("src/commonAndroidJvmMain/generated"))

dependsOn(commonMain)
androidMain.dependsOn(this)
jvmMain.dependsOn(this)
}

val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosX64Main by getting
val iosMain by creating {
create("iosMain") {
kotlin.srcDir(projectDir.resolve("src/iosMain/generated"))

dependsOn(commonMain)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
iosX64Main.dependsOn(this)
}
val jsMain by getting {

getByName("jsMain") {
kotlin.srcDir(projectDir.resolve("src/jsMain/generated"))
}
}
Expand Down

0 comments on commit 0e794d2

Please sign in to comment.