[Gradle] Move K/N binary options retrieving to PropertiesProvider
This commit is contained in:
+29
-1
@@ -262,6 +262,16 @@ internal fun PropertiesProvider.mapKotlinDaemonProperties(task: CompileUsingKotl
|
||||
val nativeUseEmbeddableCompilerJar: Boolean
|
||||
get() = booleanProperty("kotlin.native.useEmbeddableCompilerJar") ?: false
|
||||
|
||||
/**
|
||||
* Allows a user to set project-wide options that will be passed to the K/N compiler via -Xbinary flag.
|
||||
* E.g. setting kotlin.native.binary.memoryModel=experimental results in passing -Xbinary=memoryModel=experimental to the compiler.
|
||||
* @return a map: property name without `kotlin.native.binary.` prefix -> property value
|
||||
*/
|
||||
val nativeBinaryOptions: Map<String, String>
|
||||
get() = propertiesWithPrefix(KOTLIN_NATIVE_BINARY_OPTION_PREFIX).mapKeys { (key, _) ->
|
||||
key.removePrefix(KOTLIN_NATIVE_BINARY_OPTION_PREFIX)
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows a user to specify additional arguments of a JVM executing KLIB commonizer.
|
||||
*/
|
||||
@@ -391,7 +401,23 @@ internal fun PropertiesProvider.mapKotlinDaemonProperties(task: CompileUsingKotl
|
||||
localProperties.getProperty(propName)
|
||||
}
|
||||
|
||||
object PropertyNames {
|
||||
private fun propertiesWithPrefix(prefix: String): Map<String, String> {
|
||||
val result = mutableMapOf<String, String>()
|
||||
project.properties.forEach { (name, value) ->
|
||||
if (name.startsWith(prefix) && value is String) {
|
||||
result.put(name, value)
|
||||
}
|
||||
}
|
||||
localProperties.forEach { (name, value) ->
|
||||
if (name is String && name.startsWith(prefix) && value is String) {
|
||||
// Project properties have higher priority.
|
||||
result.putIfAbsent(name, value)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
object PropertyNames {
|
||||
const val KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA = "kotlin.mpp.enableGranularSourceSetsMetadata"
|
||||
const val KOTLIN_MPP_HIERARCHICAL_STRUCTURE_BY_DEFAULT = "kotlin.internal.mpp.hierarchicalStructureByDefault"
|
||||
const val KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT = "kotlin.mpp.hierarchicalStructureSupport"
|
||||
@@ -405,6 +431,8 @@ internal fun PropertiesProvider.mapKotlinDaemonProperties(task: CompileUsingKotl
|
||||
|
||||
internal const val KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES = "kotlin.native.ignoreIncorrectDependencies"
|
||||
|
||||
private const val KOTLIN_NATIVE_BINARY_OPTION_PREFIX = "kotlin.native.binary."
|
||||
|
||||
operator fun invoke(project: Project): PropertiesProvider =
|
||||
with(project.extensions.extraProperties) {
|
||||
if (!has(CACHED_PROVIDER_EXT_NAME)) {
|
||||
|
||||
+2
-12
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
|
||||
import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinNativeCompilationData
|
||||
@@ -593,14 +594,7 @@ constructor(
|
||||
@Input get() = binary.binaryOptions
|
||||
|
||||
val projectWideBinaryOptions: Map<String, String>
|
||||
@Input get() = project.properties.mapNotNull { (name, value) ->
|
||||
val prefix = KOTLIN_NATIVE_BINARY_OPTION_PREFIX
|
||||
if (name.startsWith(prefix) && value is String) {
|
||||
name.removePrefix(prefix) to value
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}.toMap()
|
||||
@Input get() = PropertiesProvider(project).nativeBinaryOptions
|
||||
|
||||
val processTests: Boolean
|
||||
@Input get() = binary is TestExecutable
|
||||
@@ -709,10 +703,6 @@ constructor(
|
||||
validatedExportedLibraries()
|
||||
super.compile()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val KOTLIN_NATIVE_BINARY_OPTION_PREFIX = "kotlin.native.binary."
|
||||
}
|
||||
}
|
||||
|
||||
private class ExternalDependenciesBuilder(
|
||||
|
||||
Reference in New Issue
Block a user