Adjust build report verbosity
This commit is contained in:
@@ -21,14 +21,13 @@ import java.io.File
|
||||
|
||||
interface ICReporter {
|
||||
fun report(message: () -> String)
|
||||
fun reportVerbose(message: () -> String)
|
||||
|
||||
// used in Gradle plugin
|
||||
@Suppress("unused")
|
||||
fun reportCompileIteration(sourceFiles: Collection<File>, exitCode: ExitCode) {}
|
||||
fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) {}
|
||||
|
||||
fun pathsAsString(files: Iterable<File>): String =
|
||||
files.joinToString { it.canonicalPath }
|
||||
files.joinToString { it.canonicalPath }
|
||||
|
||||
fun pathsAsString(vararg files: File): String =
|
||||
pathsAsString(files.toList())
|
||||
pathsAsString(files.toList())
|
||||
}
|
||||
@@ -130,7 +130,7 @@ fun ChangesCollector.getDirtyData(
|
||||
val dirtyClassesFqNames = HashSet<FqName>()
|
||||
|
||||
for (change in changes()) {
|
||||
reporter.report { "Process $change" }
|
||||
reporter.reportVerbose { "Process $change" }
|
||||
|
||||
if (change is ChangeInfo.SignatureChanged) {
|
||||
val fqNames = if (!change.areSubclassesAffected) listOf(change.fqName) else withSubtypes(change.fqName, caches)
|
||||
@@ -190,7 +190,7 @@ fun mapClassesFqNamesToFiles(
|
||||
val srcFile = cache.getSourceFileIfClass(dirtyClassFqName)
|
||||
if (srcFile == null || srcFile in excludes || srcFile.isJavaFile()) continue
|
||||
|
||||
reporter.report { ("Class $dirtyClassFqName caused recompilation of: ${reporter.pathsAsString(srcFile)}") }
|
||||
reporter.report { "Class $dirtyClassFqName caused recompilation of: ${reporter.pathsAsString(srcFile)}" }
|
||||
dirtyFiles.add(srcFile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,24 +36,34 @@ internal class RemoteICReporter(
|
||||
private val icLogLines = arrayListOf<String>()
|
||||
|
||||
override fun report(message: () -> String) {
|
||||
reportImpl(isMessageVerbose = false, message = message)
|
||||
}
|
||||
|
||||
override fun reportVerbose(message: () -> String) {
|
||||
reportImpl(isMessageVerbose = true, message = message)
|
||||
}
|
||||
|
||||
private fun reportImpl(isMessageVerbose: Boolean, message: () -> String) {
|
||||
val lazyMessage = lazy { message() }
|
||||
if (shouldReportMessages && isVerbose) {
|
||||
|
||||
val shouldReportVerbose = isVerbose || !isMessageVerbose
|
||||
if (shouldReportMessages && shouldReportVerbose) {
|
||||
servicesFacade.report(ReportCategory.IC_MESSAGE, ReportSeverity.DEBUG, lazyMessage.value)
|
||||
}
|
||||
if (shouldReportICLog) {
|
||||
if (shouldReportICLog && shouldReportVerbose) {
|
||||
icLogLines.add(lazyMessage.value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun reportCompileIteration(sourceFiles: Collection<File>, exitCode: ExitCode) {
|
||||
override fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) {
|
||||
if (shouldReportCompileIteration) {
|
||||
compilationResults.add(
|
||||
CompilationResultCategory.IC_COMPILE_ITERATION.code,
|
||||
CompileIterationResult(sourceFiles, exitCode.toString())
|
||||
)
|
||||
}
|
||||
if (shouldReportICLog) {
|
||||
icLogLines.add("compile iteration:")
|
||||
if (shouldReportICLog && incremental) {
|
||||
icLogLines.add("Compile iteration:")
|
||||
sourceFiles.relativePaths(rootDir).forEach {
|
||||
icLogLines.add(" $it")
|
||||
}
|
||||
|
||||
+5
-4
@@ -105,22 +105,22 @@ abstract class IncrementalCompilerRunner<
|
||||
private fun clearLocalStateOnRebuild(args: Args) {
|
||||
val destinationDir = destinationDir(args)
|
||||
|
||||
reporter.report { "Clearing output on rebuild" }
|
||||
reporter.reportVerbose { "Clearing output on rebuild" }
|
||||
for (file in sequenceOf(destinationDir, workingDir) + outputFiles.asSequence()) {
|
||||
val deleted: Boolean? = when {
|
||||
file.isDirectory -> {
|
||||
reporter.report { "Deleting directory $file" }
|
||||
reporter.reportVerbose { " Deleting directory $file" }
|
||||
file.deleteRecursively()
|
||||
}
|
||||
file.isFile -> {
|
||||
reporter.report { "Deleting $file" }
|
||||
reporter.reportVerbose { " Deleting $file" }
|
||||
file.delete()
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (deleted == false) {
|
||||
reporter.report { "Could not delete $file" }
|
||||
reporter.reportVerbose { " Could not delete $file" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,6 +241,7 @@ abstract class IncrementalCompilerRunner<
|
||||
exitCode = runCompiler(sourcesToCompile.toSet(), args, caches, services, messageCollectorAdapter)
|
||||
postCompilationHook(exitCode)
|
||||
|
||||
reporter.reportCompileIteration(compilationMode is CompilationMode.Incremental, sourcesToCompile, exitCode)
|
||||
if (exitCode != ExitCode.OK) break
|
||||
|
||||
dirtySourcesSinceLastTimeFile.delete()
|
||||
|
||||
+4
-7
@@ -153,13 +153,10 @@ class IncrementalJsCompilerRunner(
|
||||
): ExitCode {
|
||||
val freeArgsBackup = args.freeArgs
|
||||
|
||||
try {
|
||||
args.freeArgs += sourcesToCompile.map() { it.absolutePath }
|
||||
val exitCode = K2JSCompiler().exec(messageCollector, services, args)
|
||||
reporter.reportCompileIteration(sourcesToCompile, exitCode)
|
||||
return exitCode
|
||||
}
|
||||
finally {
|
||||
return try {
|
||||
args.freeArgs += sourcesToCompile.map { it.absolutePath }
|
||||
K2JSCompiler().exec(messageCollector, services, args)
|
||||
} finally {
|
||||
args.freeArgs = freeArgsBackup
|
||||
}
|
||||
}
|
||||
|
||||
+7
-9
@@ -82,6 +82,9 @@ fun makeIncrementally(
|
||||
object EmptyICReporter : ICReporter {
|
||||
override fun report(message: () -> String) {
|
||||
}
|
||||
|
||||
override fun reportVerbose(message: () -> String) {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <R> withIC(enabled: Boolean = true, fn: ()->R): R {
|
||||
@@ -146,7 +149,7 @@ class IncrementalJvmCompilerRunner(
|
||||
initDirtyFiles(dirtyFiles, changedFiles)
|
||||
|
||||
val lastBuildInfo = BuildInfo.read(lastBuildInfoFile) ?: return CompilationMode.Rebuild { "No information on previous build" }
|
||||
reporter.report { "Last Kotlin Build info -- $lastBuildInfo" }
|
||||
reporter.reportVerbose { "Last Kotlin Build info -- $lastBuildInfo" }
|
||||
|
||||
val classpathChanges = getClasspathChanges(args.classpathAsList, changedFiles, lastBuildInfo, modulesApiHistory, reporter)
|
||||
|
||||
@@ -351,14 +354,9 @@ class IncrementalJvmCompilerRunner(
|
||||
args.destination = null
|
||||
args.buildFile = moduleFile.absolutePath
|
||||
|
||||
try {
|
||||
reporter.report { "compiling with args: ${ArgumentUtils.convertArgumentsToStringList(args)}" }
|
||||
reporter.report { "compiling with classpath: ${classpath.toList().sorted().joinToString()}" }
|
||||
val exitCode = compiler.exec(messageCollector, services, args)
|
||||
reporter.reportCompileIteration(sourcesToCompile, exitCode)
|
||||
return exitCode
|
||||
}
|
||||
finally {
|
||||
return try {
|
||||
compiler.exec(messageCollector, services, args)
|
||||
} finally {
|
||||
args.destination = destination
|
||||
moduleFile.delete()
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class InputsCache(
|
||||
fun removeOutputForSourceFiles(sources: Iterable<File>) {
|
||||
for (sourceFile in sources) {
|
||||
sourceToOutputMap.remove(sourceFile).forEach { it ->
|
||||
reporter.report { "Deleting $it on clearing cache for $sourceFile" }
|
||||
reporter.reportVerbose { "Deleting $it on clearing cache for $sourceFile" }
|
||||
it.delete()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -32,7 +32,10 @@ class TestICReporter : ICReporter {
|
||||
override fun report(message: () -> String) {
|
||||
}
|
||||
|
||||
override fun reportCompileIteration(sourceFiles: Collection<File>, exitCode: ExitCode) {
|
||||
override fun reportVerbose(message: () -> String) {
|
||||
}
|
||||
|
||||
override fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) {
|
||||
compiledSourcesMutable.addAll(sourceFiles)
|
||||
this.exitCode = exitCode
|
||||
}
|
||||
|
||||
@@ -661,6 +661,10 @@ private class JpsICReporter : ICReporter {
|
||||
KotlinBuilder.LOG.debug(message())
|
||||
}
|
||||
}
|
||||
|
||||
override fun reportVerbose(message: () -> String) {
|
||||
report(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ChangesCollector.processChangesUsingLookups(
|
||||
@@ -672,12 +676,12 @@ private fun ChangesCollector.processChangesUsingLookups(
|
||||
val allCaches = caches.flatMap { it.thisWithDependentCaches }
|
||||
val reporter = JpsICReporter()
|
||||
|
||||
reporter.report { "Start processing changes" }
|
||||
reporter.reportVerbose { "Start processing changes" }
|
||||
|
||||
val dirtyFiles = getDirtyFiles(allCaches, dataManager)
|
||||
fsOperations.markInChunkOrDependents(dirtyFiles.asIterable(), excludeFiles = compiledFiles)
|
||||
|
||||
reporter.report { "End of processing changes" }
|
||||
reporter.reportVerbose { "End of processing changes" }
|
||||
}
|
||||
|
||||
private fun ChangesCollector.getDirtyFiles(
|
||||
|
||||
Reference in New Issue
Block a user