Revert "[K/N] add flag to klib manifest for header klibs"

This reverts commit 59f0c0464b.
This commit is contained in:
Dmitriy Dolovov
2024-03-15 17:31:46 +01:00
parent de3ad3cd3a
commit a78d498e36
3 changed files with 5 additions and 17 deletions
@@ -31,7 +31,6 @@ const val KLIB_PROPERTY_CONTAINS_ERROR_CODE = "contains_error_code"
// Native-specific: // Native-specific:
const val KLIB_PROPERTY_INTEROP = "interop" const val KLIB_PROPERTY_INTEROP = "interop"
const val KLIB_PROPERTY_HEADER = "header"
const val KLIB_PROPERTY_EXPORT_FORWARD_DECLARATIONS = "exportForwardDeclarations" const val KLIB_PROPERTY_EXPORT_FORWARD_DECLARATIONS = "exportForwardDeclarations"
const val KLIB_PROPERTY_INCLUDED_FORWARD_DECLARATIONS = "includedForwardDeclarations" const val KLIB_PROPERTY_INCLUDED_FORWARD_DECLARATIONS = "includedForwardDeclarations"
const val KLIB_PROPERTY_IR_PROVIDER = "ir_provider" const val KLIB_PROPERTY_IR_PROVIDER = "ir_provider"
@@ -127,9 +126,6 @@ interface KotlinLibrary : BaseKotlinLibrary, MetadataLibrary, IrLibrary
val KotlinLibrary.isInterop: Boolean val KotlinLibrary.isInterop: Boolean
get() = manifestProperties.getProperty(KLIB_PROPERTY_INTEROP) == "true" get() = manifestProperties.getProperty(KLIB_PROPERTY_INTEROP) == "true"
val KotlinLibrary.isHeader: Boolean
get() = manifestProperties.getProperty(KLIB_PROPERTY_HEADER) == "true"
val KotlinLibrary.packageFqName: String? val KotlinLibrary.packageFqName: String?
get() = manifestProperties.getProperty(KLIB_PROPERTY_PACKAGE) get() = manifestProperties.getProperty(KLIB_PROPERTY_PACKAGE)
@@ -118,7 +118,7 @@ internal class DynamicCompilerDriver : CompilerDriver() {
val headerKlibPath = config.headerKlibPath val headerKlibPath = config.headerKlibPath
if (!headerKlibPath.isNullOrEmpty()) { if (!headerKlibPath.isNullOrEmpty()) {
val headerKlib = engine.runFir2IrSerializer(FirSerializerInput(fir2IrOutput, produceHeaderKlib = true)) val headerKlib = engine.runFir2IrSerializer(FirSerializerInput(fir2IrOutput, produceHeaderKlib = true))
engine.writeKlib(headerKlib, headerKlibPath, produceHeaderKlib = true) engine.writeKlib(headerKlib, headerKlibPath)
// Don't overwrite the header klib with the full klib and stop compilation here. // Don't overwrite the header klib with the full klib and stop compilation here.
// By providing the same path for both regular output and header klib we can skip emitting the full klib. // By providing the same path for both regular output and header klib we can skip emitting the full klib.
if (File(config.outputPath).canonicalPath == File(headerKlibPath).canonicalPath) return null if (File(config.outputPath).canonicalPath == File(headerKlibPath).canonicalPath) return null
@@ -144,7 +144,7 @@ internal class DynamicCompilerDriver : CompilerDriver() {
val headerKlibPath = config.headerKlibPath val headerKlibPath = config.headerKlibPath
if (!headerKlibPath.isNullOrEmpty()) { if (!headerKlibPath.isNullOrEmpty()) {
val headerKlib = engine.runSerializer(frontendOutput.moduleDescriptor, psiToIrOutput, produceHeaderKlib = true) val headerKlib = engine.runSerializer(frontendOutput.moduleDescriptor, psiToIrOutput, produceHeaderKlib = true)
engine.writeKlib(headerKlib, headerKlibPath, produceHeaderKlib = true) engine.writeKlib(headerKlib, headerKlibPath)
// Don't overwrite the header klib with the full klib and stop compilation here. // Don't overwrite the header klib with the full klib and stop compilation here.
// By providing the same path for both regular output and header klib we can skip emitting the full klib. // By providing the same path for both regular output and header klib we can skip emitting the full klib.
if (File(config.outputPath).canonicalPath == File(headerKlibPath).canonicalPath) return null if (File(config.outputPath).canonicalPath == File(headerKlibPath).canonicalPath) return null
@@ -12,17 +12,14 @@ import org.jetbrains.kotlin.backend.konan.driver.PhaseContext
import org.jetbrains.kotlin.backend.konan.driver.PhaseEngine import org.jetbrains.kotlin.backend.konan.driver.PhaseEngine
import org.jetbrains.kotlin.config.KotlinCompilerVersion import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.konan.library.impl.buildLibrary import org.jetbrains.kotlin.konan.library.impl.buildLibrary
import org.jetbrains.kotlin.library.KLIB_PROPERTY_HEADER
import org.jetbrains.kotlin.library.KotlinAbiVersion import org.jetbrains.kotlin.library.KotlinAbiVersion
import org.jetbrains.kotlin.library.KotlinLibraryVersioning import org.jetbrains.kotlin.library.KotlinLibraryVersioning
import org.jetbrains.kotlin.library.metadata.KlibMetadataVersion import org.jetbrains.kotlin.library.metadata.KlibMetadataVersion
import org.jetbrains.kotlin.util.removeSuffixIfPresent import org.jetbrains.kotlin.util.removeSuffixIfPresent
import java.util.*
internal data class KlibWriterInput( internal data class KlibWriterInput(
val serializerOutput: SerializerOutput, val serializerOutput: SerializerOutput,
val customOutputPath: String?, val customOutputPath: String?
val produceHeaderKlib: Boolean
) )
internal val WriteKlibPhase = createSimpleNamedCompilerPhase<PhaseContext, KlibWriterInput>( internal val WriteKlibPhase = createSimpleNamedCompilerPhase<PhaseContext, KlibWriterInput>(
"WriteKlib", "Write klib output", "WriteKlib", "Write klib output",
@@ -46,11 +43,7 @@ internal val WriteKlibPhase = createSimpleNamedCompilerPhase<PhaseContext, KlibW
metadataVersion = metadataVersion, metadataVersion = metadataVersion,
) )
val target = config.target val target = config.target
val manifestProperties = config.manifestProperties ?: Properties() val manifestProperties = config.manifestProperties
if (input.produceHeaderKlib) {
manifestProperties.setProperty(KLIB_PROPERTY_HEADER, "true")
}
if (!nopack) { if (!nopack) {
val suffix = outputFiles.produce.suffix(target) val suffix = outputFiles.produce.suffix(target)
@@ -87,7 +80,6 @@ internal val WriteKlibPhase = createSimpleNamedCompilerPhase<PhaseContext, KlibW
internal fun <T : PhaseContext> PhaseEngine<T>.writeKlib( internal fun <T : PhaseContext> PhaseEngine<T>.writeKlib(
serializationOutput: SerializerOutput, serializationOutput: SerializerOutput,
customOutputPath: String? = null, customOutputPath: String? = null,
produceHeaderKlib: Boolean = false,
) { ) {
this.runPhase(WriteKlibPhase, KlibWriterInput(serializationOutput, customOutputPath, produceHeaderKlib)) this.runPhase(WriteKlibPhase, KlibWriterInput(serializationOutput, customOutputPath))
} }