Implement -Xframework-import-header compiler flag (#2952)
To be used to add imports to framework header to workaround missing imports issues.
This commit is contained in:
committed by
GitHub
parent
f508ac3a37
commit
c3e6ec731d
@@ -194,6 +194,7 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
put(FRIEND_MODULES, arguments.friendModules!!.split(File.pathSeparator).filterNot(String::isEmpty))
|
||||
|
||||
put(EXPORTED_LIBRARIES, selectExportedLibraries(configuration, arguments, outputKind))
|
||||
put(FRAMEWORK_IMPORT_HEADERS, arguments.frameworkImportHeaders.toNonNullList())
|
||||
|
||||
put(BITCODE_EMBEDDING_MODE, selectBitcodeEmbeddingMode(this, arguments, outputKind))
|
||||
put(DEBUG_INFO_VERSION, arguments.debugInfoFormatVersion.toInt())
|
||||
|
||||
@@ -119,6 +119,13 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var exportedLibraries: Array<String>? = null
|
||||
|
||||
@Argument(
|
||||
value = "-Xframework-import-header",
|
||||
valueDescription = "<header>",
|
||||
description = "Add additional header import to framework header"
|
||||
)
|
||||
var frameworkImportHeaders: Array<String>? = null
|
||||
|
||||
@Argument(value = "-Xprint-bitcode", deprecatedName = "--print_bitcode", description = "Print llvm bitcode")
|
||||
var printBitCode: Boolean = false
|
||||
|
||||
|
||||
+2
@@ -30,6 +30,8 @@ class KonanConfigKeys {
|
||||
= CompilerConfigurationKey.create("fully qualified main() name")
|
||||
val EXPORTED_LIBRARIES: CompilerConfigurationKey<List<String>>
|
||||
= CompilerConfigurationKey.create<List<String>>("libraries included into produced framework API")
|
||||
val FRAMEWORK_IMPORT_HEADERS: CompilerConfigurationKey<List<String>>
|
||||
= CompilerConfigurationKey.create<List<String>>("headers imported to framework header")
|
||||
val FRIEND_MODULES: CompilerConfigurationKey<List<String>>
|
||||
= CompilerConfigurationKey.create<List<String>>("friend module paths")
|
||||
val GENERATE_TEST_RUNNER: CompilerConfigurationKey<TestRunnerKind>
|
||||
|
||||
+5
@@ -715,6 +715,9 @@ abstract class ObjCExportHeaderGenerator internal constructor(
|
||||
add("#import <Foundation/NSSet.h>")
|
||||
add("#import <Foundation/NSString.h>")
|
||||
add("#import <Foundation/NSValue.h>")
|
||||
getAdditionalImports().forEach {
|
||||
add("#import <$it>")
|
||||
}
|
||||
add("")
|
||||
|
||||
if (classForwardDeclarations.isNotEmpty()) {
|
||||
@@ -747,6 +750,8 @@ abstract class ObjCExportHeaderGenerator internal constructor(
|
||||
|
||||
protected abstract fun reportWarning(method: FunctionDescriptor, text: String)
|
||||
|
||||
protected open fun getAdditionalImports(): List<String> = emptyList()
|
||||
|
||||
|
||||
fun translateModule(): List<Stub<*>> {
|
||||
// TODO: make the translation order stable
|
||||
|
||||
+4
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.Context
|
||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys
|
||||
import org.jetbrains.kotlin.backend.konan.reportCompilationWarning
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageUtil
|
||||
@@ -36,4 +37,7 @@ internal class ObjCExportHeaderGeneratorImpl(
|
||||
|
||||
context.messageCollector.report(CompilerMessageSeverity.WARNING, text, location)
|
||||
}
|
||||
|
||||
override fun getAdditionalImports(): List<String> =
|
||||
context.config.configuration.getNotNull(KonanConfigKeys.FRAMEWORK_IMPORT_HEADERS)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user