Skip to content

Commit f00110a

Browse files
authored
Add WasmWasi support (#154)
1 parent def028c commit f00110a

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
66
project adheres to [Semantic Versioning](https://semver.org/).
77

8+
## [0.8.3] - 2024-03-16
9+
### Changed
10+
- Bump kotlin to 1.9.23
11+
- Add wasmWasi support
12+
813
## [0.8.2] - 2023-11-10
914
### Changed
1015
- Bump kotlin to 1.9.20

Diff for: build.gradle.kts

+21-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
33
import org.jetbrains.kotlin.konan.target.HostManager
44

55
plugins {
6-
kotlin("multiplatform") version "1.9.20"
6+
kotlin("multiplatform") version "1.9.23"
77
id("org.jetbrains.dokka") version "1.8.20"
88
id("maven-publish")
99
id("signing")
@@ -66,9 +66,12 @@ kotlin {
6666
binaries.findTest(DEBUG)!!.linkerOpts = mutableListOf("-Wl,--subsystem,windows")
6767
}
6868
}
69-
if (HostManager.hostIsLinux || HostManager.hostIsMac) {
69+
if (HostManager.hostIsLinux) {
7070
linuxX64()
7171
linuxArm64()
72+
wasmWasi {
73+
nodejs()
74+
}
7275
}
7376
}
7477

@@ -150,11 +153,12 @@ kotlin {
150153
val mingwX64Test by getting { dependsOn(mingwTest) }
151154
}
152155

153-
if (HostManager.hostIsLinux || HostManager.hostIsMac) {
156+
if (HostManager.hostIsLinux) {
154157
val linuxX64Main by getting { dependsOn(nix64Main) }
155158
val linuxX64Test by getting { dependsOn(nix64Test) }
156159
val linuxArm64Main by getting { dependsOn(nix64Main) }
157160
val linuxArm64Test by getting { dependsOn(nix64Test) }
161+
val wasmWasiMain by getting { dependsOn(nonJvmMain) }
158162
}
159163
}
160164
}
@@ -167,6 +171,20 @@ tasks.withType<KotlinNativeCompile>().configureEach {
167171
compilerOptions.freeCompilerArgs.add("-opt-in=kotlinx.cinterop.ExperimentalForeignApi")
168172
}
169173

174+
if (HostManager.hostIsLinux) {
175+
plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
176+
the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().download = true
177+
the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion =
178+
"21.0.0-v8-canary20231024d0ddc81258"
179+
the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeDownloadBaseUrl =
180+
"https://nodejs.org/download/v8-canary"
181+
}
182+
183+
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
184+
args.add("--ignore-engines")
185+
}
186+
}
187+
170188
val ktlintConfig by configurations.creating
171189

172190
dependencies {

Diff for: gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kotlin.code.style=official
55
kotlin.incremental=true
66

77
GROUP=com.benasher44
8-
VERSION=0.8.2
8+
VERSION=0.8.3
99

1010
POM_URL=https://github.com/benasher44/uuid/
1111
POM_SCM_URL=https://github.com/benasher44/uuid/
@@ -21,4 +21,4 @@ POM_DESCRIPTION=A Kotlin multiplatform implementation of a v4 RFC4122 UUID
2121

2222
org.gradle.jvmargs=-Xmx4g
2323

24-
kotlin.stdlib.default.dependency=false
24+
kotlin.stdlib.default.dependency=false

Diff for: publish.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,5 @@ tasks.register('publishWindows') {
118118
tasks.register('publishLinux') {
119119
dependsOn 'publishLinuxX64PublicationToMavenRepository'
120120
dependsOn 'publishLinuxArm64PublicationToMavenRepository'
121+
dependsOn 'publishWasmWasiPublicationToMavenRepository'
121122
}

Diff for: src/wasmWasiMain/kotlin/platform.kt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.benasher44.uuid
2+
3+
import kotlin.random.Random
4+
5+
internal actual fun getRandomUuidBytes(): ByteArray = Random.Default.nextBytes(UUID_BYTES)
6+
7+
internal actual fun <T> T.freeze(): T = this

0 commit comments

Comments
 (0)