Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dependencies.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[versions]
kotlin = "2.0.10"
kotlin = "2.3.0"
kotlinxBrowser = "0.5.0"

coroutines = "1.8.0"
jetbrainsRuntime-api = "1.5.0"

androidGradlePlugin = "7.4.2"
androidGradlePlugin = "8.2.2"
dokka = "1.9.10"

buildHelpers-publishing = "0.1.28"
Expand All @@ -22,6 +24,8 @@ coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", ve

jetbrainsRuntime-api = { module = "org.jetbrains.runtime:jbr-api", version.ref = "jetbrainsRuntime-api" }

kotlinx-browser = { module = "org.jetbrains.kotlinx:kotlinx-browser", version.ref = "kotlinxBrowser" }

android-gradlePlugin = { module = "com.android.tools.build:gradle", version.ref = "androidGradlePlugin" }
dokka-gradlePlugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
gradleDownloadTask-gradlePlugin = { module = "de.undercouch:gradle-download-task", version.ref = "gradleDownloadTask" }
Expand Down
4 changes: 2 additions & 2 deletions samples/SkiaAwtSample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.9.21"
kotlin("jvm") version "2.3.0"
application
}

Expand Down Expand Up @@ -96,5 +96,5 @@ tasks.register("runInterop") {
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
compilerOptions.freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
1 change: 1 addition & 0 deletions samples/SkiaAwtSample/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#skiko.version=0.144.0
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ open class ClocksAwt(
val paragraph = ParagraphBuilder(style, fontCollection)
.pushStyle(TextStyle().apply {
color = 0xFF000000.toInt()
fontEdging = FontEdging.SUBPIXEL_ANTI_ALIAS
fontHinting = FontHinting.SLIGHT
subpixel = true
})
.addText("Graphic API: ${renderProvider()}, JRE: ${System.getProperty("java.vendor")}, ${System.getProperty("java.runtime.version")} $currentSystemTheme")
.popStyle()
Expand Down
12 changes: 7 additions & 5 deletions samples/SkiaMultiplatformSample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ kotlin {

jvm("awt") {
compilations.all {
kotlinOptions.jvmTarget = "11"
compileTaskProvider.configure {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
}
}
}
}

Expand Down Expand Up @@ -310,7 +314,7 @@ if (hostOs == "macos") {
} else {
// Otherwise copy the executable into the Xcode output directory.
tasks.create("packForXCode", Copy::class.java) {
dependsOn(kotlinBinary.linkTask)
dependsOn(kotlinBinary.linkTaskProvider)

println("Packing for XCode: ${kotlinBinary.target}")

Expand Down Expand Up @@ -371,7 +375,5 @@ fun KotlinNativeTarget.configureToLaunchFromXcode() {


tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-opt-in=kotlinx.cinterop.ExperimentalForeignApi"
}
compilerOptions.freeCompilerArgs.add("-opt-in=kotlinx.cinterop.ExperimentalForeignApi")
}
4 changes: 2 additions & 2 deletions samples/SkiaMultiplatformSample/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kotlin.code.style=official
org.gradle.jvmargs=-Xmx3G -XX:MaxMetaspaceSize=512m
kotlin.version=2.0.10
skiko.version=0.9.24
kotlin.version=2.3.0
skiko.version=0.144.0
#skiko.composite.build=1
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class AwtClocks(private val layer: SkiaLayer) : Clocks(layer::renderApi), MouseM
}

override fun mouseMoved(event: MouseEvent) {
if (event.x > 200) {
layer.component.cursor = Cursor.HAND_CURSOR
} else {
layer.component.cursor = Cursor.DEFAULT_CURSOR
}
xpos = event.x.toDouble()
ypos = event.y.toDouble()
}
Expand Down
22 changes: 7 additions & 15 deletions samples/SkiaWebSample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ kotlin {
binaries.executable()
}

wasmJs() {
wasmJs {
browser {
commonWebpackConfig {
outputFileName = "webApp.js"
Expand All @@ -61,24 +61,16 @@ kotlin {
}

sourceSets {
val commonMain by getting {
commonMain.dependencies {
implementation(libs.skiko)
}

webMain {
dependencies {
implementation(libs.skiko)
implementation(libs.browser)
}
}

val webMain by creating {
dependsOn(commonMain)
resources.setSrcDirs(resources.srcDirs)
resources.srcDirs(unpackWasmRuntime.map { it.destinationDir })
}

val jsMain by getting {
dependsOn(webMain)
}

val wasmJsMain by getting {
dependsOn(webMain)
}
}
}
4 changes: 2 additions & 2 deletions samples/SkiaWebSample/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official
kotlin.version=2.0.10
skiko.version=0.9.24
kotlin.version=2.3.0
skiko.version=0.144.0
#skiko.composite.build=1
3 changes: 3 additions & 0 deletions samples/SkiaWebSample/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ dependencyResolutionManagement {
versionCatalogs {
create("libs") {
version("skiko", providers.gradleProperty("skiko.version").get())
version("kotlinxBrowser", "0.5.0")

library("skiko", "org.jetbrains.skiko", "skiko").versionRef("skiko")
library("skiko-wasm-runtime", "org.jetbrains.skiko", "skiko-js-wasm-runtime").versionRef("skiko")
library("browser", "org.jetbrains.kotlinx", "kotlinx-browser").versionRef("kotlinxBrowser")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fun main() {
onWasmReady {
val description = "Skiko running with ${getPlatform().name}"
document.title = description
findElementById("description")?.innerHTML = description
document.getElementById("description")?.innerHTML = description
runApp()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fun main() {
onWasmReady {
val description = "Skiko running with ${getPlatform().name}"
document.title = description
findElementById("description")?.innerHTML = description
document.getElementById("description")?.innerHTML = description
runApp()
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.jetbrains.skiko.sample.js

import kotlinx.browser.document
import org.jetbrains.skia.Canvas
import org.jetbrains.skia.Paint
import org.jetbrains.skia.Rect
import org.jetbrains.skiko.SkiaLayer
import org.jetbrains.skiko.SkiaLayerRenderDelegate
import org.jetbrains.skiko.SkikoRenderDelegate
import org.w3c.dom.Element
import kotlinx.browser.document

private class DemoApp: SkikoRenderDelegate {
private val paint = Paint()
Expand All @@ -25,7 +24,7 @@ private class DemoApp: SkikoRenderDelegate {
internal fun runApp() {
for (index in 1 .. 3) {
val skiaLayer = SkiaLayer()
val canvas = findElementById("c$index")!!
val canvas = document.getElementById("c$index")!!
val app = if (index == 3) {
DemoApp()
} else {
Expand All @@ -35,6 +34,4 @@ internal fun runApp() {
skiaLayer.attachTo(canvas)
skiaLayer.needRedraw()
}
}

fun findElementById(id: String): Element? = document.getElementById(id)
}
20 changes: 15 additions & 5 deletions skiko/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:OptIn(ExperimentalKotlinGradlePluginApi::class)
@file:OptIn(ExperimentalKotlinGradlePluginApi::class, ExperimentalWasmDsl::class)

import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.LibraryPlugin
Expand All @@ -8,10 +8,11 @@ import org.jetbrains.compose.internal.publishing.MavenCentralProperties
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import tasks.configuration.*
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
kotlin("multiplatform")
Expand Down Expand Up @@ -58,6 +59,11 @@ repositories {
}

kotlin {
compilerOptions {
languageVersion.set(KotlinVersion.KOTLIN_2_2)
apiVersion.set(KotlinVersion.KOTLIN_2_2)
}

applyHierarchyTemplate(skikoSourceSetHierarchyTemplate)
skikoProjectContext.declareSkiaTasks()

Expand Down Expand Up @@ -96,7 +102,7 @@ kotlin {
skikoProjectContext.declareWasmTasks()

js {
moduleName = "skiko-kjs" // override the name to avoid name collision with a different skiko.js file
outputModuleName.set("skiko-kjs") // override the name to avoid name collision with a different skiko.js file
browser {
testTask {
useKarma {
Expand All @@ -120,7 +126,7 @@ kotlin {

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "skiko-kjs-wasm" // override the name to avoid name collision with a different skiko.js file
outputModuleName.set("skiko-kjs-wasm") // override the name to avoid name collision with a different skiko.js file
browser {
testTask {
useKarma {
Expand Down Expand Up @@ -183,6 +189,10 @@ kotlin {
implementation(libs.coroutines.core.jvm)
}

skikoProjectContext.webMainSourceSet?.dependencies {
implementation(libs.kotlinx.browser)
}

skikoProjectContext.awtMainSourceSet?.dependencies {
implementation(libs.jetbrainsRuntime.api)
}
Expand Down Expand Up @@ -392,7 +402,7 @@ tasks.register("printSkiaVersion") {

tasks.withType<KotlinNativeCompile>().configureEach {
// https://youtrack.jetbrains.com/issue/KT-56583
compilerOptions.freeCompilerArgs.add("-XXLanguage:+ImplicitSignedToUnsignedIntegerConversion")
//compilerOptions.freeCompilerArgs.add("-XXLanguage:+ImplicitSignedToUnsignedIntegerConversion")
compilerOptions.freeCompilerArgs.add("-opt-in=kotlinx.cinterop.ExperimentalForeignApi")
}

Expand Down
2 changes: 1 addition & 1 deletion skiko/buildSrc/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kotlin.version=2.0.10
kotlin.version=2.3.0
9 changes: 1 addition & 8 deletions skiko/buildSrc/src/main/kotlin/imports.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ import org.gradle.api.Project
val Project.wasmImports
get() = layout.buildDirectory.dir("imports").get().asFile

val Project.setupMjs
get() = wasmImports.resolve("setup.mjs")

val Project.setupReexportMjs
get() = wasmImports.resolve("js-reexport-symbols.mjs")

val Project.skikoTestMjs
get() = wasmImports.resolve("skiko-test.mjs")
fun Project.wasmImport(name: String) = wasmImports.resolve(name)

const val IMPORT_GENERATOR = "import-generator"
2 changes: 2 additions & 0 deletions skiko/buildSrc/src/main/kotlin/sourceHierarchy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ val SkikoProjectContext.awtTestSourceSet get() = if (project.supportAwt) kotlin.

val SkikoProjectContext.androidMainSourceSet get() = if (project.supportAndroid) kotlin.sourceSets.getByName("androidMain") else null

val SkikoProjectContext.webMainSourceSet get() = if (project.supportWeb) kotlin.sourceSets.getByName("webMain") else null

val SkikoProjectContext.webTestSourceSet get() = if (project.supportWeb) kotlin.sourceSets.getByName("webTest") else null

val SkikoProjectContext.wasmJsTest get() = if (project.supportWeb) kotlin.sourceSets.getByName("wasmJsTest") else null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fun configureCinterop(
}
target.compilations.getByName("main") {
cinterops.create(cinteropName).apply {
defFileProperty.set(writeCInteropDef.map { it.outputFile.get().asFile })
definitionFile.set(writeCInteropDef.flatMap { it.outputFile })
}
}
}
Expand Down Expand Up @@ -285,6 +285,7 @@ fun SkikoProjectContext.configureNativeTarget(os: OS, arch: Arch, target: Kotlin
OS.Linux -> listOf(
"-linker-option", "-lX11",
"-linker-option", "-lGLX",
"-linker-option", "--allow-shlib-undefined"
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title contains a typo: "shliub" should be "shlib" (shared library).

Copilot uses AI. Check for mistakes.
)
else -> emptyList()
})
Expand All @@ -294,9 +295,13 @@ fun SkikoProjectContext.configureNativeTarget(os: OS, arch: Arch, target: Kotlin
target.binaries.all {
freeCompilerArgs += allLibraries.map { listOf("-include-binary", it) }.flatten() + linkerFlags
}


target.compilations.all {
kotlinOptions {
freeCompilerArgs += allLibraries.map { listOf("-include-binary", it) }.flatten() + linkerFlags
compilerOptions.configure {
freeCompilerArgs.addAll(
allLibraries.flatMap { listOf("-include-binary", it) } + linkerFlags
)
}
}

Expand Down Expand Up @@ -343,7 +348,7 @@ fun KotlinMultiplatformExtension.configureIOSTestsWithMetal(project: Project) {
if (targets.names.contains(target)) {
val testBinary = targets.getByName<KotlinNativeTarget>(target).binaries.getTest("DEBUG")
project.tasks.register(target + "TestWithMetal") {
dependsOn(testBinary.linkTask)
dependsOn(testBinary.linkTaskProvider)
doLast {
val simulatorIdPropertyKey = "skiko.iosSimulatorUUID"
val simulatorId = project.findProperty(simulatorIdPropertyKey)?.toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:OptIn(ExperimentalWasmDsl::class)

package tasks.configuration

import Arch
Expand All @@ -19,16 +17,22 @@ import org.gradle.kotlin.dsl.getting
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.registering
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
import projectDirs
import registerOrGetSkiaDirProvider
import setupMjs
import setupReexportMjs
import skikoTestMjs
import supportWeb
import wasmImport
import java.io.File

private val Project.setupMjs
get() = wasmImport("setup.mjs")

private val Project.setupReexportMjs
get() = wasmImport("js-reexport-symbols.mjs")

private val Project.skikoTestMjs
get() = wasmImport("skiko-test.mjs")

fun SkikoProjectContext.declareWasmTasks() {
if (!project.supportWeb) {
return
Expand Down
Loading
Loading