[Gradle] Rename kotlin.native.[shaded -> useEmbeddableCompilerJar]
Also move it to PropertiesProvider.
This commit is contained in:
committed by
Space
parent
f049c4a630
commit
7c52077e40
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.native
|
||||
|
||||
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||
import org.jetbrains.kotlin.gradle.GradleVersionRequired
|
||||
import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.checkNativeCompilerClasspath
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class NativeEmbeddableCompilerJarIT : BaseGradleIT() {
|
||||
|
||||
override val defaultGradleVersion: GradleVersionRequired
|
||||
get() = GradleVersionRequired.FOR_MPP_SUPPORT
|
||||
|
||||
private fun String.isRegularJar() = this.endsWith("/kotlin-native.jar")
|
||||
private fun String.isEmbeddableJar() = this.endsWith("/kotlin-native-compiler-embeddable.jar")
|
||||
|
||||
private fun List<String>.includesRegularJar() = any { it.isRegularJar() }
|
||||
private fun List<String>.includesEmbeddableJar() = any { it.isEmbeddableJar() }
|
||||
|
||||
@Test
|
||||
fun testDefault() = with(transformNativeTestProjectWithPluginDsl("executables", directoryPrefix = "native-binaries")) {
|
||||
build(":runDebugExecutableHost") {
|
||||
assertSuccessful()
|
||||
checkNativeCompilerClasspath(":linkDebugExecutableHost", ":compileKotlinHost") {
|
||||
assertTrue(it.includesRegularJar())
|
||||
assertFalse(it.includesEmbeddableJar())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEmbeddableJarFalse() = with(transformNativeTestProjectWithPluginDsl("executables", directoryPrefix = "native-binaries")) {
|
||||
build(":runDebugExecutableHost", "-Pkotlin.native.useEmbeddableCompilerJar=false") {
|
||||
assertSuccessful()
|
||||
checkNativeCompilerClasspath(":linkDebugExecutableHost", ":compileKotlinHost") {
|
||||
assertTrue(it.includesRegularJar())
|
||||
assertFalse(it.includesEmbeddableJar())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEmbeddableJarTrue() = with(transformNativeTestProjectWithPluginDsl("executables", directoryPrefix = "native-binaries")) {
|
||||
build(":runDebugExecutableHost", "-Pkotlin.native.useEmbeddableCompilerJar=true") {
|
||||
assertSuccessful()
|
||||
checkNativeCompilerClasspath(":linkDebugExecutableHost", ":compileKotlinHost") {
|
||||
assertFalse(it.includesRegularJar())
|
||||
assertTrue(it.includesEmbeddableJar())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.isAtLeast
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.nativeUseEmbeddableCompilerJar
|
||||
import org.jetbrains.kotlin.gradle.tasks.CacheBuilder
|
||||
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
|
||||
import org.jetbrains.kotlin.konan.CompilerVersion
|
||||
@@ -84,15 +85,11 @@ internal abstract class KotlinNativeToolRunner(
|
||||
}
|
||||
|
||||
private val Project.kotlinNativeCompilerJar: String
|
||||
get() = if (isNativeEmbedded)
|
||||
get() = if (nativeUseEmbeddableCompilerJar)
|
||||
"$konanHome/konan/lib/kotlin-native-compiler-embeddable.jar"
|
||||
else
|
||||
"$konanHome/konan/lib/kotlin-native.jar"
|
||||
|
||||
//TODO: find better place (see org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin.isNativeEmbedded)
|
||||
private val Project.isNativeEmbedded: Boolean
|
||||
get() = findProperty("kotlin.native.shaded")?.toString()?.toBoolean() == true
|
||||
|
||||
final override fun checkClasspath() =
|
||||
check(classpath.isNotEmpty()) {
|
||||
"""
|
||||
|
||||
+8
@@ -254,6 +254,14 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val nativeDisableCompilerDaemon: Boolean?
|
||||
get() = booleanProperty("kotlin.native.disableCompilerDaemon")
|
||||
|
||||
/**
|
||||
* Switches Kotlin/Native tasks to using embeddable compiler jar,
|
||||
* allowing to apply backend-agnostic compiler plugin artifacts.
|
||||
* Will be default after proper migration.
|
||||
*/
|
||||
val nativeUseEmbeddableCompilerJar: Boolean
|
||||
get() = booleanProperty("kotlin.native.useEmbeddableCompilerJar") ?: false
|
||||
|
||||
/**
|
||||
* Allows a user to specify additional arguments of a JVM executing KLIB commonizer.
|
||||
*/
|
||||
|
||||
+3
@@ -76,6 +76,9 @@ abstract class AbstractKotlinNativeCompilation(
|
||||
override var enableEndorsedLibs: Boolean = false
|
||||
}
|
||||
|
||||
internal val Project.nativeUseEmbeddableCompilerJar: Boolean
|
||||
get() = PropertiesProvider(this).nativeUseEmbeddableCompilerJar
|
||||
|
||||
internal fun addSourcesToKotlinNativeCompileTask(
|
||||
project: Project,
|
||||
taskName: String,
|
||||
|
||||
Reference in New Issue
Block a user