[Gradle] KotlinNativeCompile: Only add -Xfragment{x} arguments for platform compilations

Shared Native compilations shall only use -Xcommon-sources
w/o setting any of the -Xfragment arguments in K2

^KT-57944 Verification Pending
This commit is contained in:
Sebastian Sellmair
2023-04-19 11:27:35 +02:00
committed by Space Team
parent 6c271eb24a
commit ed2b817409
@@ -452,7 +452,8 @@ internal constructor(
args.pluginOptions = compilerPlugins.flatMap { it.options.arguments }.toTypedArray()
if (compilerOptions.usesK2.get()) {
/* Shared native compilations in K2 still use -Xcommon-sources and klib dependencies */
if (compilerOptions.usesK2.get() && sharedCompilationData == null) {
args.fragments = multiplatformStructure.fragmentsCompilerArgs
args.fragmentRefines = multiplatformStructure.fragmentRefinesCompilerArgs
}
@@ -475,14 +476,9 @@ internal constructor(
}
sources { args ->
if (compilerOptions.usesK2.get()) {
/*
For now, we only pass multiplatform structure to K2 for platform compilations
Metadata compilations will compile against pre-compiled klibs from their dependsOn
*/
if (sharedCompilationData == null) {
args.fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs
}
/* Shared native compilations in K2 still use -Xcommon-sources and klib dependencies */
if (compilerOptions.usesK2.get() && sharedCompilationData == null) {
args.fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs
} else {
args.commonSources = commonSourcesTree.files.takeIf { it.isNotEmpty() }?.toPathsArray()
}