From c711ddc44e8fa91627ea0c12805f2af58b7c1d36 Mon Sep 17 00:00:00 2001 From: Tadeas Kriz Date: Mon, 30 Oct 2023 21:59:08 -0400 Subject: [PATCH] When using JAR files for the Kotlin Native, don't include all of the versions. --- .../coroutines/AddDependencyOnSkieRuntime.kt | 2 +- .../buildsetup/plugins/DevAcceptanceTests.kt | 7 ++++--- .../plugins/DevAcceptanceTestsFramework.kt | 7 +++++-- .../skie/buildsetup/plugins/SkieCompiler.kt | 6 ++++-- .../gradle/util/KotlinNativeCompilerHome.kt | 17 +++++++++++------ 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt b/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt index 720fcae3..0240937e 100644 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt +++ b/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt @@ -54,4 +54,4 @@ private val KonanTarget.presetName: String KonanTarget.MINGW_X86, KonanTarget.WASM32, is KonanTarget.ZEPHYR -> error( "SKIE doesn't support these platforms, so it should never ask for the preset name of this target." ) - } + }.lowercase() diff --git a/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTests.kt b/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTests.kt index 39d6f58e..7c356cb7 100644 --- a/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTests.kt +++ b/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTests.kt @@ -4,8 +4,7 @@ import co.touchlab.skie.gradle.KotlinCompilerVersion import co.touchlab.skie.gradle.KotlinToolingVersion import co.touchlab.skie.gradle.architecture.MacOsCpuArchitecture import co.touchlab.skie.gradle.util.enquoted -import co.touchlab.skie.gradle.util.kotlinNativeCompilerEmbeddableDependency -import co.touchlab.skie.gradle.util.kotlinNativeCompilerHome +import co.touchlab.skie.gradle.util.withKotlinNativeCompilerEmbeddableDependency import co.touchlab.skie.gradle.version.AcceptanceTestsComponent import co.touchlab.skie.gradle.version.KotlinToolingVersionComponent import co.touchlab.skie.gradle.version.acceptanceTest @@ -132,7 +131,9 @@ abstract class DevAcceptanceTests : Plugin { dependencies { weak("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") - weak(kotlinNativeCompilerEmbeddableDependency(kotlinVersion)) + withKotlinNativeCompilerEmbeddableDependency(kotlinVersion, isTarget = sourceSet.isTarget) { + weak(it) + } testOnly("org.jetbrains.kotlin:kotlin-test:$kotlinVersion") } diff --git a/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTestsFramework.kt b/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTestsFramework.kt index 84293bd8..619fafc0 100644 --- a/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTestsFramework.kt +++ b/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTestsFramework.kt @@ -1,9 +1,9 @@ package co.touchlab.skie.buildsetup.plugins import co.touchlab.skie.gradle.KotlinCompilerVersion -import co.touchlab.skie.gradle.util.kotlinNativeCompilerEmbeddableDependency import co.touchlab.skie.gradle.util.kotlinNativeCompilerHome import co.touchlab.skie.gradle.util.libs +import co.touchlab.skie.gradle.util.withKotlinNativeCompilerEmbeddableDependency import co.touchlab.skie.gradle.version.ToolingVersions import co.touchlab.skie.gradle.version.kotlinToolingVersion import co.touchlab.skie.gradle.version.kotlinToolingVersionDimension @@ -97,7 +97,10 @@ abstract class DevAcceptanceTestsFramework : Plugin { dependencies { weak("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}") - weak(kotlinNativeCompilerEmbeddableDependency(kotlinVersion)) + + withKotlinNativeCompilerEmbeddableDependency(kotlinVersion, isTarget = sourceSet.isTarget) { + weak(it) + } testOnly(libs.bundles.testing.jvm) } diff --git a/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/SkieCompiler.kt b/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/SkieCompiler.kt index 918a3770..7ad1e115 100644 --- a/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/SkieCompiler.kt +++ b/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/SkieCompiler.kt @@ -1,7 +1,7 @@ package co.touchlab.skie.buildsetup.plugins import co.touchlab.skie.gradle.KotlinCompilerVersion -import co.touchlab.skie.gradle.util.kotlinNativeCompilerEmbeddableDependency +import co.touchlab.skie.gradle.util.withKotlinNativeCompilerEmbeddableDependency import co.touchlab.skie.gradle.version.kotlinToolingVersion import co.touchlab.skie.gradle.version.kotlinToolingVersionDimension import co.touchlab.skie.gradle.version.target.MultiDimensionTargetExtension @@ -33,7 +33,9 @@ abstract class SkieCompiler : Plugin { dependencies { weak("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") - weak(kotlinNativeCompilerEmbeddableDependency(kotlinVersion)) + withKotlinNativeCompilerEmbeddableDependency(kotlinVersion, isTarget = sourceSet.isTarget) { + weak(it) + } } } } diff --git a/build-setup/src/main/kotlin/co/touchlab/skie/gradle/util/KotlinNativeCompilerHome.kt b/build-setup/src/main/kotlin/co/touchlab/skie/gradle/util/KotlinNativeCompilerHome.kt index 00a255b2..89da4cc9 100644 --- a/build-setup/src/main/kotlin/co/touchlab/skie/gradle/util/KotlinNativeCompilerHome.kt +++ b/build-setup/src/main/kotlin/co/touchlab/skie/gradle/util/KotlinNativeCompilerHome.kt @@ -32,17 +32,22 @@ fun Project.kotlinNativeCompilerHome(kotlinVersion: KotlinToolingVersion): File .compilerDirectory } -internal fun Project.kotlinNativeCompilerEmbeddableDependency(kotlinVersion: KotlinToolingVersion): Dependency { +internal inline fun Project.withKotlinNativeCompilerEmbeddableDependency(kotlinVersion: KotlinToolingVersion, isTarget: Boolean, block: (Dependency) -> Unit) { val kotlinNativeCompilerEmbeddableFromHome: String? by project - return if (kotlinNativeCompilerEmbeddableFromHome.toBoolean()) { - project.dependencies.create( - files( - kotlinNativeCompilerHome(kotlinVersion).resolve("konan/lib/kotlin-native-compiler-embeddable.jar") + val dependency = if (kotlinNativeCompilerEmbeddableFromHome.toBoolean()) { + if (isTarget) { + project.dependencies.create( + files( + kotlinNativeCompilerHome(kotlinVersion).resolve("konan/lib/kotlin-native.jar") + ) ) - ) + } else { + return + } } else { project.dependencies.create("org.jetbrains.kotlin:kotlin-native-compiler-embeddable:$kotlinVersion") } + block(dependency) } private fun Project.backupProperty(name: String): BackupProperty? {