[K/N] Enable dynamic and static output for dynamic driver
This commit is contained in:
committed by
Space Team
parent
2e5981eb94
commit
7706ad8cb3
+15
-2
@@ -26,6 +26,8 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
|||||||
CompilerOutputKind.DYNAMIC_CACHE,
|
CompilerOutputKind.DYNAMIC_CACHE,
|
||||||
CompilerOutputKind.STATIC_CACHE,
|
CompilerOutputKind.STATIC_CACHE,
|
||||||
CompilerOutputKind.FRAMEWORK,
|
CompilerOutputKind.FRAMEWORK,
|
||||||
|
CompilerOutputKind.DYNAMIC,
|
||||||
|
CompilerOutputKind.STATIC,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,8 +37,8 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
|||||||
PhaseEngine.startTopLevel(config) { engine ->
|
PhaseEngine.startTopLevel(config) { engine ->
|
||||||
when (config.produce) {
|
when (config.produce) {
|
||||||
CompilerOutputKind.PROGRAM -> produceBinary(engine, config, environment)
|
CompilerOutputKind.PROGRAM -> produceBinary(engine, config, environment)
|
||||||
CompilerOutputKind.DYNAMIC -> error("Dynamic compiler driver does not support `dynamic` output yet.")
|
CompilerOutputKind.DYNAMIC -> produceCLibrary(engine, config, environment)
|
||||||
CompilerOutputKind.STATIC -> error("Dynamic compiler driver does not support `static` output yet.")
|
CompilerOutputKind.STATIC -> produceCLibrary(engine, config, environment)
|
||||||
CompilerOutputKind.FRAMEWORK -> produceObjCFramework(engine, config, environment)
|
CompilerOutputKind.FRAMEWORK -> produceObjCFramework(engine, config, environment)
|
||||||
CompilerOutputKind.LIBRARY -> produceKlib(engine, config, environment)
|
CompilerOutputKind.LIBRARY -> produceKlib(engine, config, environment)
|
||||||
CompilerOutputKind.BITCODE -> error("Dynamic compiler driver does not support `bitcode` output yet.")
|
CompilerOutputKind.BITCODE -> error("Dynamic compiler driver does not support `bitcode` output yet.")
|
||||||
@@ -72,6 +74,17 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
|||||||
engine.runBackend(backendContext)
|
engine.runBackend(backendContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun produceCLibrary(engine: PhaseEngine<PhaseContext>, config: KonanConfig, environment: KotlinCoreEnvironment) {
|
||||||
|
val frontendOutput = engine.runFrontend(config, environment) ?: return
|
||||||
|
val (psiToIrOutput, cAdapterElements) = engine.runPsiToIr(frontendOutput, isProducingLibrary = false) {
|
||||||
|
it.runPhase(BuildCExports, frontendOutput)
|
||||||
|
}
|
||||||
|
val backendContext = createBackendContext(config, frontendOutput, psiToIrOutput) {
|
||||||
|
it.cAdapterExportedElements = cAdapterElements
|
||||||
|
}
|
||||||
|
engine.runBackend(backendContext)
|
||||||
|
}
|
||||||
|
|
||||||
private fun produceKlib(engine: PhaseEngine<PhaseContext>, config: KonanConfig, environment: KotlinCoreEnvironment) {
|
private fun produceKlib(engine: PhaseEngine<PhaseContext>, config: KonanConfig, environment: KotlinCoreEnvironment) {
|
||||||
val frontendOutput = engine.runFrontend(config, environment) ?: return
|
val frontendOutput = engine.runFrontend(config, environment) ?: return
|
||||||
val psiToIrOutput = if (config.metadataKlib) {
|
val psiToIrOutput = if (config.metadataKlib) {
|
||||||
|
|||||||
Reference in New Issue
Block a user