From ffb0b063a83b99da8100e3275e30752472d6760f Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Tue, 2 Jan 2024 12:15:56 +0100 Subject: [PATCH] [K/N][tests] Support dependencies for cinterop modules When building cinterop klibs, cinterop tool can accept dependencies, which affects the way it processes the native library. The test infrastructure allowed to specify cinterop module dependencies, but didn't actually pass them to the tool. This commit fixes that. --- .../kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt | 1 + .../test/blackbox/support/compilation/TestCompilation.kt | 5 +++++ .../blackbox/support/compilation/TestCompilationFactory.kt | 1 + 3 files changed, 7 insertions(+) diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt index adbde2aacf4..00c057af879 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt @@ -146,6 +146,7 @@ internal fun AbstractNativeSimpleTest.cinteropToLibrary( targets = targets, freeCompilerArgs = freeCompilerArgs, defFile = testCase.modules.single().files.single().location, + dependencies = emptyList(), expectedArtifact = getLibraryArtifact(testCase, outputDir) ).result } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt index 50d7de29ea4..cccae13cb0c 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt @@ -323,11 +323,16 @@ internal class CInteropCompilation( freeCompilerArgs: TestCompilerArgs, defFile: File, sources: List = emptyList(), + dependencies: Iterable>, expectedArtifact: KLIB ) : TestCompilation() { override val result: TestCompilationResult by lazy { val extraArgsArray = buildList { + dependencies.forEach { + add("-l") + add(it.artifact.path) + } addAll(freeCompilerArgs.cinteropArgs) sources.forEach { add("-Xcompile-source") diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt index 9d2f5d5312f..4344145933f 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt @@ -252,6 +252,7 @@ internal class TestCompilationFactory { freeCompilerArgs = freeCompilerArgs, defFile = defFile, sources = cSourceFiles, + dependencies = dependencies.forKlib(), expectedArtifact = klibArtifact ) to false // CInterop klib cannot be compiled into per-file cache }