File tree 8 files changed +108
-12
lines changed
wasmWasiMain/kotlin/sample
wasmWasiTest/kotlin/sample
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")
249
249
tasks. named(" dokkaHtmlMultiModule" ) {
250
250
pluginsMapConfiguration. set([" org.jetbrains.dokka.base.DokkaBase" : """ { "templatesDir": "${ projectDir.toString().replace('\\', '/')} /dokka-templates" }""" ])
251
251
}
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 {
42
42
wasmJsMain {
43
43
dependsOn(sourceSets. jsWasmMain)
44
44
}
45
+ wasmWasiMain {
46
+ dependsOn(sourceSets. jsWasmMain)
47
+ }
45
48
}
46
49
}
47
50
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ tasks.withType(JavaCompile).configureEach {
14
14
options. release = 8
15
15
}
16
16
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
+
17
22
kotlin {
18
23
jvm {
19
24
withJava()
@@ -43,7 +48,13 @@ kotlin {
43
48
}
44
49
45
50
wasmJs {
46
- d8()
51
+ nodejs()
52
+ }
53
+
54
+ if (! isOkIoOrFormatTests) {
55
+ wasmWasi {
56
+ nodejs()
57
+ }
47
58
}
48
59
49
60
sourceSets. all {
@@ -96,25 +107,43 @@ kotlin {
96
107
}
97
108
}
98
109
110
+ create(" wasmMain" ) {
111
+ dependsOn(commonMain)
112
+ }
113
+ create(" wasmTest" ) {
114
+ dependsOn(commonTest)
115
+ }
99
116
100
117
wasmJsMain {
101
- kotlin {
102
- srcDir ' wasmMain/src'
103
- }
118
+ dependsOn(wasmMain)
104
119
dependencies {
105
120
api ' org.jetbrains.kotlin:kotlin-stdlib-wasm-js'
106
121
}
107
122
}
108
123
109
124
wasmJsTest {
110
- kotlin {
111
- srcDir ' wasmTest/src'
112
- }
125
+ dependsOn(wasmTest)
113
126
dependencies {
114
127
api ' org.jetbrains.kotlin:kotlin-test-wasm-js'
115
128
}
116
129
}
117
130
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
+
118
147
nativeMain. dependencies {
119
148
}
120
149
}
@@ -162,3 +191,9 @@ kotlin {
162
191
}
163
192
}
164
193
}
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 {
42
42
}
43
43
}
44
44
wasmJs {
45
- d8()
45
+ nodejs()
46
+ }
47
+ wasmWasi {
48
+ nodejs()
46
49
}
47
50
jvm {
48
51
withJava()
@@ -102,12 +105,21 @@ kotlin {
102
105
api ' org.jetbrains.kotlin:kotlin-stdlib-wasm-js'
103
106
}
104
107
}
105
-
106
108
wasmJsTest {
107
109
dependencies {
108
110
api ' org.jetbrains.kotlin:kotlin-test-wasm-js'
109
111
}
110
112
}
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
+ }
111
123
}
112
124
113
125
targets. all {
@@ -129,3 +141,13 @@ dependencies {
129
141
}
130
142
131
143
task 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 1
1
/*
2
- * Copyright 2019 JetBrains s.r.o.
2
+ * Copyright 2023 JetBrains s.r.o.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
package sample
18
18
19
19
actual object Platform {
20
- actual val name: String = " Wasm "
20
+ actual val name: String = " WasmJs "
21
21
}
Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ import kotlin.test.assertTrue
6
6
class SampleTestsWasm {
7
7
@Test
8
8
fun testHello () {
9
- assertTrue(" Wasm " in hello())
9
+ assertTrue(" WasmJs " in hello())
10
10
}
11
11
}
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