Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Kotlin] JVM support #3407

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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