File tree Expand file tree Collapse file tree 8 files changed +108
-12
lines changed
wasmWasiMain/kotlin/sample
wasmWasiTest/kotlin/sample Expand file tree Collapse file tree 8 files changed +108
-12
lines changed Original file line number Diff line number Diff line change @@ -249,3 +249,7 @@ apply from: rootProject.file("gradle/benchmark-parsing.gradle")
249249tasks. named(" dokkaHtmlMultiModule" ) {
250250 pluginsMapConfiguration. set([" org.jetbrains.dokka.base.DokkaBase" : """ { "templatesDir": "${ projectDir.toString().replace('\\', '/')} /dokka-templates" }""" ])
251251}
252+
253+ tasks. withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask ). configureEach {
254+ args. add(" --ignore-engines" )
255+ }
Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ kotlin {
4242 wasmJsMain {
4343 dependsOn(sourceSets. jsWasmMain)
4444 }
45+ wasmWasiMain {
46+ dependsOn(sourceSets. jsWasmMain)
47+ }
4548 }
4649}
4750
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ tasks.withType(JavaCompile).configureEach {
1414 options. release = 8
1515}
1616
17+ // Unfortunately there is no compatible version of okio for Wasm WASI target, so we need to skip to configure WASI for json-okio and json-tests.
18+ // json-tests uses okio with incorporate with other formatter tests so it is hard and not worth to separate it for two projects for WASI.
19+ // So we disable WASI target in it and we hope, that WASI version of compiler and serialization plugin are identical to the WasmJS target so WASI target is being covered.
20+ Boolean isOkIoOrFormatTests = (project. name == ' kotlinx-serialization-json-okio' || project. name == ' kotlinx-serialization-json-tests' )
21+
1722kotlin {
1823 jvm {
1924 withJava()
@@ -43,7 +48,13 @@ kotlin {
4348 }
4449
4550 wasmJs {
46- d8()
51+ nodejs()
52+ }
53+
54+ if (! isOkIoOrFormatTests) {
55+ wasmWasi {
56+ nodejs()
57+ }
4758 }
4859
4960 sourceSets. all {
@@ -96,25 +107,43 @@ kotlin {
96107 }
97108 }
98109
110+ create(" wasmMain" ) {
111+ dependsOn(commonMain)
112+ }
113+ create(" wasmTest" ) {
114+ dependsOn(commonTest)
115+ }
99116
100117 wasmJsMain {
101- kotlin {
102- srcDir ' wasmMain/src'
103- }
118+ dependsOn(wasmMain)
104119 dependencies {
105120 api ' org.jetbrains.kotlin:kotlin-stdlib-wasm-js'
106121 }
107122 }
108123
109124 wasmJsTest {
110- kotlin {
111- srcDir ' wasmTest/src'
112- }
125+ dependsOn(wasmTest)
113126 dependencies {
114127 api ' org.jetbrains.kotlin:kotlin-test-wasm-js'
115128 }
116129 }
117130
131+ if (! isOkIoOrFormatTests) {
132+ wasmWasiMain {
133+ dependsOn(wasmMain)
134+ dependencies {
135+ api ' org.jetbrains.kotlin:kotlin-stdlib-wasm-wasi'
136+ }
137+ }
138+
139+ wasmWasiTest {
140+ dependsOn(wasmTest)
141+ dependencies {
142+ api ' org.jetbrains.kotlin:kotlin-test-wasm-wasi'
143+ }
144+ }
145+ }
146+
118147 nativeMain. dependencies {
119148 }
120149 }
@@ -162,3 +191,9 @@ kotlin {
162191 }
163192 }
164193}
194+
195+ rootProject. extensions. findByType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension . class). with {
196+ // canary nodejs that supports recent Wasm GC changes
197+ it. nodeVersion = " 21.0.0-v8-canary202309167e82ab1fa2"
198+ it. nodeDownloadBaseUrl = " https://nodejs.org/download/v8-canary"
199+ }
Original file line number Diff line number Diff line change @@ -42,7 +42,10 @@ kotlin {
4242 }
4343 }
4444 wasmJs {
45- d8()
45+ nodejs()
46+ }
47+ wasmWasi {
48+ nodejs()
4649 }
4750 jvm {
4851 withJava()
@@ -102,12 +105,21 @@ kotlin {
102105 api ' org.jetbrains.kotlin:kotlin-stdlib-wasm-js'
103106 }
104107 }
105-
106108 wasmJsTest {
107109 dependencies {
108110 api ' org.jetbrains.kotlin:kotlin-test-wasm-js'
109111 }
110112 }
113+ wasmWasiMain {
114+ dependencies {
115+ api ' org.jetbrains.kotlin:kotlin-stdlib-wasm-wasi'
116+ }
117+ }
118+ wasmWasiTest {
119+ dependencies {
120+ api ' org.jetbrains.kotlin:kotlin-test-wasm-wasi'
121+ }
122+ }
111123 }
112124
113125 targets. all {
@@ -129,3 +141,13 @@ dependencies {
129141}
130142
131143task run dependsOn " check"
144+
145+ rootProject. extensions. findByType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension . class). with {
146+ // canary nodejs that supports recent Wasm GC changes
147+ it. nodeVersion = " 21.0.0-v8-canary202309167e82ab1fa2"
148+ it. nodeDownloadBaseUrl = " https://nodejs.org/download/v8-canary"
149+ }
150+
151+ tasks. withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask ). configureEach {
152+ args. add(" --ignore-engines" )
153+ }
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2019 JetBrains s.r.o.
2+ * Copyright 2023 JetBrains s.r.o.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1717package sample
1818
1919actual object Platform {
20- actual val name: String = " Wasm "
20+ actual val name: String = " WasmJs "
2121}
Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ import kotlin.test.assertTrue
66class SampleTestsWasm {
77 @Test
88 fun testHello () {
9- assertTrue(" Wasm " in hello())
9+ assertTrue(" WasmJs " in hello())
1010 }
1111}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2023 JetBrains s.r.o.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package sample
18+
19+ actual object Platform {
20+ actual val name: String = " WasmWasi"
21+ }
Original file line number Diff line number Diff line change 1+ package sample
2+
3+ import kotlin.test.Test
4+ import kotlin.test.assertTrue
5+
6+ class SampleTestsWasm {
7+ @Test
8+ fun testHello () {
9+ assertTrue(" WasmWasi" in hello())
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments