[K/N] Move framework interface generation to "Produce Output" phase

It allows to invoke interface generation even if we don't compile a
binary.
This commit is contained in:
Sergey Bogolepov
2022-07-20 11:00:02 +03:00
committed by Space
parent 78da5907c8
commit 7055893605
2 changed files with 13 additions and 8 deletions
@@ -181,7 +181,9 @@ internal fun produceOutput(context: Context) {
val config = context.config.configuration
val tempFiles = context.config.tempFiles
val produce = config.get(KonanConfigKeys.PRODUCE)
if (produce == CompilerOutputKind.FRAMEWORK) {
context.objCExport.produceFrameworkInterface()
}
when (produce) {
CompilerOutputKind.STATIC,
CompilerOutputKind.DYNAMIC,
@@ -47,8 +47,6 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
private fun produceInterface(): ObjCExportedInterface? {
if (!target.family.isAppleFamily) return null
if (!context.config.produce.isFinalBinary) return null
// TODO: emit RTTI to the same modules as classes belong to.
// Not possible yet, since ObjCExport translates the entire "world" API at once
// and can't do this per-module, e.g. due to global name conflict resolution.
@@ -98,16 +96,21 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
val objCCodeGenerator = ObjCExportCodeGenerator(codegen, namer, mapper)
if (exportedInterface != null) {
produceFrameworkSpecific(exportedInterface.headerLines)
exportedInterface.generateWorkaroundForSwiftSR10177()
}
exportedInterface?.generateWorkaroundForSwiftSR10177()
objCCodeGenerator.generate(codeSpec)
objCCodeGenerator.dispose()
}
/**
* Populate framework directory with headers, module and info.plist.
*/
fun produceFrameworkInterface() {
if (exportedInterface != null) {
produceFrameworkSpecific(exportedInterface.headerLines)
}
}
private fun produceFrameworkSpecific(headerLines: List<String>) {
val framework = File(context.config.outputFile)
val frameworkContents = when(target.family) {