Adjust build report verbosity

This commit is contained in:
Alexey Tsvetkov
2019-01-29 00:51:55 +03:00
parent 98ef00b957
commit 47bb938b94
9 changed files with 48 additions and 36 deletions
@@ -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()
@@ -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
}
}
@@ -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()
}
@@ -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()
}
}
@@ -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
}