minor: replace Pair with data class in daemon client connectAndLease call
backport from 1.0.7
This commit is contained in:
+5
-4
@@ -50,6 +50,7 @@ object KotlinCompilerClient {
|
|||||||
|
|
||||||
val verboseReporting = System.getProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY) != null
|
val verboseReporting = System.getProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY) != null
|
||||||
|
|
||||||
|
data class ServiceWithSession(val service: CompileService, val sessionId: Int)
|
||||||
|
|
||||||
fun connectToCompileService(compilerId: CompilerId,
|
fun connectToCompileService(compilerId: CompilerId,
|
||||||
daemonJVMOptions: DaemonJVMOptions,
|
daemonJVMOptions: DaemonJVMOptions,
|
||||||
@@ -81,7 +82,7 @@ object KotlinCompilerClient {
|
|||||||
reportingTargets,
|
reportingTargets,
|
||||||
autostart,
|
autostart,
|
||||||
leaseSession = false,
|
leaseSession = false,
|
||||||
sessionAliveFlagFile = null)?.first
|
sessionAliveFlagFile = null)?.service
|
||||||
|
|
||||||
|
|
||||||
fun connectAndLease(compilerId: CompilerId,
|
fun connectAndLease(compilerId: CompilerId,
|
||||||
@@ -92,19 +93,19 @@ object KotlinCompilerClient {
|
|||||||
autostart: Boolean,
|
autostart: Boolean,
|
||||||
leaseSession: Boolean,
|
leaseSession: Boolean,
|
||||||
sessionAliveFlagFile: File? = null
|
sessionAliveFlagFile: File? = null
|
||||||
): Pair<CompileService, Int>? = connectLoop(reportingTargets) {
|
): ServiceWithSession? = connectLoop(reportingTargets) {
|
||||||
val (service, newJVMOptions) = tryFindSuitableDaemonOrNewOpts(File(daemonOptions.runFilesPath), compilerId, daemonJVMOptions, { cat, msg -> reportingTargets.report(cat, msg) })
|
val (service, newJVMOptions) = tryFindSuitableDaemonOrNewOpts(File(daemonOptions.runFilesPath), compilerId, daemonJVMOptions, { cat, msg -> reportingTargets.report(cat, msg) })
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
// the newJVMOptions could be checked here for additional parameters, if needed
|
// the newJVMOptions could be checked here for additional parameters, if needed
|
||||||
service.registerClient(clientAliveFlagFile.absolutePath)
|
service.registerClient(clientAliveFlagFile.absolutePath)
|
||||||
reportingTargets.report(DaemonReportCategory.DEBUG, "connected to the daemon")
|
reportingTargets.report(DaemonReportCategory.DEBUG, "connected to the daemon")
|
||||||
if (!leaseSession) service to CompileService.NO_SESSION
|
if (!leaseSession) ServiceWithSession(service, CompileService.NO_SESSION)
|
||||||
else {
|
else {
|
||||||
val sessionId = service.leaseCompileSession(sessionAliveFlagFile?.absolutePath)
|
val sessionId = service.leaseCompileSession(sessionAliveFlagFile?.absolutePath)
|
||||||
if (sessionId is CompileService.CallResult.Dying)
|
if (sessionId is CompileService.CallResult.Dying)
|
||||||
null
|
null
|
||||||
else
|
else
|
||||||
service to sessionId.get()
|
ServiceWithSession(service, sessionId.get())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reportingTargets.report(DaemonReportCategory.DEBUG, "no suitable daemon found")
|
reportingTargets.report(DaemonReportCategory.DEBUG, "no suitable daemon found")
|
||||||
|
|||||||
@@ -425,13 +425,13 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
val daemonWithSession = KotlinCompilerClient.connectAndLease(compilerId, flagFile, daemonJVMOptions, daemonOptions,
|
val daemonWithSession = KotlinCompilerClient.connectAndLease(compilerId, flagFile, daemonJVMOptions, daemonOptions,
|
||||||
DaemonReportingTargets(out = System.err), autostart = true,
|
DaemonReportingTargets(out = System.err), autostart = true,
|
||||||
leaseSession = true, sessionAliveFlagFile = sessionFlagFile)
|
leaseSession = true, sessionAliveFlagFile = sessionFlagFile)
|
||||||
if (daemonWithSession?.first == null) {
|
if (daemonWithSession?.service == null) {
|
||||||
fail("failed to connect daemon:\n${logFile.readLines().joinToString("\n")}\n------")
|
fail("failed to connect daemon:\n${logFile.readLines().joinToString("\n")}\n------")
|
||||||
}
|
}
|
||||||
val jar = tmpdir.absolutePath + File.separator + "hello.$threadNo.jar"
|
val jar = tmpdir.absolutePath + File.separator + "hello.$threadNo.jar"
|
||||||
val res = KotlinCompilerClient.compile(
|
val res = KotlinCompilerClient.compile(
|
||||||
daemonWithSession!!.first,
|
daemonWithSession!!.service,
|
||||||
daemonWithSession.second,
|
daemonWithSession.sessionId,
|
||||||
CompileService.TargetPlatform.JVM,
|
CompileService.TargetPlatform.JVM,
|
||||||
arrayOf(File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar),
|
arrayOf(File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar),
|
||||||
outStreams[threadNo])
|
outStreams[threadNo])
|
||||||
|
|||||||
+2
-2
@@ -191,7 +191,7 @@ class SourceSectionsTest : TestCaseWithTmpdir() {
|
|||||||
messageCollector.clear()
|
messageCollector.clear()
|
||||||
val outputs = arrayListOf<OutputMessageUtil.Output>()
|
val outputs = arrayListOf<OutputMessageUtil.Output>()
|
||||||
|
|
||||||
val code = KotlinCompilerClient.compile(daemonWithSession!!.first, daemonWithSession.second, CompileService.TargetPlatform.JVM,
|
val code = KotlinCompilerClient.compile(daemonWithSession!!.service, daemonWithSession.sessionId, CompileService.TargetPlatform.JVM,
|
||||||
args, messageCollector,
|
args, messageCollector,
|
||||||
{ outFile, srcFiles -> outputs.add(OutputMessageUtil.Output(srcFiles, outFile)) },
|
{ outFile, srcFiles -> outputs.add(OutputMessageUtil.Output(srcFiles, outFile)) },
|
||||||
reportSeverity = ReportSeverity.DEBUG)
|
reportSeverity = ReportSeverity.DEBUG)
|
||||||
@@ -205,7 +205,7 @@ class SourceSectionsTest : TestCaseWithTmpdir() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
daemonWithSession!!.first.shutdown()
|
daemonWithSession!!.service.shutdown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user