Native: add included forward declarations into cinterop klib manifest

This allows the compiler to limit imports from "magic" packages like
cnames.structs to forward declarations actually present in dependent
cinterop klibs.

The manifest already had `exportForwardDeclarations` field, but
- it didn't include Objective-C forward declarations (@class, @protocol)
- it has a slightly different meaning (the export list enables importing
  the listed declarations through the interop package of the library,
  while the include list shouldn't do that), so we better avoid mixing
  them.
This commit is contained in:
Svyatoslav Scherbina
2023-01-24 13:05:29 +01:00
committed by Space Team
parent 86a29a7b07
commit 322a8a443b
5 changed files with 40 additions and 5 deletions
@@ -20,6 +20,7 @@ const val KLIB_PROPERTY_CONTAINS_ERROR_CODE = "contains_error_code"
// Native-specific:
const val KLIB_PROPERTY_INTEROP = "interop"
const val KLIB_PROPERTY_EXPORT_FORWARD_DECLARATIONS = "exportForwardDeclarations"
const val KLIB_PROPERTY_INCLUDED_FORWARD_DECLARATIONS = "includedForwardDeclarations"
/**
* Copy-pasted to `kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt`
@@ -104,6 +105,9 @@ val KotlinLibrary.packageFqName: String?
val KotlinLibrary.exportForwardDeclarations: List<String>
get() = manifestProperties.propertyList(KLIB_PROPERTY_EXPORT_FORWARD_DECLARATIONS, escapeInQuotes = true)
val KotlinLibrary.includedForwardDeclarations: List<String>
get() = manifestProperties.propertyList(KLIB_PROPERTY_INCLUDED_FORWARD_DECLARATIONS, escapeInQuotes = true)
val BaseKotlinLibrary.nativeTargets: List<String>
get() = manifestProperties.propertyList(KLIB_PROPERTY_NATIVE_TARGETS)