[FIR] Properly setup dependant module data for metadata compilation
^KT-57377 Fixed
This commit is contained in:
committed by
Space Team
parent
b2e03035a9
commit
b9c61bbc60
@@ -65,7 +65,7 @@ fun <F> prepareJvmSessions(
|
||||
|
||||
return prepareSessions(
|
||||
files, configuration, rootModuleName, JvmPlatforms.unspecifiedJvmPlatform,
|
||||
JvmPlatformAnalyzerServices, libraryList, isCommonSource, fileBelongsToModule,
|
||||
JvmPlatformAnalyzerServices, metadataCompilationMode = false, libraryList, isCommonSource, fileBelongsToModule,
|
||||
createLibrarySession = { sessionProvider ->
|
||||
FirJvmSessionFactory.createLibrarySession(
|
||||
rootModuleName,
|
||||
@@ -116,7 +116,7 @@ fun <F> prepareJsSessions(
|
||||
): List<SessionWithSources<F>> {
|
||||
return prepareSessions(
|
||||
files, configuration, rootModuleName, JsPlatforms.defaultJsPlatform, JsPlatformAnalyzerServices,
|
||||
libraryList, isCommonSource, fileBelongsToModule,
|
||||
metadataCompilationMode = false, libraryList, isCommonSource, fileBelongsToModule,
|
||||
createLibrarySession = { sessionProvider ->
|
||||
FirJsSessionFactory.createLibrarySession(
|
||||
rootModuleName,
|
||||
@@ -161,7 +161,7 @@ fun <F> prepareNativeSessions(
|
||||
): List<SessionWithSources<F>> {
|
||||
return prepareSessions(
|
||||
files, configuration, rootModuleName, NativePlatforms.unspecifiedNativePlatform, NativePlatformAnalyzerServices,
|
||||
libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider ->
|
||||
metadataCompilationMode = false, libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider ->
|
||||
FirNativeSessionFactory.createLibrarySession(
|
||||
rootModuleName,
|
||||
resolvedLibraries,
|
||||
@@ -186,10 +186,8 @@ fun <F> prepareNativeSessions(
|
||||
|
||||
/**
|
||||
* Creates library session and sources session for Common platform (for metadata compilation)
|
||||
* Number of created session depends on mode of MPP:
|
||||
* - disabled
|
||||
* - legacy (one platform and one common module)
|
||||
* - HMPP (multiple number of modules)
|
||||
* Number of created sessions is always one, in this mode modules are compiled against compiled
|
||||
* metadata of dependent modules
|
||||
*/
|
||||
fun <F> prepareCommonSessions(
|
||||
files: List<F>,
|
||||
@@ -206,7 +204,7 @@ fun <F> prepareCommonSessions(
|
||||
): List<SessionWithSources<F>> {
|
||||
return prepareSessions(
|
||||
files, configuration, rootModuleName, CommonPlatforms.defaultCommonPlatform, CommonPlatformAnalyzerServices,
|
||||
libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider ->
|
||||
metadataCompilationMode = true, libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider ->
|
||||
FirCommonSessionFactory.createLibrarySession(
|
||||
rootModuleName,
|
||||
sessionProvider,
|
||||
@@ -246,6 +244,7 @@ private inline fun <F> prepareSessions(
|
||||
rootModuleName: Name,
|
||||
targetPlatform: TargetPlatform,
|
||||
analyzerServices: PlatformDependentAnalyzerServices,
|
||||
metadataCompilationMode: Boolean,
|
||||
libraryList: DependencyListForCliModule,
|
||||
isCommonSource: (F) -> Boolean,
|
||||
fileBelongsToModule: (F, String) -> Boolean,
|
||||
@@ -267,8 +266,8 @@ private inline fun <F> prepareSessions(
|
||||
}
|
||||
|
||||
return when {
|
||||
!isMppEnabled -> listOf(
|
||||
createSessionForNonMppProject(
|
||||
metadataCompilationMode || !isMppEnabled -> listOf(
|
||||
createSingleSession(
|
||||
files, rootModuleName, libraryList, targetPlatform, analyzerServices,
|
||||
sessionProvider, sessionConfigurator, createSourceSession
|
||||
)
|
||||
@@ -286,7 +285,7 @@ private inline fun <F> prepareSessions(
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <F> createSessionForNonMppProject(
|
||||
private inline fun <F> createSingleSession(
|
||||
files: List<F>,
|
||||
rootModuleName: Name,
|
||||
libraryList: DependencyListForCliModule,
|
||||
@@ -299,7 +298,7 @@ private inline fun <F> createSessionForNonMppProject(
|
||||
val platformModuleData = FirModuleDataImpl(
|
||||
rootModuleName,
|
||||
libraryList.regularDependencies,
|
||||
dependsOnDependencies = emptyList(),
|
||||
libraryList.dependsOnDependencies,
|
||||
libraryList.friendsDependencies,
|
||||
targetPlatform,
|
||||
analyzerServices
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.createContextForIncrementa
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.createIncrementalCompilationScope
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.toAbstractProjectEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
|
||||
import org.jetbrains.kotlin.cli.jvm.config.K2MetadataConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmModularRoots
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
@@ -66,9 +67,11 @@ internal class FirMetadataSerializer(
|
||||
CommonPlatformAnalyzerServices
|
||||
)
|
||||
val libraryList = DependencyListForCliModule.build(binaryModuleData) {
|
||||
dependencies(configuration.jvmClasspathRoots.map { it.toPath() })
|
||||
val refinedPaths = configuration.get(K2MetadataConfigurationKeys.REFINES_PATHS)?.map { File(it) }.orEmpty()
|
||||
dependencies(configuration.jvmClasspathRoots.filter { it !in refinedPaths }.map { it.toPath() })
|
||||
dependencies(configuration.jvmModularRoots.map { it.toPath() })
|
||||
friendDependencies(configuration[JVMConfigurationKeys.FRIEND_PATHS] ?: emptyList())
|
||||
friendDependencies(configuration[K2MetadataConfigurationKeys.FRIEND_PATHS] ?: emptyList())
|
||||
dependsOnDependencies(refinedPaths.map { it.toPath() })
|
||||
}
|
||||
|
||||
val diagnosticsReporter = DiagnosticReporterFactory.createPendingReporter()
|
||||
@@ -193,4 +196,4 @@ internal class FirMetadataSerializer(
|
||||
|
||||
buildKotlinMetadataLibrary(configuration, serializedMetadata, destDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ class CustomK2Tests : KGPBaseTest() {
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("HMPP compilation without JS target. KT-57376, KT-57635")
|
||||
@DisplayName("HMPP compilation without JS target. KT-57376, KT-57377, KT-57635")
|
||||
fun testHmppCompilationWithoutJsTarget(gradleVersion: GradleVersion) {
|
||||
with(project("k2-mpp-without-js", gradleVersion)) {
|
||||
val taskToExecute = ":compileIntermediateMainKotlinMetadata"
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// ISSUE: KT-57377
|
||||
package kt57377
|
||||
|
||||
internal class StringBox(val value: String)
|
||||
internal fun createBox(value: String): StringBox = StringBox(value)
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// ISSUE: KT-57377
|
||||
package kt57377
|
||||
|
||||
internal val testInternal1 = StringBox("foo")
|
||||
internal val testInternal2 = createBox("foo")
|
||||
Reference in New Issue
Block a user