[IC] Allow to not specify the build history file
This commit is contained in:
committed by
Space Team
parent
38a54549ff
commit
e33611a88a
+1
-1
@@ -68,7 +68,7 @@ class IncrementalCompilationOptions(
|
||||
* Directories that should be cleared when IC decides to rebuild
|
||||
*/
|
||||
val outputFiles: List<File>,
|
||||
val multiModuleICSettings: MultiModuleICSettings,
|
||||
val multiModuleICSettings: MultiModuleICSettings? = null,
|
||||
val modulesInfo: IncrementalModuleInfo,
|
||||
kotlinScriptExtensions: Array<String>? = null,
|
||||
val withAbiSnapshot: Boolean = false,
|
||||
|
||||
@@ -55,6 +55,7 @@ import org.jetbrains.kotlin.incremental.components.InlineConstTracker
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
||||
import org.jetbrains.kotlin.incremental.multiproject.EmptyModulesApiHistory
|
||||
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistoryAndroid
|
||||
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistoryJs
|
||||
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistoryJvm
|
||||
@@ -560,7 +561,7 @@ abstract class CompileServiceImplBase(
|
||||
val compiler = IncrementalJsCompilerRunner(
|
||||
workingDir = workingDir,
|
||||
reporter = reporter,
|
||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings?.buildHistoryFile,
|
||||
scopeExpansion = if (args.isIrBackendEnabled()) CompileScopeExpansionMode.ALWAYS else CompileScopeExpansionMode.NEVER,
|
||||
modulesApiHistory = modulesApiHistory,
|
||||
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot,
|
||||
@@ -605,15 +606,15 @@ abstract class CompileServiceImplBase(
|
||||
|
||||
val workingDir = incrementalCompilationOptions.workingDir
|
||||
|
||||
val modulesApiHistory = incrementalCompilationOptions.run {
|
||||
reporter.info { "Use module detection: ${multiModuleICSettings.useModuleDetection}" }
|
||||
val modulesApiHistory = incrementalCompilationOptions.multiModuleICSettings?.run {
|
||||
reporter.info { "Use module detection: ${useModuleDetection}" }
|
||||
|
||||
if (!multiModuleICSettings.useModuleDetection) {
|
||||
ModulesApiHistoryJvm(modulesInfo)
|
||||
if (!useModuleDetection) {
|
||||
ModulesApiHistoryJvm(incrementalCompilationOptions.modulesInfo)
|
||||
} else {
|
||||
ModulesApiHistoryAndroid(modulesInfo)
|
||||
ModulesApiHistoryAndroid(incrementalCompilationOptions.modulesInfo)
|
||||
}
|
||||
}
|
||||
} ?: EmptyModulesApiHistory
|
||||
|
||||
val projectRoot = incrementalCompilationOptions.modulesInfo.projectRoot
|
||||
val useK2 = k2jvmArgs.useK2 || LanguageVersion.fromVersionString(k2jvmArgs.languageVersion)?.usesK2 == true
|
||||
@@ -624,7 +625,7 @@ abstract class CompileServiceImplBase(
|
||||
val compiler = IncrementalJvmCompilerRunner(
|
||||
workingDir,
|
||||
reporter,
|
||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings?.buildHistoryFile,
|
||||
outputDirs = incrementalCompilationOptions.outputFiles,
|
||||
usePreciseJavaTracking = usePreciseJavaTracking,
|
||||
modulesApiHistory = modulesApiHistory,
|
||||
|
||||
+14
-11
@@ -54,7 +54,7 @@ abstract class IncrementalCompilerRunner<
|
||||
private val workingDir: File,
|
||||
cacheDirName: String,
|
||||
protected val reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||
protected val buildHistoryFile: File,
|
||||
protected val buildHistoryFile: File?,
|
||||
|
||||
/**
|
||||
* Output directories of the compilation. These include:
|
||||
@@ -416,7 +416,7 @@ abstract class IncrementalCompilerRunner<
|
||||
reporter.measure(GradleBuildTime.CALCULATE_OUTPUT_SIZE) {
|
||||
reporter.addMetric(
|
||||
GradleBuildPerformanceMetric.SNAPSHOT_SIZE,
|
||||
buildHistoryFile.length() + lastBuildInfoFile.length() + abiSnapshotFile.length()
|
||||
(buildHistoryFile?.length() ?: 0) + lastBuildInfoFile.length() + abiSnapshotFile.length()
|
||||
)
|
||||
reporter.addMetric(GradleBuildPerformanceMetric.CACHE_DIRECTORY_SIZE, cacheDirectory.walk().sumOf { it.length() })
|
||||
}
|
||||
@@ -608,16 +608,19 @@ abstract class IncrementalCompilerRunner<
|
||||
compilationMode: CompilationMode,
|
||||
currentBuildInfo: BuildInfo,
|
||||
dirtyData: DirtyData,
|
||||
) = reporter.measure(GradleBuildTime.IC_WRITE_HISTORY_FILE) {
|
||||
val prevDiffs = BuildDiffsStorage.readFromFile(buildHistoryFile, reporter)?.buildDiffs ?: emptyList()
|
||||
val newDiff = if (compilationMode is CompilationMode.Incremental) {
|
||||
BuildDifference(currentBuildInfo.startTS, true, dirtyData)
|
||||
} else {
|
||||
val emptyDirtyData = DirtyData()
|
||||
BuildDifference(currentBuildInfo.startTS, false, emptyDirtyData)
|
||||
}
|
||||
) {
|
||||
if (buildHistoryFile == null) return
|
||||
reporter.measure(GradleBuildTime.IC_WRITE_HISTORY_FILE) {
|
||||
val prevDiffs = BuildDiffsStorage.readFromFile(buildHistoryFile, reporter)?.buildDiffs ?: emptyList()
|
||||
val newDiff = if (compilationMode is CompilationMode.Incremental) {
|
||||
BuildDifference(currentBuildInfo.startTS, true, dirtyData)
|
||||
} else {
|
||||
val emptyDirtyData = DirtyData()
|
||||
BuildDifference(currentBuildInfo.startTS, false, emptyDirtyData)
|
||||
}
|
||||
|
||||
BuildDiffsStorage.writeToFile(icContext, buildHistoryFile, BuildDiffsStorage(prevDiffs + newDiff))
|
||||
BuildDiffsStorage.writeToFile(icContext, buildHistoryFile, BuildDiffsStorage(prevDiffs + newDiff))
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ import java.io.File
|
||||
open class IncrementalFirJvmCompilerRunner(
|
||||
workingDir: File,
|
||||
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||
buildHistoryFile: File,
|
||||
buildHistoryFile: File?,
|
||||
outputDirs: Collection<File>?,
|
||||
modulesApiHistory: ModulesApiHistory,
|
||||
kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
|
||||
|
||||
+4
-1
@@ -86,7 +86,7 @@ inline fun <R> withJsIC(args: CommonCompilerArguments, enabled: Boolean = true,
|
||||
class IncrementalJsCompilerRunner(
|
||||
workingDir: File,
|
||||
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||
buildHistoryFile: File,
|
||||
buildHistoryFile: File?,
|
||||
private val modulesApiHistory: ModulesApiHistory,
|
||||
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER,
|
||||
withAbiSnapshot: Boolean = false,
|
||||
@@ -125,6 +125,9 @@ class IncrementalJsCompilerRunner(
|
||||
messageCollector: MessageCollector,
|
||||
classpathAbiSnapshots: Map<String, AbiSnapshot> //Ignore for now
|
||||
): CompilationMode {
|
||||
if (buildHistoryFile == null) {
|
||||
error("The build is configured to use the build-history based IC approach, but doesn't specify the buildHistoryFile")
|
||||
}
|
||||
if (!withAbiSnapshot && !buildHistoryFile.isFile) {
|
||||
return CompilationMode.Rebuild(BuildAttribute.NO_BUILD_HISTORY)
|
||||
}
|
||||
|
||||
+5
-2
@@ -63,7 +63,7 @@ open class IncrementalJvmCompilerRunner(
|
||||
workingDir: File,
|
||||
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||
private val usePreciseJavaTracking: Boolean,
|
||||
buildHistoryFile: File,
|
||||
buildHistoryFile: File?,
|
||||
outputDirs: Collection<File>?,
|
||||
private val modulesApiHistory: ModulesApiHistory,
|
||||
override val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
|
||||
@@ -207,7 +207,10 @@ open class IncrementalJvmCompilerRunner(
|
||||
is NotAvailableDueToMissingClasspathSnapshot -> ChangesEither.Unknown(BuildAttribute.CLASSPATH_SNAPSHOT_NOT_FOUND)
|
||||
is NotAvailableForNonIncrementalRun -> ChangesEither.Unknown(BuildAttribute.UNKNOWN_CHANGES_IN_GRADLE_INPUTS)
|
||||
is ClasspathSnapshotDisabled -> reporter.measure(GradleBuildTime.IC_ANALYZE_CHANGES_IN_DEPENDENCIES) {
|
||||
if (!withAbiSnapshot && !buildHistoryFile.isFile) {
|
||||
if (buildHistoryFile == null) {
|
||||
error("The build is configured to use the build-history based IC approach, but doesn't specify the buildHistoryFile")
|
||||
}
|
||||
if (!withAbiSnapshot && buildHistoryFile.isFile != true) {
|
||||
// If the previous build was a Gradle cache hit, the build history file must have been deleted as it is marked as
|
||||
// @LocalState in the Gradle task. Therefore, this compilation will need to run non-incrementally.
|
||||
// (Note that buildHistoryFile is outside workingDir. We don't need to perform the same check for files inside
|
||||
|
||||
Reference in New Issue
Block a user