Add main interop libraries in test interop dependencies
Earlier we added interop libraries built for a main compilation in dependencies of a corresponding test compilation. But we didn't add them in dependencies of interop libraries built for the test compilation. It caused cinterop failures when the test compilation has interop libraries. This patch fixes it by adding main interop libraries in dependencies of test ones. Also earlier interop libraries of test compilations were unintentionally added in apiElements and publication. This patch fixes this issue too. Issue #KT-30290 Fixed
This commit is contained in:
+1
@@ -1124,6 +1124,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
assertTasksExecuted(":publishedLibrary:cinteropStdio${host.capitalize()}")
|
||||
assertTrue(output.contains("Published test"), "No test output found")
|
||||
assertFileExists("publishedLibrary/build/classes/kotlin/$host/main/publishedLibrary-cinterop-stdio.klib")
|
||||
assertFileExists("publishedLibrary/build/classes/kotlin/$host/test/test-cinterop-stdio.klib")
|
||||
assertFileExists("repo/org/example/publishedLibrary-$host/1.0/publishedLibrary-$host-1.0-cinterop-stdio.klib")
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -34,10 +34,13 @@ kotlin {
|
||||
fromPreset(presets.mingwX64, 'mingw64')
|
||||
|
||||
configure([macos64, linux64, mingw64]) {
|
||||
compilations.main.cinterops {
|
||||
stdio {
|
||||
packageName 'example.cinterop.published.stdio'
|
||||
extraOpts '-nodefaultlibs'
|
||||
compilations.all {
|
||||
// Add interop in the test compilation too as a regression test for KT-30290.
|
||||
cinterops {
|
||||
stdio {
|
||||
packageName 'example.cinterop.published.stdio'
|
||||
extraOpts '-nodefaultlibs'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-4
@@ -194,16 +194,25 @@ open class KotlinNativeTargetConfigurator(
|
||||
|
||||
val interopOutput = project.files(outputFileProvider).builtBy(this)
|
||||
with(compilation) {
|
||||
// Register the interop library as a dependency of the compilation to make IDE happy.
|
||||
project.dependencies.add(compileDependencyConfigurationName, interopOutput)
|
||||
if (isMainCompilation) {
|
||||
target.compilations.findByName(TEST_COMPILATION_NAME)?.let {
|
||||
project.dependencies.add(it.compileDependencyConfigurationName, interopOutput)
|
||||
// Register the interop library as an outgoing klib to allow depending on projects with cinterops.
|
||||
project.dependencies.add(target.apiElementsConfigurationName, interopOutput)
|
||||
// Add the interop library in publication.
|
||||
createCInteropKlibArtifact(interop, this@apply)
|
||||
// We cannot add the interop library in an compilation output because in this case
|
||||
// IDE doesn't see this library in module dependencies. So we have to manually add
|
||||
// main interop libraries in dependencies of the default test compilation.
|
||||
target.compilations.findByName(TEST_COMPILATION_NAME)?.let { testCompilation ->
|
||||
project.dependencies.add(testCompilation.compileDependencyConfigurationName, interopOutput)
|
||||
testCompilation.cinterops.all {
|
||||
it.dependencyFiles += interopOutput
|
||||
}
|
||||
}
|
||||
}
|
||||
project.dependencies.add(target.apiElementsConfigurationName, interopOutput)
|
||||
}
|
||||
}
|
||||
createCInteropKlibArtifact(interop, interopTask)
|
||||
}
|
||||
}
|
||||
// endregion.
|
||||
|
||||
Reference in New Issue
Block a user