[K/N] Don't add linkDependencies when serializing a metadata klib
^KT-56205 Verification Pending
This commit is contained in:
committed by
Space Team
parent
1978566fee
commit
b6ea04d789
+21
-13
@@ -48,20 +48,28 @@ internal val WriteKlibPhase = createSimpleNamedCompilerPhase<PhaseContext, Seria
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
metadata libraries do not have 'link' dependencies, as there are several reasons
|
||||
why a consumer might not be able to provide the same compile classpath as the producer
|
||||
(e.g. commonized cinterops, host vs client environment differences).
|
||||
*/
|
||||
val linkDependencies = if (context.config.metadataKlib) emptyList()
|
||||
else input.neededLibraries
|
||||
|
||||
buildLibrary(
|
||||
config.nativeLibraries,
|
||||
config.includeBinaries,
|
||||
input.neededLibraries,
|
||||
input.serializedMetadata!!,
|
||||
input.serializedIr,
|
||||
versions,
|
||||
target,
|
||||
output,
|
||||
libraryName,
|
||||
nopack,
|
||||
shortLibraryName,
|
||||
manifestProperties,
|
||||
input.dataFlowGraph
|
||||
natives = config.nativeLibraries,
|
||||
included = config.includeBinaries,
|
||||
linkDependencies = linkDependencies,
|
||||
metadata = input.serializedMetadata!!,
|
||||
ir = input.serializedIr,
|
||||
versions = versions,
|
||||
target = target,
|
||||
output = output,
|
||||
moduleName = libraryName,
|
||||
nopack = nopack,
|
||||
shortName = shortLibraryName,
|
||||
manifestProperties = manifestProperties,
|
||||
dataFlowGraph = input.dataFlowGraph
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ dependencies {
|
||||
testImplementation(kotlinGradlePluginTest)
|
||||
testImplementation(project(":kotlin-gradle-subplugin-example"))
|
||||
testImplementation(project(":kotlin-test:kotlin-test-jvm"))
|
||||
testImplementation(project(":kotlin-util-klib"))
|
||||
|
||||
testImplementation(project(":native:kotlin-native-utils"))
|
||||
testImplementation(project(":native:kotlin-klib-commonizer-api"))
|
||||
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.mpp
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.konan.properties.hasProperty
|
||||
import org.jetbrains.kotlin.library.KLIB_PROPERTY_DEPENDS
|
||||
import org.jetbrains.kotlin.library.ToolingSingleFileKlibResolveStrategy
|
||||
import org.jetbrains.kotlin.library.unresolvedDependencies
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.fail
|
||||
|
||||
@MppGradlePluginTests
|
||||
@DisplayName("Tests for multiplatform | shared native compilations")
|
||||
class MppSharedNativeCompileIT : KGPBaseTest() {
|
||||
/**
|
||||
* https://youtrack.jetbrains.com/issue/KT-56205/Shared-Native-Compilation-False-positive-w-Could-not-find-warnings-on-metadata-klibs
|
||||
* metadata klib should not contain any dependsOn= in their klib manifest.
|
||||
*/
|
||||
@GradleTest
|
||||
fun `test - shared native klib - does not contain 'depends=' manifest property`(gradleVersion: GradleVersion) {
|
||||
project("kt-54995-compileSharedNative-with-okio", gradleVersion) {
|
||||
build("compileNativeMainKotlinMetadata") {
|
||||
val nativeMainKlib = projectPath.resolve("build/classes/kotlin/metadata/nativeMain/klib/test-project_nativeMain.klib")
|
||||
assertFileExists(nativeMainKlib)
|
||||
|
||||
val libraryFile = org.jetbrains.kotlin.library.resolveSingleFileKlib(
|
||||
org.jetbrains.kotlin.konan.file.File(nativeMainKlib),
|
||||
strategy = ToolingSingleFileKlibResolveStrategy
|
||||
)
|
||||
|
||||
if (libraryFile.unresolvedDependencies.isNotEmpty()) {
|
||||
fail("Expected metadata klib to not list dependencies. Found ${libraryFile.unresolvedDependencies}")
|
||||
}
|
||||
|
||||
if (libraryFile.manifestProperties.hasProperty(KLIB_PROPERTY_DEPENDS)) {
|
||||
fail(
|
||||
"Expected metadata klib to not contain $KLIB_PROPERTY_DEPENDS. " +
|
||||
"Value: ${libraryFile.manifestProperties.getProperty(KLIB_PROPERTY_DEPENDS)}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user