Skip to content

Commit

Permalink
Add support for using Kotlin Native Compiler Embeddable artifact from…
Browse files Browse the repository at this point in the history
… Konan home.
  • Loading branch information
TadeasKriz committed Oct 31, 2023
1 parent 89e4786 commit d6e361e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package co.touchlab.skie.buildsetup.plugins

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.version.AcceptanceTestsComponent
import co.touchlab.skie.gradle.version.KotlinToolingVersionComponent
import co.touchlab.skie.gradle.version.acceptanceTest
Expand All @@ -18,16 +21,12 @@ import com.github.gmazzo.gradle.plugins.BuildConfigExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.Dependency
import org.gradle.api.attributes.Attribute
import org.gradle.api.attributes.Usage
import org.gradle.api.file.Directory
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.exclude
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.project
import org.gradle.kotlin.dsl.*
import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.gradle.language.jvm.tasks.ProcessResources
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
Expand Down Expand Up @@ -132,7 +131,8 @@ abstract class DevAcceptanceTests : Plugin<Project> {

dependencies {
weak("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
weak("org.jetbrains.kotlin:kotlin-native-compiler-embeddable:$kotlinVersion")

weak(kotlinNativeCompilerEmbeddableDependency(kotlinVersion))

testOnly("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +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.kotlinNativeCompilerHome
import co.touchlab.skie.gradle.util.libs
import co.touchlab.skie.gradle.version.ToolingVersions
Expand Down Expand Up @@ -96,7 +97,7 @@ abstract class DevAcceptanceTestsFramework : Plugin<Project> {

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

testOnly(libs.bundles.testing.jvm)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +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.version.kotlinToolingVersion
import co.touchlab.skie.gradle.version.kotlinToolingVersionDimension
import co.touchlab.skie.gradle.version.target.MultiDimensionTargetExtension
Expand Down Expand Up @@ -32,7 +33,7 @@ abstract class SkieCompiler : Plugin<Project> {

dependencies {
weak("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
weak("org.jetbrains.kotlin:kotlin-native-compiler-embeddable:$kotlinVersion")
weak(kotlinNativeCompilerEmbeddableDependency(kotlinVersion))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package co.touchlab.skie.gradle.util

import co.touchlab.skie.gradle.KotlinToolingVersion
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.provideDelegate
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
import org.jetbrains.kotlin.konan.CompilerVersion
import java.io.File
Expand Down Expand Up @@ -30,6 +32,19 @@ fun Project.kotlinNativeCompilerHome(kotlinVersion: KotlinToolingVersion): File
.compilerDirectory
}

internal fun Project.kotlinNativeCompilerEmbeddableDependency(kotlinVersion: KotlinToolingVersion): Dependency {
val kotlinNativeCompilerEmbeddableFromHome: String? by project
return if (kotlinNativeCompilerEmbeddableFromHome.toBoolean()) {
project.dependencies.create(
files(
kotlinNativeCompilerHome(kotlinVersion).resolve("konan/lib/kotlin-native-compiler-embeddable.jar")
)
)
} else {
project.dependencies.create("org.jetbrains.kotlin:kotlin-native-compiler-embeddable:$kotlinVersion")
}
}

private fun <T> Project.backupProperty(name: String): BackupProperty<T>? {
return if (properties.containsKey(name)) {
BackupProperty(name, properties[name] as T)
Expand Down
5 changes: 4 additions & 1 deletion common-gradle/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ kotlin.mpp.import.enableKgpDependencyResolution=true
pluginId=co.touchlab.skie

# WIP remove RC
versionSupport.kotlinTooling=1.8.0(1.8.10), 1.8.20(1.8.21, 1.8.22), 1.9.0(1.9.10), 1.9.20[1.9.20-RC2]
versionSupport.kotlinTooling=1.8.0(1.8.10), 1.8.20(1.8.21, 1.8.22), 1.9.0(1.9.10), 1.9.20[1.9.20]
versionSupport.gradleApi=7.3, 8.0, 8.1

touchlab.key=ABCDEFGHIJKLMNOPQRSTUVWXYZ


kotlinNativeCompilerEmbeddableFromHome=true

0 comments on commit d6e361e

Please sign in to comment.