Skip to content

Commit 908a5bf

Browse files
authored
add wasm and wasi targets (#7)
1 parent a6e3e39 commit 908a5bf

19 files changed

Lines changed: 1054 additions & 516 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- os: windows-latest
3434
cmd: "./gradlew runKmp_xlogDebugExecutableMingwX64"
3535
- os: macos-latest
36-
cmd: "./gradlew :example:shared:jsBrowserDistribution"
36+
cmd: "./gradlew :example:shared:jsBrowserDistribution && ./gradlew :example:shared:wasmJsBrowserDistribution && ./gradlew :example:shared:wasmWasiNodeDevelopmentRun"
3737
runs-on: ${{ matrix.os }}
3838

3939
steps:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ pod install
173173
```bash
174174
# run on macOS, with Android NDK android-ndk-r23d-canary,
175175
# https://ci.android.com/builds/branches/aosp-ndk-release-r23/grid
176+
# rename the folder as 23.3.12186248
176177
./scripts/build_xlog_android.sh
177178
# run on macOS
178179
./scripts/build_xlog_apple.sh
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Consts {
22
const val releaseGroup = "com.piasy"
33
const val releaseName = "kmp-xlog"
4-
const val releaseVersion = "1.4.3"
4+
const val releaseVersion = "1.5.0"
55

66
val androidNS = "$releaseGroup.${releaseName.replace('-', '.')}"
77
}

example/shared/build.gradle.kts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
@file:OptIn(ExperimentalWasmDsl::class)
2+
3+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
4+
15
plugins {
26
alias(libs.plugins.kmp)
37

@@ -36,9 +40,19 @@ kotlin {
3640
}
3741
}
3842

39-
js(IR) {
40-
browser {
41-
}
43+
js {
44+
browser()
45+
nodejs()
46+
binaries.executable()
47+
}
48+
wasmJs {
49+
browser()
50+
nodejs()
51+
d8()
52+
binaries.executable()
53+
}
54+
wasmWasi {
55+
nodejs()
4256
binaries.executable()
4357
}
4458

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package com.piasy.kmp.xlog.example
22

3+
import com.piasy.kmp.xlog.Logging
34
import com.piasy.kmp.xlog.initializeConsoleLog
4-
import kotlinx.browser.document
55

66
class JsPlatform : Platform {
7-
override val name: String = "JS"
7+
override val name: String = "JS"
88
}
99

1010
actual fun getPlatform(): Platform = JsPlatform()
1111

1212
fun main() {
13-
initializeConsoleLog(true)
13+
initializeConsoleLog(true)
1414

15-
document.getElementById("text")?.innerHTML = Greeting().greeting()
15+
Logging.info("XXPXX", Greeting().greeting())
1616
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.piasy.kmp.xlog.example
2+
3+
import com.piasy.kmp.xlog.Logging
4+
import com.piasy.kmp.xlog.initializeConsoleLog
5+
6+
class WasmJsPlatform : Platform {
7+
override val name: String = "WasmJS"
8+
}
9+
10+
actual fun getPlatform(): Platform = WasmJsPlatform()
11+
12+
fun main() {
13+
initializeConsoleLog(true)
14+
15+
Logging.info("XXPXX", Greeting().greeting())
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.piasy.kmp.xlog.example
2+
3+
import com.piasy.kmp.xlog.initializeConsoleLog
4+
5+
class WasmWasiPlatform : Platform {
6+
override val name: String = "WasmWasi"
7+
}
8+
9+
actual fun getPlatform(): Platform = WasmWasiPlatform()
10+
11+
fun main() {
12+
initializeConsoleLog(true)
13+
14+
println(Greeting().greeting())
15+
}

example/shared/src/jsMain/resources/index.html renamed to example/shared/src/webMain/resources/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>kmp-xlog</title>
66
</head>
77
<body>
8-
<h1 id="text"></h1>
8+
<h1 id="text">KMP-XLOG (check console logs)</h1>
99
<script src="shared.js"></script>
1010
</body>
1111
</html>

gradle/libs.versions.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
11
[versions]
22
iosDeploymentTarget = "14.0"
33
jvm = "17"
4-
ndk = "21.3.6528147"
5-
compileSdk = "35"
4+
# ndk = "23.3.12186248" # actual canary ndk to support 16KB page size
5+
ndk = "21.3.6528147" # official ndk to pass ci
6+
compileSdk = "36"
67
minSdk = "21"
7-
targetSdk = "35"
8-
agp = "8.7.3"
9-
kotlin = "2.2.0"
10-
compose = "1.7.8"
8+
targetSdk = "36"
9+
agp = "8.13.0"
10+
kotlin = "2.2.20"
11+
compose = "1.9.2"
1112

1213
[libraries]
1314
kotlin-stdlib-js = { module = "org.jetbrains.kotlin:kotlin-stdlib-js", version.ref = "kotlin" }
1415

15-
androidx-junit = "androidx.test.ext:junit:1.2.1"
16-
androidx-runner = "androidx.test:runner:1.6.2"
16+
androidx-junit = "androidx.test.ext:junit:1.3.0"
17+
androidx-runner = "androidx.test:runner:1.7.0"
1718
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
1819
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
19-
mockk = "io.mockk:mockk:1.13.16"
20+
mockk = "io.mockk:mockk:1.14.5"
2021

2122
androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
2223
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
2324
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
2425
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
2526
androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
26-
androidx-activity-compose = "androidx.activity:activity-compose:1.10.1"
27+
androidx-activity-compose = "androidx.activity:activity-compose:1.11.0"
2728

2829
[plugins]
2930
android-library = { id = "com.android.library", version.ref = "agp" }
3031
android-application = { id = "com.android.application", version.ref = "agp" }
3132
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
3233
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
3334
kmp = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
34-
versions = "com.github.ben-manes.versions:0.51.0"
35-
versionUpdate = "nl.littlerobots.version-catalog-update:0.8.5"
36-
vanniktech-mavenPublish = "com.vanniktech.maven.publish:0.30.0"
35+
versions = "com.github.ben-manes.versions:0.52.0"
36+
versionUpdate = "nl.littlerobots.version-catalog-update:1.0.0"
37+
vanniktech-mavenPublish = "com.vanniktech.maven.publish:0.34.0"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Wed Nov 16 22:27:43 CST 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-all.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)