[Gradle][MPP] Bundle cinterop metadata in allMetadata klib
^KT-46198
This commit is contained in:
committed by
Space
parent
94c68c99a0
commit
2dda5f6ed2
+3
@@ -308,6 +308,9 @@ class KotlinMetadataTargetConfigurator :
|
||||
if (!isHostSpecific) {
|
||||
val metadataContent = project.filesWithUnpackedArchives(this@apply.output.allOutputs, setOf("klib"))
|
||||
allMetadataJar.configure { it.from(metadataContent) { spec -> spec.into(this@apply.defaultSourceSet.name) } }
|
||||
if (this is KotlinSharedNativeCompilation) {
|
||||
project.includeCommonizedCInteropMetadata(allMetadataJar, this)
|
||||
}
|
||||
} else {
|
||||
if (platformCompilations.filterIsInstance<KotlinNativeCompilation>().none { it.konanTarget.enabledOnCurrentHost }) {
|
||||
// Then we don't have any platform module to put this compiled source set to, so disable the compilation task:
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.targets.native.internal
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.api.tasks.bundling.Zip
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinSharedNativeCompilation
|
||||
|
||||
internal fun Project.includeCommonizedCInteropMetadata(metadataKlib: TaskProvider<out Zip>, compilation: KotlinSharedNativeCompilation) {
|
||||
metadataKlib.configure { jar -> includeCommonizedCInteropMetadata(jar, compilation) }
|
||||
}
|
||||
|
||||
internal fun Project.includeCommonizedCInteropMetadata(metadataKlib: Zip, compilation: KotlinSharedNativeCompilation) {
|
||||
val commonizerTask = commonizeCInteropTask?.get() ?: return
|
||||
val commonizerDependencyToken = CInteropCommonizerDependent.from(compilation) ?: return
|
||||
val outputDirectory = commonizerTask.commonizedOutputDirectory(commonizerDependencyToken) ?: return
|
||||
|
||||
metadataKlib.from(outputDirectory) { spec ->
|
||||
spec.into(compilation.defaultSourceSet.name + "-cinterop")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user