Skip to content

Commit

Permalink
When using JAR files for the Kotlin Native, don't include all of the …
Browse files Browse the repository at this point in the history
…versions.
  • Loading branch information
TadeasKriz committed Oct 31, 2023
1 parent d6e361e commit c711ddc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -132,7 +131,9 @@ abstract class DevAcceptanceTests : Plugin<Project> {
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")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -97,7 +97,10 @@ abstract class DevAcceptanceTestsFramework : Plugin<Project> {

dependencies {
weak("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
weak(kotlinNativeCompilerEmbeddableDependency(kotlinVersion))

withKotlinNativeCompilerEmbeddableDependency(kotlinVersion, isTarget = sourceSet.isTarget) {
weak(it)
}

testOnly(libs.bundles.testing.jvm)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -33,7 +33,9 @@ abstract class SkieCompiler : Plugin<Project> {

dependencies {
weak("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
weak(kotlinNativeCompilerEmbeddableDependency(kotlinVersion))
withKotlinNativeCompilerEmbeddableDependency(kotlinVersion, isTarget = sourceSet.isTarget) {
weak(it)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> Project.backupProperty(name: String): BackupProperty<T>? {
Expand Down

0 comments on commit c711ddc

Please sign in to comment.