Skip to content

Commit 904dd81

Browse files
authored
Merge pull request #3304 from square/mikepaw.wasm
Adding wasm target to wire runtime.
2 parents d8d66d8 + 5eb63ae commit 904dd81

File tree

20 files changed

+129
-587
lines changed

20 files changed

+129
-587
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ jobs:
2929
./gradlew generateTests -Pswift=false --stacktrace --warning-mode all
3030
if [ ! -z "$(git status --porcelain)" ]; then git diff; echo -e "\nTest files changed. Did you run ./gradlew generateTests?"; exit 1; fi
3131
32-
- name: Test Native and JS
32+
- name: Test Native, JS and Wasm
3333
run: |
34-
./gradlew -Dkjs=true -Dknative=true -Pswift=false samples:native:build samples:js:build samples:multi-target:build --stacktrace --warning-mode all
34+
./gradlew -Dkjs=true -Dknative=true -Dkwasm=true -Pswift=false samples:native:build samples:js:build samples:multi-target:build --stacktrace --warning-mode all
3535
3636
- name: Test
3737
run: |
38-
./gradlew -Dkjs=false -Dknative=false -Pswift=false build --stacktrace --warning-mode all -x samples:native:build -x samples:js:build -x samples:multi-target:build
38+
./gradlew -Dkjs=false -Dknative=false -Dkwasm=false -Pswift=false build --stacktrace --warning-mode all -x samples:native:build -x samples:js:build -x samples:multi-target:build
3939
4040
multiplatform:
4141
runs-on: macos-latest

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ kotlin-test-annotations = { module = "org.jetbrains.kotlin:kotlin-test-annotatio
6262
kotlin-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common" }
6363
kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js" }
6464
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit" }
65+
kotlin-test-wasm-js = { module = "org.jetbrains.kotlin:kotlin-test-wasm-js" }
6566
kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" }
6667
misk = { module = "com.squareup.misk:misk", version = "2025.02.21.143120-9967585" }
6768
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }

wire-runtime/build.gradle.kts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
2+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
23

34
plugins {
45
kotlin("multiplatform")
@@ -39,6 +40,17 @@ kotlin {
3940
tvosArm64()
4041
tvosSimulatorArm64()
4142
}
43+
44+
if (System.getProperty("kwasm", "true").toBoolean()) {
45+
wasmJs {
46+
browser()
47+
}
48+
@OptIn(ExperimentalWasmDsl::class)
49+
wasmWasi {
50+
nodejs()
51+
}
52+
}
53+
4254
sourceSets {
4355
val commonMain by getting {
4456
dependencies {
@@ -62,13 +74,51 @@ kotlin {
6274
implementation(libs.kotlin.test.junit)
6375
}
6476
}
77+
val nonJvmMain by creating {
78+
dependsOn(commonMain)
79+
}
80+
val nonJvmTest by creating {
81+
dependsOn(commonTest)
82+
}
83+
if (System.getProperty("knative", "true").toBoolean()) {
84+
val nativeMain by getting {
85+
dependsOn(nonJvmMain)
86+
}
87+
val nativeTest by getting {
88+
dependsOn(nonJvmTest)
89+
}
90+
}
6591
if (System.getProperty("kjs", "true").toBoolean()) {
92+
val jsMain by getting {
93+
dependsOn(nonJvmMain)
94+
}
6695
val jsTest by getting {
96+
dependsOn(nonJvmTest)
6797
dependencies {
6898
implementation(libs.kotlin.test.js)
6999
}
70100
}
71101
}
102+
if (System.getProperty("kwasm", "true").toBoolean()) {
103+
val wasmJsMain by getting {
104+
dependsOn(nonJvmMain)
105+
}
106+
val wasmJsTest by getting {
107+
dependsOn(nonJvmTest)
108+
dependencies {
109+
implementation(libs.kotlin.test.wasm.js)
110+
}
111+
}
112+
val wasmWasiMain by getting {
113+
dependsOn(nonJvmMain)
114+
}
115+
val wasmWasiTest by getting {
116+
dependsOn(nonJvmTest)
117+
dependencies {
118+
implementation(libs.kotlin.test)
119+
}
120+
}
121+
}
72122
}
73123
}
74124

wire-runtime/src/jsMain/kotlin/com/squareup/wire/ProtoAdapter.kt

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

wire-runtime/src/jsMain/kotlin/com/squareup/wire/internal/-Platform.kt

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,4 @@
1515
*/
1616
package com.squareup.wire.internal
1717

18-
import okio.IOException
19-
20-
actual interface Serializable
21-
22-
/** This annotation is an empty placeholder. */
23-
actual annotation class JvmField
24-
25-
/** This annotation is an empty placeholder. */
26-
actual annotation class JvmSynthetic
27-
28-
/** This annotation is an empty placeholder. */
29-
actual annotation class JvmStatic
30-
31-
actual abstract class ObjectStreamException : IOException()
32-
33-
actual class ProtocolException actual constructor(host: String) : IOException(host)
34-
35-
@Suppress("NOTHING_TO_INLINE") // Syntactic sugar.
36-
actual inline fun <T> MutableList<T>.toUnmodifiableList(): List<T> = this
37-
38-
@Suppress("NOTHING_TO_INLINE") // Syntactic sugar.
39-
actual inline fun <K, V> MutableMap<K, V>.toUnmodifiableMap(): Map<K, V> = this
40-
41-
// TODO: Use code points to process each char.
42-
actual fun camelCase(string: String, upperCamel: Boolean): String {
43-
return buildString(string.length) {
44-
var index = 0
45-
var uppercase = upperCamel
46-
while (index < string.length) {
47-
var char = string[index]
48-
49-
index++
50-
51-
if (char == '_') {
52-
uppercase = true
53-
continue
54-
}
55-
if (uppercase) {
56-
if (char in 'a'..'z') char += 'A' - 'a'
57-
}
58-
append(char)
59-
uppercase = false
60-
}
61-
}
62-
}
18+
actual typealias JsName = kotlin.js.JsName

0 commit comments

Comments
 (0)