From accb8b11fdcacbbb1e308751353dda1b65446238 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Thu, 23 Nov 2023 13:47:35 +0100 Subject: [PATCH 1/2] Enable WasmWasi target Added WasmWasi target sharing the same source code with WasmJs target for now. Closes #234 --- .../kotlinx-io-multiplatform.gradle.kts | 12 ++++++++++++ core/build.gradle.kts | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts index 8dc93f5c3..0b6065b1d 100644 --- a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts +++ b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts @@ -46,6 +46,12 @@ kotlin { binaries.executable() } + @OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class) + wasmWasi { + nodejs() + binaries.executable() + } + sourceSets { commonTest { dependencies { @@ -96,6 +102,12 @@ kotlin { getByName("wasmJsTest") { kotlin.srcDir(File(File(projectDir, "wasm"), "test")) } + getByName("wasmWasiMain") { + kotlin.srcDir(File(File(projectDir, "wasm"), "src")) + } + getByName("wasmWasiTest") { + kotlin.srcDir(File(File(projectDir, "wasm"), "test")) + } } } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 26b89e9b8..fefa361f4 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -4,6 +4,7 @@ */ import org.jetbrains.dokka.gradle.DokkaTaskPartial +import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinTargetWithNodeJsDsl plugins { id("kotlinx-io-multiplatform") @@ -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" @@ -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 { From b86e2ec8f23d134720b8c73aa146a397239df69b Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Thu, 23 Nov 2023 15:36:10 +0100 Subject: [PATCH 2/2] Fixed Wasm sourceSets setup --- .../kotlinx-io-multiplatform.gradle.kts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts index 0b6065b1d..19ed95179 100644 --- a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts +++ b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts @@ -96,18 +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")) - } - getByName("wasmWasiMain") { - kotlin.srcDir(File(File(projectDir, "wasm"), "src")) - } - getByName("wasmWasiTest") { - kotlin.srcDir(File(File(projectDir, "wasm"), "test")) - } + createSourceSet("wasmMain", parent = commonMain.get(), children = wasmTargets()) + createSourceSet("wasmTest", parent = commonTest.get(), children = wasmTargets()) } } @@ -210,6 +200,8 @@ fun androidTargets() = listOf( "androidNativeX86" ) +fun wasmTargets() = listOf("wasmJs", "wasmWasi") + rootProject.the().apply { nodeVersion = "21.0.0-v8-canary202310177990572111" nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"