Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow OS-specific paths for installed binaries and logs instead of ~/.skiko #897

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class RenderExceptionsHandler {
try {
if (output == null) {
output = File(
"${SkikoProperties.dataPath}/skiko-render-exception-${ProcessHandle.current().pid()}.log"
"${SkikoProperties.logPath}/skiko-render-exception-${ProcessHandle.current().pid()}.log"
)
output!!.parentFile.mkdirs()
}
Expand Down
36 changes: 33 additions & 3 deletions skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkikoProperties.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetbrains.skiko

import java.lang.System.getenv
import java.lang.System.getProperty

// TODO maybe we can get rid of global properties, and pass SkiaLayerProperties to Window -> ComposeWindow -> SkiaLayer
Expand Down Expand Up @@ -28,9 +29,38 @@ object SkikoProperties {
/**
* The path where to store data files.
*
* It is used for extracting the Skiko binaries (if `libraryPath` isn't null) and logging.
* It is used for extracting the Skiko binaries (if `libraryPath` isn't null).
*/
val dataPath: String get() = getProperty("skiko.data.path") ?: "${getProperty("user.home")}/.skiko/"
val dataPath: String get() {
return getProperty("skiko.data.path") ?: when (hostOs) {
OS.Windows -> "${getenv("LOCALAPPDATA")}/Skiko"
OS.MacOS, OS.Ios -> "${getProperty("user.home")}/Library/Application Support/Skiko"
else -> {
var dataHome = getenv("XDG_DATA_HOME")
if (dataHome == null || !dataHome.startsWith('/')) {
dataHome = "${getProperty("user.home")}/.local/share"
}
return "${dataHome}/skiko"
}
}
}

/**
* The path where to store log files.
*/
val logPath: String get() {
return getProperty("skiko.data.path") ?: when (hostOs) {
OS.Windows -> "${getenv("LOCALAPPDATA")}/Skiko"
OS.MacOS, OS.Ios -> "${getProperty("user.home")}/Library/Logs/Skiko"
else -> {
var stateHome = getenv("XDG_STATE_HOME")
if (stateHome == null || !stateHome.startsWith('/')) {
stateHome = "${getProperty("user.home")}/.local/state"
}
return "${stateHome}/skiko"
}
}
}

val vsyncEnabled: Boolean get() = getProperty("skiko.vsync.enabled")?.toBoolean() ?: true

Expand All @@ -54,7 +84,7 @@ object SkikoProperties {
val fpsLongFramesMillis: Double? get() = getProperty("skiko.fps.longFrames.millis")?.toDouble()

val renderApi: GraphicsApi get() {
val environment = System.getenv("SKIKO_RENDER_API")
val environment = getenv("SKIKO_RENDER_API")
val property = getProperty("skiko.renderApi")
return parseRenderApi(environment ?: property)
}
Expand Down