[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
|
* Directories that should be cleared when IC decides to rebuild
|
||||||
*/
|
*/
|
||||||
val outputFiles: List<File>,
|
val outputFiles: List<File>,
|
||||||
val multiModuleICSettings: MultiModuleICSettings,
|
val multiModuleICSettings: MultiModuleICSettings? = null,
|
||||||
val modulesInfo: IncrementalModuleInfo,
|
val modulesInfo: IncrementalModuleInfo,
|
||||||
kotlinScriptExtensions: Array<String>? = null,
|
kotlinScriptExtensions: Array<String>? = null,
|
||||||
val withAbiSnapshot: Boolean = false,
|
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.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
||||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
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.ModulesApiHistoryAndroid
|
||||||
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistoryJs
|
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistoryJs
|
||||||
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistoryJvm
|
import org.jetbrains.kotlin.incremental.multiproject.ModulesApiHistoryJvm
|
||||||
@@ -560,7 +561,7 @@ abstract class CompileServiceImplBase(
|
|||||||
val compiler = IncrementalJsCompilerRunner(
|
val compiler = IncrementalJsCompilerRunner(
|
||||||
workingDir = workingDir,
|
workingDir = workingDir,
|
||||||
reporter = reporter,
|
reporter = reporter,
|
||||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings?.buildHistoryFile,
|
||||||
scopeExpansion = if (args.isIrBackendEnabled()) CompileScopeExpansionMode.ALWAYS else CompileScopeExpansionMode.NEVER,
|
scopeExpansion = if (args.isIrBackendEnabled()) CompileScopeExpansionMode.ALWAYS else CompileScopeExpansionMode.NEVER,
|
||||||
modulesApiHistory = modulesApiHistory,
|
modulesApiHistory = modulesApiHistory,
|
||||||
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot,
|
withAbiSnapshot = incrementalCompilationOptions.withAbiSnapshot,
|
||||||
@@ -605,15 +606,15 @@ abstract class CompileServiceImplBase(
|
|||||||
|
|
||||||
val workingDir = incrementalCompilationOptions.workingDir
|
val workingDir = incrementalCompilationOptions.workingDir
|
||||||
|
|
||||||
val modulesApiHistory = incrementalCompilationOptions.run {
|
val modulesApiHistory = incrementalCompilationOptions.multiModuleICSettings?.run {
|
||||||
reporter.info { "Use module detection: ${multiModuleICSettings.useModuleDetection}" }
|
reporter.info { "Use module detection: ${useModuleDetection}" }
|
||||||
|
|
||||||
if (!multiModuleICSettings.useModuleDetection) {
|
if (!useModuleDetection) {
|
||||||
ModulesApiHistoryJvm(modulesInfo)
|
ModulesApiHistoryJvm(incrementalCompilationOptions.modulesInfo)
|
||||||
} else {
|
} else {
|
||||||
ModulesApiHistoryAndroid(modulesInfo)
|
ModulesApiHistoryAndroid(incrementalCompilationOptions.modulesInfo)
|
||||||
}
|
}
|
||||||
}
|
} ?: EmptyModulesApiHistory
|
||||||
|
|
||||||
val projectRoot = incrementalCompilationOptions.modulesInfo.projectRoot
|
val projectRoot = incrementalCompilationOptions.modulesInfo.projectRoot
|
||||||
val useK2 = k2jvmArgs.useK2 || LanguageVersion.fromVersionString(k2jvmArgs.languageVersion)?.usesK2 == true
|
val useK2 = k2jvmArgs.useK2 || LanguageVersion.fromVersionString(k2jvmArgs.languageVersion)?.usesK2 == true
|
||||||
@@ -624,7 +625,7 @@ abstract class CompileServiceImplBase(
|
|||||||
val compiler = IncrementalJvmCompilerRunner(
|
val compiler = IncrementalJvmCompilerRunner(
|
||||||
workingDir,
|
workingDir,
|
||||||
reporter,
|
reporter,
|
||||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings?.buildHistoryFile,
|
||||||
outputDirs = incrementalCompilationOptions.outputFiles,
|
outputDirs = incrementalCompilationOptions.outputFiles,
|
||||||
usePreciseJavaTracking = usePreciseJavaTracking,
|
usePreciseJavaTracking = usePreciseJavaTracking,
|
||||||
modulesApiHistory = modulesApiHistory,
|
modulesApiHistory = modulesApiHistory,
|
||||||
|
|||||||
+14
-11
@@ -54,7 +54,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
private val workingDir: File,
|
private val workingDir: File,
|
||||||
cacheDirName: String,
|
cacheDirName: String,
|
||||||
protected val reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
protected val reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||||
protected val buildHistoryFile: File,
|
protected val buildHistoryFile: File?,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output directories of the compilation. These include:
|
* Output directories of the compilation. These include:
|
||||||
@@ -416,7 +416,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
reporter.measure(GradleBuildTime.CALCULATE_OUTPUT_SIZE) {
|
reporter.measure(GradleBuildTime.CALCULATE_OUTPUT_SIZE) {
|
||||||
reporter.addMetric(
|
reporter.addMetric(
|
||||||
GradleBuildPerformanceMetric.SNAPSHOT_SIZE,
|
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() })
|
reporter.addMetric(GradleBuildPerformanceMetric.CACHE_DIRECTORY_SIZE, cacheDirectory.walk().sumOf { it.length() })
|
||||||
}
|
}
|
||||||
@@ -608,16 +608,19 @@ abstract class IncrementalCompilerRunner<
|
|||||||
compilationMode: CompilationMode,
|
compilationMode: CompilationMode,
|
||||||
currentBuildInfo: BuildInfo,
|
currentBuildInfo: BuildInfo,
|
||||||
dirtyData: DirtyData,
|
dirtyData: DirtyData,
|
||||||
) = reporter.measure(GradleBuildTime.IC_WRITE_HISTORY_FILE) {
|
) {
|
||||||
val prevDiffs = BuildDiffsStorage.readFromFile(buildHistoryFile, reporter)?.buildDiffs ?: emptyList()
|
if (buildHistoryFile == null) return
|
||||||
val newDiff = if (compilationMode is CompilationMode.Incremental) {
|
reporter.measure(GradleBuildTime.IC_WRITE_HISTORY_FILE) {
|
||||||
BuildDifference(currentBuildInfo.startTS, true, dirtyData)
|
val prevDiffs = BuildDiffsStorage.readFromFile(buildHistoryFile, reporter)?.buildDiffs ?: emptyList()
|
||||||
} else {
|
val newDiff = if (compilationMode is CompilationMode.Incremental) {
|
||||||
val emptyDirtyData = DirtyData()
|
BuildDifference(currentBuildInfo.startTS, true, dirtyData)
|
||||||
BuildDifference(currentBuildInfo.startTS, false, emptyDirtyData)
|
} 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 {
|
companion object {
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ import java.io.File
|
|||||||
open class IncrementalFirJvmCompilerRunner(
|
open class IncrementalFirJvmCompilerRunner(
|
||||||
workingDir: File,
|
workingDir: File,
|
||||||
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||||
buildHistoryFile: File,
|
buildHistoryFile: File?,
|
||||||
outputDirs: Collection<File>?,
|
outputDirs: Collection<File>?,
|
||||||
modulesApiHistory: ModulesApiHistory,
|
modulesApiHistory: ModulesApiHistory,
|
||||||
kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
|
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(
|
class IncrementalJsCompilerRunner(
|
||||||
workingDir: File,
|
workingDir: File,
|
||||||
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||||
buildHistoryFile: File,
|
buildHistoryFile: File?,
|
||||||
private val modulesApiHistory: ModulesApiHistory,
|
private val modulesApiHistory: ModulesApiHistory,
|
||||||
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER,
|
private val scopeExpansion: CompileScopeExpansionMode = CompileScopeExpansionMode.NEVER,
|
||||||
withAbiSnapshot: Boolean = false,
|
withAbiSnapshot: Boolean = false,
|
||||||
@@ -125,6 +125,9 @@ class IncrementalJsCompilerRunner(
|
|||||||
messageCollector: MessageCollector,
|
messageCollector: MessageCollector,
|
||||||
classpathAbiSnapshots: Map<String, AbiSnapshot> //Ignore for now
|
classpathAbiSnapshots: Map<String, AbiSnapshot> //Ignore for now
|
||||||
): CompilationMode {
|
): 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) {
|
if (!withAbiSnapshot && !buildHistoryFile.isFile) {
|
||||||
return CompilationMode.Rebuild(BuildAttribute.NO_BUILD_HISTORY)
|
return CompilationMode.Rebuild(BuildAttribute.NO_BUILD_HISTORY)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -63,7 +63,7 @@ open class IncrementalJvmCompilerRunner(
|
|||||||
workingDir: File,
|
workingDir: File,
|
||||||
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||||
private val usePreciseJavaTracking: Boolean,
|
private val usePreciseJavaTracking: Boolean,
|
||||||
buildHistoryFile: File,
|
buildHistoryFile: File?,
|
||||||
outputDirs: Collection<File>?,
|
outputDirs: Collection<File>?,
|
||||||
private val modulesApiHistory: ModulesApiHistory,
|
private val modulesApiHistory: ModulesApiHistory,
|
||||||
override val kotlinSourceFilesExtensions: List<String> = DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS,
|
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 NotAvailableDueToMissingClasspathSnapshot -> ChangesEither.Unknown(BuildAttribute.CLASSPATH_SNAPSHOT_NOT_FOUND)
|
||||||
is NotAvailableForNonIncrementalRun -> ChangesEither.Unknown(BuildAttribute.UNKNOWN_CHANGES_IN_GRADLE_INPUTS)
|
is NotAvailableForNonIncrementalRun -> ChangesEither.Unknown(BuildAttribute.UNKNOWN_CHANGES_IN_GRADLE_INPUTS)
|
||||||
is ClasspathSnapshotDisabled -> reporter.measure(GradleBuildTime.IC_ANALYZE_CHANGES_IN_DEPENDENCIES) {
|
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
|
// 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.
|
// @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
|
// (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