[K/N] avoid overwriting header when output paths are equal
^KT-65442
This commit is contained in:
+1
-1
@@ -288,7 +288,7 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
|||||||
|
|
||||||
internal val metadataKlib get() = configuration.getBoolean(CommonConfigurationKeys.METADATA_KLIB)
|
internal val metadataKlib get() = configuration.getBoolean(CommonConfigurationKeys.METADATA_KLIB)
|
||||||
|
|
||||||
internal val headerKlibPath get() = configuration.get(KonanConfigKeys.HEADER_KLIB)
|
internal val headerKlibPath get() = configuration.get(KonanConfigKeys.HEADER_KLIB)?.removeSuffixIfPresent(".klib")
|
||||||
|
|
||||||
internal val produceStaticFramework get() = configuration.getBoolean(KonanConfigKeys.STATIC_FRAMEWORK)
|
internal val produceStaticFramework get() = configuration.getBoolean(KonanConfigKeys.STATIC_FRAMEWORK)
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -119,6 +119,9 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
|||||||
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)
|
engine.writeKlib(headerKlib, headerKlibPath)
|
||||||
|
// 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.
|
||||||
|
if (File(config.outputPath).canonicalPath == File(headerKlibPath).canonicalPath) return null
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.runK2SpecialBackendChecks(fir2IrOutput)
|
engine.runK2SpecialBackendChecks(fir2IrOutput)
|
||||||
@@ -137,9 +140,14 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
|||||||
} else {
|
} else {
|
||||||
engine.runPsiToIr(frontendOutput, isProducingLibrary = true) as PsiToIrOutput.ForKlib
|
engine.runPsiToIr(frontendOutput, isProducingLibrary = true) as PsiToIrOutput.ForKlib
|
||||||
}
|
}
|
||||||
if (!config.headerKlibPath.isNullOrEmpty()) {
|
|
||||||
|
val headerKlibPath = config.headerKlibPath
|
||||||
|
if (!headerKlibPath.isNullOrEmpty()) {
|
||||||
val headerKlib = engine.runSerializer(frontendOutput.moduleDescriptor, psiToIrOutput, produceHeaderKlib = true)
|
val headerKlib = engine.runSerializer(frontendOutput.moduleDescriptor, psiToIrOutput, produceHeaderKlib = true)
|
||||||
engine.writeKlib(headerKlib, config.headerKlibPath)
|
engine.writeKlib(headerKlib, headerKlibPath)
|
||||||
|
// 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.
|
||||||
|
if (File(config.outputPath).canonicalPath == File(headerKlibPath).canonicalPath) return null
|
||||||
}
|
}
|
||||||
return engine.runSerializer(frontendOutput.moduleDescriptor, psiToIrOutput)
|
return engine.runSerializer(frontendOutput.moduleDescriptor, psiToIrOutput)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ internal val WriteKlibPhase = createSimpleNamedCompilerPhase<PhaseContext, KlibW
|
|||||||
) { context, input ->
|
) { context, input ->
|
||||||
val config = context.config
|
val config = context.config
|
||||||
val configuration = config.configuration
|
val configuration = config.configuration
|
||||||
val outputFiles = OutputFiles(input.customOutputPath?.removeSuffixIfPresent(".klib")
|
val outputFiles = OutputFiles(input.customOutputPath
|
||||||
?: config.outputPath, config.target, config.produce)
|
?: config.outputPath, config.target, config.produce)
|
||||||
val nopack = configuration.getBoolean(KonanConfigKeys.NOPACK)
|
val nopack = configuration.getBoolean(KonanConfigKeys.NOPACK)
|
||||||
val output = outputFiles.klibOutputFileName(!nopack)
|
val output = outputFiles.klibOutputFileName(!nopack)
|
||||||
|
|||||||
Reference in New Issue
Block a user