Improve JPS progress messages
#KT-9218 fixed
Original commit: 7f865565a6
This commit is contained in:
+19
-1
@@ -34,7 +34,14 @@ fun createTestingCompilerEnvironment(
|
||||
val paths = PathUtil.kotlinPathsForDistDirectory
|
||||
|
||||
val wrappedMessageCollector = MessageCollectorToOutputItemsCollectorAdapter(messageCollector, outputItemsCollector)
|
||||
return JpsCompilerEnvironment(paths, services, KotlinBuilder.classesToLoadByParent, wrappedMessageCollector, outputItemsCollector)
|
||||
return JpsCompilerEnvironment(
|
||||
paths,
|
||||
services,
|
||||
KotlinBuilder.classesToLoadByParent,
|
||||
wrappedMessageCollector,
|
||||
outputItemsCollector,
|
||||
MockProgressReporter
|
||||
)
|
||||
}
|
||||
|
||||
fun runJSCompiler(args: K2JSCompilerArguments, env: JpsCompilerEnvironment): ExitCode? {
|
||||
@@ -46,4 +53,15 @@ fun runJSCompiler(args: K2JSCompilerArguments, env: JpsCompilerEnvironment): Exi
|
||||
val reader = BufferedReader(StringReader(stream.toString()))
|
||||
CompilerOutputParser.parseCompilerMessagesFromReader(env.messageCollector, reader, env.outputItemsCollector)
|
||||
return exitCode as? ExitCode
|
||||
}
|
||||
|
||||
private object MockProgressReporter : ProgressReporter {
|
||||
override fun progress(message: String) {
|
||||
}
|
||||
|
||||
override fun compilationStarted() {
|
||||
}
|
||||
|
||||
override fun clearProgress() {
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ class JpsCompilerEnvironment(
|
||||
services: Services,
|
||||
val classesToLoadByParent: ClassCondition,
|
||||
messageCollector: MessageCollector,
|
||||
outputItemsCollector: OutputItemsCollectorImpl
|
||||
outputItemsCollector: OutputItemsCollectorImpl,
|
||||
val progressReporter: ProgressReporter
|
||||
) : CompilerEnvironment(services, messageCollector, outputItemsCollector) {
|
||||
override val outputItemsCollector: OutputItemsCollectorImpl
|
||||
get() = super.outputItemsCollector as OutputItemsCollectorImpl
|
||||
|
||||
@@ -174,7 +174,16 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
||||
requestedCompilationResults = emptyArray()
|
||||
)
|
||||
return doWithDaemon(environment) { sessionId, daemon ->
|
||||
daemon.compile(sessionId, withAdditionalCompilerArgs(compilerArgs), options, JpsCompilerServicesFacadeImpl(environment), null)
|
||||
environment.withProgressReporter { progress ->
|
||||
progress.compilationStarted()
|
||||
daemon.compile(
|
||||
sessionId,
|
||||
withAdditionalCompilerArgs(compilerArgs),
|
||||
options,
|
||||
JpsCompilerServicesFacadeImpl(environment),
|
||||
null
|
||||
)
|
||||
}
|
||||
}?.let { exitCodeFromProcessExitCode(it) }
|
||||
}
|
||||
|
||||
@@ -248,7 +257,10 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
||||
if (System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false").toBoolean())
|
||||
System.setProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "true")
|
||||
|
||||
val rc = CompilerRunnerUtil.invokeExecMethod(compilerClassName, withAdditionalCompilerArgs(compilerArgs), environment, out)
|
||||
val rc = environment.withProgressReporter { progress ->
|
||||
progress.compilationStarted()
|
||||
CompilerRunnerUtil.invokeExecMethod(compilerClassName, withAdditionalCompilerArgs(compilerArgs), environment, out)
|
||||
}
|
||||
|
||||
// exec() returns an ExitCode object, class of which is loaded with a different class loader,
|
||||
// so we take it's contents through reflection
|
||||
@@ -292,6 +304,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
||||
|
||||
override fun getDaemonConnection(environment: JpsCompilerEnvironment): CompileServiceSession? =
|
||||
getOrCreateDaemonConnection {
|
||||
environment.progressReporter.progress("connecting to daemon")
|
||||
val libPath = CompilerRunnerUtil.getLibPath(environment.kotlinPaths, environment.messageCollector)
|
||||
val compilerPath = File(libPath, "kotlin-compiler.jar")
|
||||
val toolsJarPath = CompilerRunnerUtil.jdkToolsJar
|
||||
@@ -300,6 +313,10 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
||||
|
||||
val clientFlagFile = KotlinCompilerClient.getOrCreateClientFlagFile(daemonOptions)
|
||||
val sessionFlagFile = makeAutodeletingFlagFile("compiler-jps-session-", File(daemonOptions.runFilesPathOrDefault))
|
||||
newDaemonConnection(compilerId, clientFlagFile, sessionFlagFile, environment, daemonOptions)
|
||||
|
||||
environment.withProgressReporter { progress ->
|
||||
progress.progress("connecting to daemon")
|
||||
newDaemonConnection(compilerId, clientFlagFile, sessionFlagFile, environment, daemonOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.compilerRunner
|
||||
|
||||
import org.jetbrains.jps.ModuleChunk
|
||||
import org.jetbrains.jps.incremental.CompileContext
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage
|
||||
|
||||
interface ProgressReporter {
|
||||
fun progress(message: String)
|
||||
fun compilationStarted()
|
||||
fun clearProgress()
|
||||
}
|
||||
|
||||
class ProgressReporterImpl(private val context: CompileContext, private val chunk: ModuleChunk) : ProgressReporter {
|
||||
override fun progress(message: String) {
|
||||
context.processMessage(ProgressMessage("Kotlin: $message"))
|
||||
}
|
||||
|
||||
override fun compilationStarted() {
|
||||
progress("compiling [${chunk.presentableShortName}]")
|
||||
}
|
||||
|
||||
override fun clearProgress() {
|
||||
context.processMessage(ProgressMessage(""))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline fun <T> JpsCompilerEnvironment.withProgressReporter(fn: (ProgressReporter) -> T): T =
|
||||
try {
|
||||
fn(progressReporter)
|
||||
} finally {
|
||||
progressReporter.clearProgress()
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.*
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.jps.model.java.JpsJavaClasspathKind
|
||||
@@ -176,7 +177,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
|
||||
val incrementalCaches = getIncrementalCaches(chunk, context)
|
||||
val messageCollector = MessageCollectorAdapter(context)
|
||||
val environment = createCompileEnvironment(incrementalCaches, LookupTracker.DO_NOTHING, context, messageCollector)
|
||||
val environment = createCompileEnvironment(incrementalCaches, LookupTracker.DO_NOTHING, context, chunk, messageCollector)
|
||||
if (environment == null) return
|
||||
|
||||
val removedClasses = HashSet<String>()
|
||||
@@ -347,7 +348,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
val project = projectDescriptor.project
|
||||
val lookupTracker = getLookupTracker(project)
|
||||
val incrementalCaches = getIncrementalCaches(chunk, context)
|
||||
val environment = createCompileEnvironment(incrementalCaches, lookupTracker, context, messageCollector) ?: return ABORT
|
||||
val environment = createCompileEnvironment(incrementalCaches, lookupTracker, context, chunk, messageCollector) ?: return ABORT
|
||||
|
||||
val commonArguments = compilerArgumentsForChunk(chunk).apply {
|
||||
reportOutputFiles = true
|
||||
@@ -405,17 +406,24 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
|
||||
context.checkCanceled()
|
||||
|
||||
val changesCollector = ChangesCollector()
|
||||
for ((target, files) in generatedFiles) {
|
||||
updateIncrementalCache(files, incrementalCaches[target]!!, changesCollector, null)
|
||||
}
|
||||
updateLookupStorage(chunk, lookupTracker, dataManager, dirtyFilesHolder, filesToCompile)
|
||||
environment.withProgressReporter { progress ->
|
||||
progress.progress("updating IC caches")
|
||||
|
||||
if (isChunkRebuilding) {
|
||||
return OK
|
||||
}
|
||||
val changesCollector = ChangesCollector()
|
||||
for ((target, files) in generatedFiles) {
|
||||
updateIncrementalCache(files, incrementalCaches[target]!!, changesCollector, null)
|
||||
}
|
||||
updateLookupStorage(chunk, lookupTracker, dataManager, dirtyFilesHolder, filesToCompile)
|
||||
|
||||
changesCollector.processChangesUsingLookups(filesToCompile.values().toSet(), dataManager, fsOperations, incrementalCaches.values)
|
||||
if (!isChunkRebuilding) {
|
||||
changesCollector.processChangesUsingLookups(
|
||||
filesToCompile.values().toSet(),
|
||||
dataManager,
|
||||
fsOperations,
|
||||
incrementalCaches.values
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return OK
|
||||
}
|
||||
@@ -567,6 +575,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
incrementalCaches: Map<ModuleBuildTarget, IncrementalCache>,
|
||||
lookupTracker: LookupTracker,
|
||||
context: CompileContext,
|
||||
chunk: ModuleChunk,
|
||||
messageCollector: MessageCollectorAdapter
|
||||
): JpsCompilerEnvironment? {
|
||||
val compilerServices = with(Services.Builder()) {
|
||||
@@ -597,7 +606,8 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
compilerServices,
|
||||
classesToLoadByParent,
|
||||
messageCollector,
|
||||
OutputItemsCollectorImpl()
|
||||
OutputItemsCollectorImpl(),
|
||||
ProgressReporterImpl(context, chunk)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user