[Gradle] Don't resolve Apple-specific Cinterops on Linux & Windows
Resolving such dependencies was lenient, however it produced a lot of annoying error messages in the IDE. Because "file not found". KGP already warns user if they are declared Apple-specific targets on non-macos machine. ^KT-66514 Verification Pending
This commit is contained in:
committed by
Space Team
parent
e2336e1752
commit
a56dc7d73a
+10
-2
@@ -99,13 +99,21 @@ class MppIdeDependencyResolutionIT : KGPBaseTest() {
|
|||||||
|
|
||||||
resolveIdeDependencies("dep-with-cinterop") { dependencies ->
|
resolveIdeDependencies("dep-with-cinterop") { dependencies ->
|
||||||
dependencies["commonMain"].cinteropDependencies()
|
dependencies["commonMain"].cinteropDependencies()
|
||||||
.assertMatches(binaryCoordinates(Regex("a:dep.*\\(linux_arm64, linux_x64\\)")))
|
.assertMatches(binaryCoordinates(Regex("a:dep.*\\(ios_x64, linux_arm64, linux_x64\\)")))
|
||||||
dependencies["commonTest"].cinteropDependencies()
|
dependencies["commonTest"].cinteropDependencies()
|
||||||
.assertMatches(binaryCoordinates(Regex("a:dep.*\\(linux_arm64, linux_x64\\)")))
|
.assertMatches(binaryCoordinates(Regex("a:dep.*\\(ios_x64, linux_arm64, linux_x64\\)")))
|
||||||
dependencies["linuxX64Main"].cinteropDependencies().assertMatches(binaryCoordinates(Regex("a:dep.*linux_x64")))
|
dependencies["linuxX64Main"].cinteropDependencies().assertMatches(binaryCoordinates(Regex("a:dep.*linux_x64")))
|
||||||
dependencies["linuxArm64Main"].cinteropDependencies().assertMatches(binaryCoordinates(Regex("a:dep.*linux_arm64")))
|
dependencies["linuxArm64Main"].cinteropDependencies().assertMatches(binaryCoordinates(Regex("a:dep.*linux_arm64")))
|
||||||
dependencies["linuxX64Test"].cinteropDependencies().assertMatches(binaryCoordinates(Regex("a:dep.*linux_x64")))
|
dependencies["linuxX64Test"].cinteropDependencies().assertMatches(binaryCoordinates(Regex("a:dep.*linux_x64")))
|
||||||
dependencies["linuxArm64Test"].cinteropDependencies().assertMatches(binaryCoordinates(Regex("a:dep.*linux_arm64")))
|
dependencies["linuxArm64Test"].cinteropDependencies().assertMatches(binaryCoordinates(Regex("a:dep.*linux_arm64")))
|
||||||
|
|
||||||
|
val iosX64MainDependencies = dependencies["iosX64Main"].cinteropDependencies()
|
||||||
|
if (HostManager.hostIsMac) {
|
||||||
|
iosX64MainDependencies.assertMatches(binaryCoordinates(Regex("a:dep.*ios_x64")))
|
||||||
|
} else {
|
||||||
|
if (iosX64MainDependencies.isNotEmpty())
|
||||||
|
fail("Expected no dependencies (resolved & unresolved) for iosX64Cinterops on non-MacOS Host")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveIdeDependencies("client-for-binary-dep") { dependencies ->
|
resolveIdeDependencies("client-for-binary-dep") { dependencies ->
|
||||||
|
|||||||
+1
@@ -6,6 +6,7 @@ plugins {
|
|||||||
kotlin {
|
kotlin {
|
||||||
linuxX64().compilations.getByName("main").cinterops.create("dep")
|
linuxX64().compilations.getByName("main").cinterops.create("dep")
|
||||||
linuxArm64().compilations.getByName("main").cinterops.create("dep")
|
linuxArm64().compilations.getByName("main").cinterops.create("dep")
|
||||||
|
iosX64().compilations.getByName("main").cinterops.create("dep")
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|||||||
+4
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinSharedNativeCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinSharedNativeCompilation
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.enabledOnCurrentHost
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||||
import org.jetbrains.kotlin.gradle.tasks.CInteropProcess
|
import org.jetbrains.kotlin.gradle.tasks.CInteropProcess
|
||||||
@@ -76,6 +77,9 @@ internal fun Project.getPlatformCinteropDependenciesOrEmpty(
|
|||||||
/* Participating in multiple compilations? -> can't propagate -> should be commonized */
|
/* Participating in multiple compilations? -> can't propagate -> should be commonized */
|
||||||
val compilation = compilations.singleOrNull() as? KotlinNativeCompilation ?: return@files emptySet<File>()
|
val compilation = compilations.singleOrNull() as? KotlinNativeCompilation ?: return@files emptySet<File>()
|
||||||
|
|
||||||
|
/* Apple-specific cinterops can't be produced on non-MacOs machines, so just return an empty dependencies collection */
|
||||||
|
if (!compilation.target.konanTarget.enabledOnCurrentHost) return@files emptySet<File>()
|
||||||
|
|
||||||
(compilation.associatedCompilations + compilation)
|
(compilation.associatedCompilations + compilation)
|
||||||
.filterIsInstance<KotlinNativeCompilation>()
|
.filterIsInstance<KotlinNativeCompilation>()
|
||||||
.filter(compilationFilter)
|
.filter(compilationFilter)
|
||||||
|
|||||||
Reference in New Issue
Block a user