mirror of
https://github.com/apple/pkl.git
synced 2026-03-30 22:02:10 +02:00
Implement SPICE-0009 External Readers (#660)
This adds a new feature, which allows Pkl to read resources and modules from external processes. Follows the design laid out in SPICE-0009. Also, this moves most of the messaging API into pkl-core
This commit is contained in:
@@ -31,12 +31,12 @@ import org.pkl.commons.writeString
|
||||
import org.pkl.core.EvaluatorBuilder
|
||||
import org.pkl.core.ModuleSource
|
||||
import org.pkl.core.PklException
|
||||
import org.pkl.core.module.ModuleKeyFactories
|
||||
import org.pkl.core.module.ModulePathResolver
|
||||
import org.pkl.core.runtime.ModuleResolver
|
||||
import org.pkl.core.runtime.VmException
|
||||
import org.pkl.core.runtime.VmUtils
|
||||
import org.pkl.core.util.IoUtils
|
||||
import org.pkl.core.util.Readers
|
||||
|
||||
private data class OutputFile(val pathSpec: String, val moduleUri: URI)
|
||||
|
||||
@@ -100,7 +100,8 @@ constructor(
|
||||
writeOutput(builder)
|
||||
}
|
||||
} finally {
|
||||
ModuleKeyFactories.closeQuietly(builder.moduleKeyFactories)
|
||||
Readers.closeQuietly(builder.moduleKeyFactories)
|
||||
Readers.closeQuietly(builder.resourceReaders)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.pkl.commons.cli.CliCommand
|
||||
import org.pkl.commons.createParentDirectories
|
||||
import org.pkl.commons.writeString
|
||||
import org.pkl.core.ModuleSource
|
||||
import org.pkl.core.module.ModuleKeyFactories
|
||||
import org.pkl.core.util.Readers
|
||||
|
||||
class CliImportAnalyzer
|
||||
@JvmOverloads
|
||||
@@ -73,7 +73,8 @@ constructor(
|
||||
.build()
|
||||
.use { it.evaluateOutputText(sourceModule) }
|
||||
} finally {
|
||||
ModuleKeyFactories.closeQuietly(builder.moduleKeyFactories)
|
||||
Readers.closeQuietly(builder.moduleKeyFactories)
|
||||
Readers.closeQuietly(builder.resourceReaders)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,13 @@ package org.pkl.cli
|
||||
import org.pkl.commons.cli.CliBaseOptions
|
||||
import org.pkl.commons.cli.CliCommand
|
||||
import org.pkl.commons.cli.CliException
|
||||
import org.pkl.server.MessageTransports
|
||||
import org.pkl.server.ProtocolException
|
||||
import org.pkl.core.messaging.ProtocolException
|
||||
import org.pkl.server.Server
|
||||
|
||||
class CliServer(options: CliBaseOptions) : CliCommand(options) {
|
||||
override fun doRun() =
|
||||
try {
|
||||
val server = Server(MessageTransports.stream(System.`in`, System.out))
|
||||
val server = Server.stream(System.`in`, System.out)
|
||||
server.use { it.start() }
|
||||
} catch (e: ProtocolException) {
|
||||
throw CliException(e.message!!)
|
||||
|
||||
@@ -19,10 +19,10 @@ import java.io.Writer
|
||||
import org.pkl.commons.cli.*
|
||||
import org.pkl.core.EvaluatorBuilder
|
||||
import org.pkl.core.ModuleSource.uri
|
||||
import org.pkl.core.module.ModuleKeyFactories
|
||||
import org.pkl.core.stdlib.test.report.JUnitReport
|
||||
import org.pkl.core.stdlib.test.report.SimpleReport
|
||||
import org.pkl.core.util.ErrorMessages
|
||||
import org.pkl.core.util.Readers
|
||||
|
||||
class CliTestRunner
|
||||
@JvmOverloads
|
||||
@@ -38,7 +38,8 @@ constructor(
|
||||
try {
|
||||
evalTest(builder)
|
||||
} finally {
|
||||
ModuleKeyFactories.closeQuietly(builder.moduleKeyFactories)
|
||||
Readers.closeQuietly(builder.moduleKeyFactories)
|
||||
Readers.closeQuietly(builder.resourceReaders)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user