[Commonizer] Read exported forward declarations for every C-interop module
This commit is contained in:
@@ -18,7 +18,12 @@ interface ModulesProvider {
|
|||||||
open class ModuleInfo(
|
open class ModuleInfo(
|
||||||
val name: String,
|
val name: String,
|
||||||
val originalLocation: File,
|
val originalLocation: File,
|
||||||
val isCInterop: Boolean
|
val cInteropAttributes: CInteropModuleAttributes?
|
||||||
|
)
|
||||||
|
|
||||||
|
class CInteropModuleAttributes(
|
||||||
|
val mainPackage: String,
|
||||||
|
val exportedForwardDeclarations: Collection<String>
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+8
-3
@@ -17,8 +17,8 @@ internal class NativeDistributionModulesProvider(libraries: Collection<NativeLib
|
|||||||
name: String,
|
name: String,
|
||||||
originalLocation: File,
|
originalLocation: File,
|
||||||
val dependencies: Set<String>,
|
val dependencies: Set<String>,
|
||||||
isCInterop: Boolean
|
cInteropAttributes: ModulesProvider.CInteropModuleAttributes?
|
||||||
) : ModuleInfo(name, originalLocation, isCInterop)
|
) : ModuleInfo(name, originalLocation, cInteropAttributes)
|
||||||
|
|
||||||
private val libraryMap: Map<String, NativeLibrary>
|
private val libraryMap: Map<String, NativeLibrary>
|
||||||
private val moduleInfoMap: Map<String, NativeModuleInfo>
|
private val moduleInfoMap: Map<String, NativeModuleInfo>
|
||||||
@@ -34,8 +34,13 @@ internal class NativeDistributionModulesProvider(libraries: Collection<NativeLib
|
|||||||
val location = File(library.library.libraryFile.path)
|
val location = File(library.library.libraryFile.path)
|
||||||
val dependencies = manifestData.dependencies.toSet()
|
val dependencies = manifestData.dependencies.toSet()
|
||||||
|
|
||||||
|
val cInteropAttributes = if (manifestData.isInterop) {
|
||||||
|
val packageFqName = manifestData.packageFqName ?: error("Main package FQ name not specified for module $name")
|
||||||
|
ModulesProvider.CInteropModuleAttributes(packageFqName, manifestData.exportForwardDeclarations)
|
||||||
|
} else null
|
||||||
|
|
||||||
libraryMap.put(name, library)?.let { error("Duplicated libraries: $name") }
|
libraryMap.put(name, library)?.let { error("Duplicated libraries: $name") }
|
||||||
moduleInfoMap[name] = NativeModuleInfo(name, location, dependencies, manifestData.isInterop)
|
moduleInfoMap[name] = NativeModuleInfo(name, location, dependencies, cInteropAttributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.libraryMap = libraryMap
|
this.libraryMap = libraryMap
|
||||||
|
|||||||
+2
-2
@@ -47,7 +47,7 @@ internal class CirProvidedClassifiersByModules private constructor(
|
|||||||
var hasForwardDeclarations = false
|
var hasForwardDeclarations = false
|
||||||
|
|
||||||
modulesProvider.loadModuleInfos().forEach { moduleInfo ->
|
modulesProvider.loadModuleInfos().forEach { moduleInfo ->
|
||||||
if (moduleInfo.isCInterop) {
|
if (moduleInfo.cInteropAttributes != null) {
|
||||||
// this is a C-interop module
|
// this is a C-interop module
|
||||||
hasForwardDeclarations = true
|
hasForwardDeclarations = true
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ private fun readClass(
|
|||||||
typeParameterIndexOffset = typeParameterIndexOffset
|
typeParameterIndexOffset = typeParameterIndexOffset
|
||||||
)
|
)
|
||||||
val visibility = ProtoEnumFlags.visibility(Flags.VISIBILITY.get(classProto.flags))
|
val visibility = ProtoEnumFlags.visibility(Flags.VISIBILITY.get(classProto.flags))
|
||||||
val clazz = CirProvided.Class(typeParameters, visibility)
|
val clazz = CirProvided.RegularClass(typeParameters, visibility)
|
||||||
|
|
||||||
consumer(classId, clazz)
|
consumer(classId, clazz)
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ internal class MockModulesProvider private constructor(
|
|||||||
return SERIALIZER.serializeModule(module)
|
return SERIALIZER.serializeModule(module)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fakeModuleInfo(name: String) = ModuleInfo(name, File("/tmp/commonizer/mocks/$name"), false)
|
private fun fakeModuleInfo(name: String) = ModuleInfo(name, File("/tmp/commonizer/mocks/$name"), null)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmName("createByModuleNames")
|
@JvmName("createByModuleNames")
|
||||||
|
|||||||
Reference in New Issue
Block a user