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

Enable WasmWasi target #236

Merged
merged 2 commits into from
Dec 1, 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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ kotlin {
binaries.executable()
}

@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasmWasi {
nodejs()
binaries.executable()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fzhinkin sorry for bothering again, can I ask why you explicitly selected an executable binary?
Wouldn't this be done by consumers of the library?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lppedd thanks for pointing to this! You're absolutely right, it should be done by consumers and there's absolutely no sense in specifying it for the library. I'll remove it.

}

sourceSets {
commonTest {
dependencies {
Expand Down Expand Up @@ -90,12 +96,8 @@ kotlin {
createSourceSet("linuxTest", parent = unixTest, children = linuxTargets())
createSourceSet("androidMain", parent = unixMain, children = androidTargets())
createSourceSet("androidTest", parent = unixTest, children = androidTargets())
getByName("wasmJsMain") {
kotlin.srcDir(File(File(projectDir, "wasm"), "src"))
}
getByName("wasmJsTest") {
kotlin.srcDir(File(File(projectDir, "wasm"), "test"))
}
createSourceSet("wasmMain", parent = commonMain.get(), children = wasmTargets())
createSourceSet("wasmTest", parent = commonTest.get(), children = wasmTargets())
}
}

Expand Down Expand Up @@ -198,6 +200,8 @@ fun androidTargets() = listOf(
"androidNativeX86"
)

fun wasmTargets() = listOf("wasmJs", "wasmWasi")

rootProject.the<NodeJsRootExtension>().apply {
nodeVersion = "21.0.0-v8-canary202310177990572111"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
Expand Down
16 changes: 13 additions & 3 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinTargetWithNodeJsDsl

plugins {
id("kotlinx-io-multiplatform")
Expand Down Expand Up @@ -31,9 +32,8 @@ kotlin {
}
}

@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasmJs {
nodejs {
fun KotlinTargetWithNodeJsDsl.filterSmokeTests() {
this.nodejs {
testTask(Action {
useMocha {
timeout = "300s"
Expand All @@ -43,6 +43,16 @@ kotlin {
}
}

@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasmJs {
filterSmokeTests()
}

@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasmWasi {
filterSmokeTests()
}

sourceSets {
commonMain {
dependencies {
Expand Down