[JS IR] Module descriptors depends on each other

This commit is contained in:
Ilya Goncharov
2023-01-06 18:41:42 +01:00
committed by Space Team
parent b42492cd4d
commit 7ae85ed68e
9 changed files with 52 additions and 24 deletions
@@ -84,12 +84,13 @@ class ClassicFrontend2IrConverter(
val sourceFiles = psiFiles.values.toList()
val icData = configuration.incrementalDataProvider?.getSerializedData(sourceFiles) ?: emptyList()
val expectDescriptorToSymbol = mutableMapOf<DeclarationDescriptor, IrSymbol>()
val (moduleFragment, pluginContext) = generateIrForKlibSerialization(
project,
sourceFiles,
configuration,
analysisResult,
sortDependencies(JsEnvironmentConfigurator.getAllRecursiveLibrariesFor(module, testServices)),
sortDependencies(JsEnvironmentConfigurator.getAllDependenciesMappingFor(module, testServices)),
icData,
expectDescriptorToSymbol,
IrFactoryImpl,
@@ -213,6 +213,16 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu
return dependencies.associateBy { testServices.jsLibraryProvider.getCompiledLibraryByDescriptor(it) }
}
fun getAllDependenciesMappingFor(module: TestModule, testServices: TestServices): Map<KotlinLibrary, List<KotlinLibrary>> {
val allRecursiveLibraries: Map<KotlinLibrary, ModuleDescriptor> = getAllRecursiveLibrariesFor(module, testServices)
val m2l = allRecursiveLibraries.map { it.value to it.key }.toMap()
return allRecursiveLibraries.keys.associateWith { m ->
val descriptor = allRecursiveLibraries[m] ?: error("No descriptor found for library ${m.libraryName}")
descriptor.allDependencyModules.filter { it != descriptor }.map { m2l.getValue(it) }
}
}
fun TestModule.hasFilesToRecompile(): Boolean {
return files.any { JsEnvironmentConfigurationDirectives.RECOMPILE in it.directives }
}