Skip to content

Commit

Permalink
Add core wasmWasi support, wasmJs to coroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored and evant committed Mar 25, 2024
1 parent 59a43f7 commit 0836bdb
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
gradle-{{ checksum ".circleci/gradle_cache_seed" }}-{{ checksum
".circleci/config.yml" }}-windows
- run:
command: ./gradlew --no-daemon build -x wasmNodeTest
command: ./gradlew --no-daemon build -x wasmJsNodeTest -x wasmWasiNodeTest
shell: bash.exe
- save_cache:
paths:
Expand Down
23 changes: 10 additions & 13 deletions assertk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.common
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.wasm

plugins {
id("assertk.multiplatform")
Expand All @@ -23,15 +21,6 @@ kotlin {
withJava()
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyDefaultHierarchyTemplate {
group("coroutines") {
withNative()
withJs()
withJvm()
}
}

sourceSets {
commonMain {
dependencies {
Expand All @@ -56,11 +45,19 @@ kotlin {
}
}

val coroutinesTest by getting {
val coroutinesTest by creating {
dependsOn(commonTest.get())
dependencies {
implementation(libs.kotlinx.coroutines)
implementation(libs.kotlinx.coroutines.test)
}
}
targets.configureEach {
if (platformType != common && name != "wasmWasi") {
compilations.getByName(TEST_COMPILATION_NAME)
.defaultSourceSet
.dependsOn(coroutinesTest)
}
}
}
}
27 changes: 24 additions & 3 deletions buildSrc/src/main/kotlin/assertk.multiplatform.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ kotlin {
}
}
}
// TODO Remove conditional once coroutines ships a version with WASM target.
if (project.path != ":assertk-coroutines") {
// TODO Remove conditional once coroutines ships a version with WASI target.
val hasWasmWasi = project.path != ":assertk-coroutines"
if (hasWasmWasi) {
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
wasmWasi {
nodejs()
}
}
Expand All @@ -71,6 +72,26 @@ kotlin {
androidNativeArm64()
androidNativeX86()
androidNativeX64()

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
nodejs()
}

applyDefaultHierarchyTemplate()

// The above does not yet create a common Wasm source set, so build our own.
// https://youtrack.jetbrains.com/issue/KT-61988
sourceSets {
val wasmMain by creating
val wasmTest by creating
named("wasmJsMain") { dependsOn(wasmMain) }
named("wasmJsTest") { dependsOn(wasmTest) }
if (hasWasmWasi) {
named("wasmWasiMain") { dependsOn(wasmMain) }
named("wasmWasiTest") { dependsOn(wasmTest) }
}
}
}

tasks.withType<KotlinJvmCompile> {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
assertk = "1.0.0-SNAPSHOT"
kotlin = "1.9.21"
kotlinx-coroutines = "1.7.3"
kotlinx-coroutines = "1.8.0"
[libraries]
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "1.9.10" }
Expand Down

0 comments on commit 0836bdb

Please sign in to comment.