[IC] Allow to not specify the modules info
This commit is contained in:
committed by
Space Team
parent
e33611a88a
commit
b3677fa0ca
@@ -21,7 +21,6 @@ data class IncrementalModuleEntry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IncrementalModuleInfo(
|
class IncrementalModuleInfo(
|
||||||
val projectRoot: File,
|
|
||||||
val rootProjectBuildDir: File,
|
val rootProjectBuildDir: File,
|
||||||
val dirToModule: Map<File, IncrementalModuleEntry>,
|
val dirToModule: Map<File, IncrementalModuleEntry>,
|
||||||
val nameToModules: Map<String, Set<IncrementalModuleEntry>>,
|
val nameToModules: Map<String, Set<IncrementalModuleEntry>>,
|
||||||
|
|||||||
+5
-1
@@ -69,7 +69,11 @@ class IncrementalCompilationOptions(
|
|||||||
*/
|
*/
|
||||||
val outputFiles: List<File>,
|
val outputFiles: List<File>,
|
||||||
val multiModuleICSettings: MultiModuleICSettings? = null,
|
val multiModuleICSettings: MultiModuleICSettings? = null,
|
||||||
val modulesInfo: IncrementalModuleInfo,
|
val modulesInfo: IncrementalModuleInfo? = null,
|
||||||
|
/**
|
||||||
|
* Root project directory, used to resolve relative paths
|
||||||
|
*/
|
||||||
|
val rootProjectDir: File,
|
||||||
kotlinScriptExtensions: Array<String>? = null,
|
kotlinScriptExtensions: Array<String>? = null,
|
||||||
val withAbiSnapshot: Boolean = false,
|
val withAbiSnapshot: Boolean = false,
|
||||||
val preciseCompilationResultsBackup: Boolean = false,
|
val preciseCompilationResultsBackup: Boolean = false,
|
||||||
|
|||||||
@@ -556,7 +556,12 @@ abstract class CompileServiceImplBase(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val workingDir = incrementalCompilationOptions.workingDir
|
val workingDir = incrementalCompilationOptions.workingDir
|
||||||
val modulesApiHistory = ModulesApiHistoryJs(incrementalCompilationOptions.modulesInfo)
|
val modulesApiHistory = incrementalCompilationOptions.multiModuleICSettings?.run {
|
||||||
|
val modulesInfo = incrementalCompilationOptions.modulesInfo
|
||||||
|
?: error("The build is configured to use the history-file based IC approach, but doesn't provide the modulesInfo")
|
||||||
|
|
||||||
|
ModulesApiHistoryJs(incrementalCompilationOptions.rootProjectDir, modulesInfo)
|
||||||
|
} ?: EmptyModulesApiHistory
|
||||||
|
|
||||||
val compiler = IncrementalJsCompilerRunner(
|
val compiler = IncrementalJsCompilerRunner(
|
||||||
workingDir = workingDir,
|
workingDir = workingDir,
|
||||||
@@ -606,17 +611,20 @@ abstract class CompileServiceImplBase(
|
|||||||
|
|
||||||
val workingDir = incrementalCompilationOptions.workingDir
|
val workingDir = incrementalCompilationOptions.workingDir
|
||||||
|
|
||||||
|
val projectRoot = incrementalCompilationOptions.rootProjectDir
|
||||||
|
|
||||||
val modulesApiHistory = incrementalCompilationOptions.multiModuleICSettings?.run {
|
val modulesApiHistory = incrementalCompilationOptions.multiModuleICSettings?.run {
|
||||||
reporter.info { "Use module detection: ${useModuleDetection}" }
|
reporter.info { "Use module detection: $useModuleDetection" }
|
||||||
|
val modulesInfo = incrementalCompilationOptions.modulesInfo
|
||||||
|
?: error("The build is configured to use the history-file based IC approach, but doesn't provide the modulesInfo")
|
||||||
|
|
||||||
if (!useModuleDetection) {
|
if (!useModuleDetection) {
|
||||||
ModulesApiHistoryJvm(incrementalCompilationOptions.modulesInfo)
|
ModulesApiHistoryJvm(projectRoot, modulesInfo)
|
||||||
} else {
|
} else {
|
||||||
ModulesApiHistoryAndroid(incrementalCompilationOptions.modulesInfo)
|
ModulesApiHistoryAndroid(projectRoot, modulesInfo)
|
||||||
}
|
}
|
||||||
} ?: EmptyModulesApiHistory
|
} ?: EmptyModulesApiHistory
|
||||||
|
|
||||||
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
|
||||||
// TODO: This should be reverted after implementing of fir-based java tracker (KT-57147).
|
// TODO: This should be reverted after implementing of fir-based java tracker (KT-57147).
|
||||||
// See org.jetbrains.kotlin.incremental.CompilerRunnerUtilsKt.makeJvmIncrementally
|
// See org.jetbrains.kotlin.incremental.CompilerRunnerUtilsKt.makeJvmIncrementally
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ fun getBuildReporter(
|
|||||||
compilationResults: CompilationResults,
|
compilationResults: CompilationResults,
|
||||||
compilationOptions: IncrementalCompilationOptions
|
compilationOptions: IncrementalCompilationOptions
|
||||||
): RemoteBuildReporter<GradleBuildTime, GradleBuildPerformanceMetric> {
|
): RemoteBuildReporter<GradleBuildTime, GradleBuildPerformanceMetric> {
|
||||||
val root = compilationOptions.modulesInfo.projectRoot
|
val root = compilationOptions.rootProjectDir
|
||||||
val reporters = ArrayList<RemoteICReporter>()
|
val reporters = ArrayList<RemoteICReporter>()
|
||||||
|
|
||||||
if (ReportCategory.IC_MESSAGE.code in compilationOptions.reportCategories) {
|
if (ReportCategory.IC_MESSAGE.code in compilationOptions.reportCategories) {
|
||||||
|
|||||||
+6
-6
@@ -25,14 +25,14 @@ object EmptyModulesApiHistory : ModulesApiHistory {
|
|||||||
override fun abiSnapshot(jar: File): Either<Set<File>> = Either.Error("Not supported")
|
override fun abiSnapshot(jar: File): Either<Set<File>> = Either.Error("Not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ModulesApiHistoryBase(protected val modulesInfo: IncrementalModuleInfo) : ModulesApiHistory {
|
abstract class ModulesApiHistoryBase(rootProjectDir: File, protected val modulesInfo: IncrementalModuleInfo) : ModulesApiHistory {
|
||||||
// All project build dirs should have this dir as their parent. For a default project setup, this will
|
// All project build dirs should have this dir as their parent. For a default project setup, this will
|
||||||
// be the same as root project path. Some projects map output outside of the root project dir, typically
|
// be the same as root project path. Some projects map output outside of the root project dir, typically
|
||||||
// with <some_dir>/<project_path>/build, and in that case, this path will be <some_dir>.
|
// with <some_dir>/<project_path>/build, and in that case, this path will be <some_dir>.
|
||||||
// This is using set in order to de-dup paths, and avoid duplicate checks when possible.
|
// This is using set in order to de-dup paths, and avoid duplicate checks when possible.
|
||||||
protected val possibleParentsToBuildDirs: Set<Path> = setOf(
|
protected val possibleParentsToBuildDirs: Set<Path> = setOf(
|
||||||
Paths.get(modulesInfo.rootProjectBuildDir.parentFile.absolutePath),
|
Paths.get(modulesInfo.rootProjectBuildDir.parentFile.absolutePath),
|
||||||
Paths.get(modulesInfo.projectRoot.absolutePath)
|
Paths.get(rootProjectDir.absolutePath)
|
||||||
)
|
)
|
||||||
private val dirToHistoryFileCache = HashMap<File, Set<File>>()
|
private val dirToHistoryFileCache = HashMap<File, Set<File>>()
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ abstract class ModulesApiHistoryBase(protected val modulesInfo: IncrementalModul
|
|||||||
protected abstract fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>>
|
protected abstract fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>>
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModulesApiHistoryJvm(modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryBase(modulesInfo) {
|
class ModulesApiHistoryJvm(rootProjectDir: File, modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryBase(rootProjectDir, modulesInfo) {
|
||||||
override fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>> {
|
override fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>> {
|
||||||
val moduleInfoFromJar = modulesInfo.jarToModule[jar]
|
val moduleInfoFromJar = modulesInfo.jarToModule[jar]
|
||||||
if (moduleInfoFromJar != null) {
|
if (moduleInfoFromJar != null) {
|
||||||
@@ -144,7 +144,7 @@ class ModulesApiHistoryJvm(modulesInfo: IncrementalModuleInfo) : ModulesApiHisto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModulesApiHistoryJs(modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryBase(modulesInfo) {
|
class ModulesApiHistoryJs(rootProjectDir: File, modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryBase(rootProjectDir, modulesInfo) {
|
||||||
override fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>> {
|
override fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>> {
|
||||||
val moduleEntry = modulesInfo.jarToModule[jar]
|
val moduleEntry = modulesInfo.jarToModule[jar]
|
||||||
|
|
||||||
@@ -160,8 +160,8 @@ class ModulesApiHistoryJs(modulesInfo: IncrementalModuleInfo) : ModulesApiHistor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModulesApiHistoryAndroid(modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryBase(modulesInfo) {
|
class ModulesApiHistoryAndroid(rootProjectDir: File, modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryBase(rootProjectDir, modulesInfo) {
|
||||||
private val delegate = ModulesApiHistoryJvm(modulesInfo)
|
private val delegate = ModulesApiHistoryJvm(rootProjectDir, modulesInfo)
|
||||||
|
|
||||||
override fun historyFilesForChangedFiles(changedFiles: Set<File>): Either<Set<File>> {
|
override fun historyFilesForChangedFiles(changedFiles: Set<File>): Either<Set<File>> {
|
||||||
val historyFromDelegate = delegate.historyFilesForChangedFiles(changedFiles)
|
val historyFromDelegate = delegate.historyFilesForChangedFiles(changedFiles)
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ abstract class AbstractIncrementalMultiModuleCompilerRunnerTest<Args : CommonCom
|
|||||||
private val jarToAbiSnapshot = mutableMapOf<File, File>()
|
private val jarToAbiSnapshot = mutableMapOf<File, File>()
|
||||||
|
|
||||||
protected val incrementalModuleInfo: IncrementalModuleInfo by lazy {
|
protected val incrementalModuleInfo: IncrementalModuleInfo by lazy {
|
||||||
IncrementalModuleInfo(workingDir, workingDir, dirToModule, nameToModules, jarToClassListFile, jarToModule, jarToAbiSnapshot)
|
IncrementalModuleInfo(workingDir, dirToModule, nameToModules, jarToClassListFile, jarToModule, jarToAbiSnapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract val modulesApiHistory: ApiHistory
|
protected abstract val modulesApiHistory: ApiHistory
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ abstract class AbstractIncrementalMultiModuleJsKlibCompilerRunnerTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val modulesApiHistory: ModulesApiHistoryJs by lazy {
|
override val modulesApiHistory: ModulesApiHistoryJs by lazy {
|
||||||
ModulesApiHistoryJs(incrementalModuleInfo)
|
ModulesApiHistoryJs(workingDir, incrementalModuleInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val scopeExpansionMode: CompileScopeExpansionMode get() = CompileScopeExpansionMode.NEVER
|
override val scopeExpansionMode: CompileScopeExpansionMode get() = CompileScopeExpansionMode.NEVER
|
||||||
|
|||||||
+1
-2
@@ -59,7 +59,6 @@ class ModulesApiHistoryAndroidTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val info = IncrementalModuleInfo(
|
val info = IncrementalModuleInfo(
|
||||||
projectRoot = projectRoot,
|
|
||||||
rootProjectBuildDir = projectRoot.resolve("build"),
|
rootProjectBuildDir = projectRoot.resolve("build"),
|
||||||
dirToModule = mapOf(appKotlinDestination to appEntry, libKotlinDestination to libEntry),
|
dirToModule = mapOf(appKotlinDestination to appEntry, libKotlinDestination to libEntry),
|
||||||
nameToModules = mapOf("app" to setOf(appEntry), "lib" to setOf(libEntry)),
|
nameToModules = mapOf("app" to setOf(appEntry), "lib" to setOf(libEntry)),
|
||||||
@@ -68,7 +67,7 @@ class ModulesApiHistoryAndroidTest {
|
|||||||
jarToAbiSnapshot = mapOf()
|
jarToAbiSnapshot = mapOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
androidHistory = ModulesApiHistoryAndroid(info)
|
androidHistory = ModulesApiHistoryAndroid(projectRoot, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
-1
@@ -397,7 +397,6 @@ internal open class GradleCompilerRunner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return IncrementalModuleInfo(
|
return IncrementalModuleInfo(
|
||||||
projectRoot = gradle.rootProject.projectDir,
|
|
||||||
rootProjectBuildDir = gradle.rootProject.buildDir,
|
rootProjectBuildDir = gradle.rootProject.buildDir,
|
||||||
dirToModule = dirToModule,
|
dirToModule = dirToModule,
|
||||||
nameToModules = nameToModules,
|
nameToModules = nameToModules,
|
||||||
|
|||||||
+1
@@ -330,6 +330,7 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
outputFiles = outputFiles,
|
outputFiles = outputFiles,
|
||||||
multiModuleICSettings = icEnv.multiModuleICSettings,
|
multiModuleICSettings = icEnv.multiModuleICSettings,
|
||||||
modulesInfo = incrementalModuleInfo!!,
|
modulesInfo = incrementalModuleInfo!!,
|
||||||
|
rootProjectDir = icEnv.rootProjectDir,
|
||||||
kotlinScriptExtensions = kotlinScriptExtensions,
|
kotlinScriptExtensions = kotlinScriptExtensions,
|
||||||
withAbiSnapshot = icEnv.withAbiSnapshot,
|
withAbiSnapshot = icEnv.withAbiSnapshot,
|
||||||
preciseCompilationResultsBackup = icEnv.preciseCompilationResultsBackup,
|
preciseCompilationResultsBackup = icEnv.preciseCompilationResultsBackup,
|
||||||
|
|||||||
+1
@@ -15,6 +15,7 @@ internal class IncrementalCompilationEnvironment(
|
|||||||
val changedFiles: ChangedFiles,
|
val changedFiles: ChangedFiles,
|
||||||
val classpathChanges: ClasspathChanges,
|
val classpathChanges: ClasspathChanges,
|
||||||
val workingDir: File,
|
val workingDir: File,
|
||||||
|
val rootProjectDir: File,
|
||||||
val usePreciseJavaTracking: Boolean = false,
|
val usePreciseJavaTracking: Boolean = false,
|
||||||
val disableMultiModuleIC: Boolean = false,
|
val disableMultiModuleIC: Boolean = false,
|
||||||
val multiModuleICSettings: MultiModuleICSettings,
|
val multiModuleICSettings: MultiModuleICSettings,
|
||||||
|
|||||||
+1
@@ -328,6 +328,7 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
getChangedFiles(inputChanges, incrementalProps),
|
getChangedFiles(inputChanges, incrementalProps),
|
||||||
ClasspathChanges.NotAvailableForJSCompiler,
|
ClasspathChanges.NotAvailableForJSCompiler,
|
||||||
taskBuildCacheableOutputDirectory.get().asFile,
|
taskBuildCacheableOutputDirectory.get().asFile,
|
||||||
|
projectRootDir,
|
||||||
multiModuleICSettings = multiModuleICSettings,
|
multiModuleICSettings = multiModuleICSettings,
|
||||||
preciseCompilationResultsBackup = preciseCompilationResultsBackup.get(),
|
preciseCompilationResultsBackup = preciseCompilationResultsBackup.get(),
|
||||||
keepIncrementalCompilationCachesInMemory = keepIncrementalCompilationCachesInMemory.get(),
|
keepIncrementalCompilationCachesInMemory = keepIncrementalCompilationCachesInMemory.get(),
|
||||||
|
|||||||
+3
@@ -302,6 +302,8 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val projectRootDir = project.rootDir
|
||||||
|
|
||||||
override fun callCompilerAsync(
|
override fun callCompilerAsync(
|
||||||
args: K2JVMCompilerArguments,
|
args: K2JVMCompilerArguments,
|
||||||
inputChanges: InputChanges,
|
inputChanges: InputChanges,
|
||||||
@@ -323,6 +325,7 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
changedFiles = getChangedFiles(inputChanges, incrementalProps),
|
changedFiles = getChangedFiles(inputChanges, incrementalProps),
|
||||||
classpathChanges = getClasspathChanges(inputChanges),
|
classpathChanges = getClasspathChanges(inputChanges),
|
||||||
workingDir = taskBuildCacheableOutputDirectory.get().asFile,
|
workingDir = taskBuildCacheableOutputDirectory.get().asFile,
|
||||||
|
rootProjectDir = projectRootDir,
|
||||||
usePreciseJavaTracking = usePreciseJavaTracking,
|
usePreciseJavaTracking = usePreciseJavaTracking,
|
||||||
disableMultiModuleIC = disableMultiModuleIC,
|
disableMultiModuleIC = disableMultiModuleIC,
|
||||||
multiModuleICSettings = multiModuleICSettings,
|
multiModuleICSettings = multiModuleICSettings,
|
||||||
|
|||||||
Reference in New Issue
Block a user