From e14de532bafd4968458472095b9a75ca73567a32 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sun, 22 Sep 2024 13:17:50 +0200 Subject: [PATCH] Support KONAN_DATA_DIR env var to customize .konan location This is a standard variable used by the Kotlin compiler, so we should respect it as well to correctly find the local native distribution. See https://github.com/JetBrains/kotlin/blob/master/kotlin-native/HACKING.md#compiler-environment-variables --- .../complete_kotlin/internal/KotlinNativeCompilerInfo.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/kotlin/com/louiscad/complete_kotlin/internal/KotlinNativeCompilerInfo.kt b/plugin/src/main/kotlin/com/louiscad/complete_kotlin/internal/KotlinNativeCompilerInfo.kt index adab3da..54c40e8 100644 --- a/plugin/src/main/kotlin/com/louiscad/complete_kotlin/internal/KotlinNativeCompilerInfo.kt +++ b/plugin/src/main/kotlin/com/louiscad/complete_kotlin/internal/KotlinNativeCompilerInfo.kt @@ -13,7 +13,9 @@ internal class KotlinNativeCompilerInfo( ) { companion object { - val konanDir = File(System.getProperty("user.home")).resolve(".konan") + // https://github.com/JetBrains/kotlin/blob/master/kotlin-native/HACKING.md#compiler-environment-variables + val konanDir = System.getenv("KONAN_DATA_DIR")?.ifBlank { null }?.let { File(it) } + ?: File(System.getProperty("user.home")).resolve(".konan") } private val kindaSimpleOsName: String = when {