[Gradle] Read the kotlin.useK2 gradle property value for K/N tasks

This commit is contained in:
Alexander.Likhachev
2023-03-23 19:58:48 +01:00
committed by Space Team
parent f44d82ce6d
commit ca59092318
3 changed files with 8 additions and 3 deletions
@@ -392,6 +392,11 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotl
it.destinationDirectory.set(project.klibOutputDirectory(compilationInfo).resolve("klib"))
it.compilerOptions.moduleName.set(project.klibModuleName(it.baseName))
val propertiesProvider = PropertiesProvider(project)
if (propertiesProvider.useK2 == true) {
it.compilerOptions.useK2.set(true)
}
it.compilerOptions.useK2.disallowChanges()
}
compilationInfo.classesDirs.from(compileTaskProvider.map { it.outputFile })
@@ -17,9 +17,6 @@ class NativeCompilerOptions(project: Project) : HasCompilerOptions<KotlinCommonC
override val options: KotlinNativeCompilerOptions = project.objects
.newInstance(KotlinNativeCompilerOptionsDefault::class.java)
.apply {
useK2.finalizeValue()
}
internal fun syncLanguageSettings(languageSettings: LanguageSettings) {
applyLanguageSettingsToCompilerOptions(languageSettings, options)
@@ -187,6 +187,9 @@ internal fun buildKotlinNativeCompileCommonArgs(
addKey("-nowarn", compilerOptions.suppressWarnings.get())
addKey("-verbose", compilerOptions.verbose.get())
addKey("-progressive", compilerOptions.progressiveMode.get())
if (compilerOptions.useK2.get()) {
add("-Xuse-k2")
}
compilerOptions.optIn.get().forEach { add("-opt-in=$it") }
addAll(compilerOptions.freeCompilerArgs.get())