Skip to content

Commit ca9c1b0

Browse files
committed
Support wasm targets for core, tests and local transport
1 parent 7a04217 commit ca9c1b0

File tree

11 files changed

+99
-74
lines changed

11 files changed

+99
-74
lines changed

build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ kotlin {
4141
optIn.addAll(OptIns.ExperimentalSubclassOptIn)
4242
}
4343

44+
applyDefaultHierarchyTemplate {
45+
common {
46+
group("nonJvm") {
47+
withJs()
48+
withWasmJs()
49+
withWasmWasi()
50+
group("native")
51+
}
52+
}
53+
}
54+
4455
sourceSets.configureEach {
4556
languageSettings {
4657
if (name.contains("test", ignoreCase = true)) {

build-logic/src/main/kotlin/rsocketbuild/targets.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@ package rsocketbuild
1818

1919
import org.gradle.jvm.toolchain.*
2020
import org.gradle.kotlin.dsl.*
21+
import org.jetbrains.kotlin.gradle.*
2122
import org.jetbrains.kotlin.gradle.dsl.*
2223

24+
fun KotlinMultiplatformExtension.allTargets() {
25+
jvmTarget()
26+
jsTarget()
27+
wasmJsTarget()
28+
wasmWasiTarget()
29+
nativeTargets()
30+
}
31+
2332
fun KotlinMultiplatformExtension.appleTargets() {
2433
macosX64()
2534
macosArm64()
@@ -63,6 +72,24 @@ fun KotlinMultiplatformExtension.jsTarget(
6372
}
6473
}
6574

75+
@OptIn(ExperimentalWasmDsl::class)
76+
fun KotlinMultiplatformExtension.wasmJsTarget(
77+
supportsNode: Boolean = true,
78+
supportsBrowser: Boolean = true,
79+
) {
80+
wasmJs {
81+
if (supportsNode) nodejs()
82+
if (supportsBrowser) browser()
83+
}
84+
}
85+
86+
@OptIn(ExperimentalWasmDsl::class)
87+
fun KotlinMultiplatformExtension.wasmWasiTarget() {
88+
wasmWasi {
89+
nodejs()
90+
}
91+
}
92+
6693
fun KotlinMultiplatformExtension.jvmTarget(
6794
jdkVersion: Int = 8,
6895
jdkAdditionalTestVersions: Set<Int> = setOf(11, 17, 21),

rsocket-core/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ plugins {
2424
description = "rsocket-kotlin core functionality"
2525

2626
kotlin {
27-
jvmTarget()
28-
jsTarget()
29-
nativeTargets()
27+
allTargets()
3028

3129
sourceSets {
3230
commonMain.dependencies {

rsocket-core/src/jsMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt

Lines changed: 0 additions & 57 deletions
This file was deleted.

rsocket-core/src/nativeMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt renamed to rsocket-core/src/nonJvmMain/kotlin/io/rsocket/kotlin/logging/DefaultLoggerFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2022 the original author or authors.
2+
* Copyright 2015-2024 the original author or authors.
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.
@@ -19,5 +19,5 @@ package io.rsocket.kotlin.logging
1919
import io.rsocket.kotlin.*
2020

2121
@RSocketLoggingApi
22-
public actual val DefaultLoggerFactory: LoggerFactory
22+
internal actual val DefaultLoggerFactory: LoggerFactory
2323
get() = PrintLogger

rsocket-internal-io/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ plugins {
2323
description = "rsocket-kotlin internal IO support"
2424

2525
kotlin {
26-
jvmTarget()
27-
jsTarget()
28-
nativeTargets()
26+
allTargets()
2927

3028
sourceSets {
3129
commonMain.dependencies {

rsocket-test/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ plugins {
2424

2525
@OptIn(ExperimentalKotlinGradlePluginApi::class)
2626
kotlin {
27-
jvmTarget()
28-
jsTarget()
29-
nativeTargets()
27+
allTargets()
3028

3129
compilerOptions {
3230
freeCompilerArgs.add("-Xexpect-actual-classes")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2015-2024 the original author or authors.
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 io.rsocket.kotlin.test
18+
19+
import kotlinx.coroutines.*
20+
21+
actual annotation class IgnoreJs
22+
actual annotation class IgnoreJvm
23+
actual annotation class IgnoreNative
24+
25+
actual val anotherDispatcher: CoroutineDispatcher get() = Dispatchers.Default
26+
27+
actual fun identityHashCode(instance: Any): Int = instance.hashCode()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2015-2024 the original author or authors.
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 io.rsocket.kotlin.test
18+
19+
import kotlinx.coroutines.*
20+
21+
actual annotation class IgnoreJs
22+
actual annotation class IgnoreJvm
23+
actual annotation class IgnoreNative
24+
25+
actual val anotherDispatcher: CoroutineDispatcher get() = Dispatchers.Default
26+
27+
actual fun identityHashCode(instance: Any): Int = instance.hashCode()

rsocket-transport-tests/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ plugins {
2424

2525
@OptIn(ExperimentalKotlinGradlePluginApi::class)
2626
kotlin {
27-
jvmTarget()
28-
jsTarget()
29-
nativeTargets()
27+
allTargets()
3028

3129
compilerOptions {
3230
optIn.addAll(

0 commit comments

Comments
 (0)