Don't use global state for keeping incremental compilation state
Previously IC state was stored in System properties. As result parallel compilation might cause incorrect state of IC, what led to corruption of kotlin_module files. Now IC state is stored via CompilerArguments and CompilerConfiguration #KT-46038 Fixed
This commit is contained in:
@@ -47,7 +47,8 @@ fun makeModuleFile(
|
||||
commonSources: Iterable<File>,
|
||||
javaSourceRoots: Iterable<JvmSourceRoot>,
|
||||
classpath: Iterable<File>,
|
||||
friendDirs: Iterable<File>
|
||||
friendDirs: Iterable<File>,
|
||||
isIncrementalMode: Boolean = true
|
||||
): File {
|
||||
val builder = KotlinModuleXmlBuilder()
|
||||
builder.addModule(
|
||||
@@ -65,7 +66,8 @@ fun makeModuleFile(
|
||||
isTest,
|
||||
// this excludes the output directories from the class path, to be removed for true incremental compilation
|
||||
setOf(outputDir),
|
||||
friendDirs
|
||||
friendDirs,
|
||||
isIncrementalMode
|
||||
)
|
||||
|
||||
val scriptFile = Files.createTempFile("kjps", sanitizeJavaIdentifier(name) + ".script.xml").toFile()
|
||||
|
||||
@@ -31,6 +31,7 @@ class KotlinModuleXmlBuilder {
|
||||
openTag(p, MODULES)
|
||||
}
|
||||
|
||||
@Deprecated(message = "State of IC should be set explicitly")
|
||||
fun addModule(
|
||||
moduleName: String,
|
||||
outputDir: String,
|
||||
@@ -43,6 +44,34 @@ class KotlinModuleXmlBuilder {
|
||||
isTests: Boolean,
|
||||
directoriesToFilterOut: Set<File>,
|
||||
friendDirs: Iterable<File>
|
||||
) = addModule(
|
||||
moduleName,
|
||||
outputDir,
|
||||
sourceFiles,
|
||||
javaSourceRoots,
|
||||
classpathRoots,
|
||||
commonSourceFiles,
|
||||
modularJdkRoot,
|
||||
targetTypeId,
|
||||
isTests,
|
||||
directoriesToFilterOut,
|
||||
friendDirs,
|
||||
IncrementalCompilation.isEnabledForJvm()
|
||||
)
|
||||
|
||||
fun addModule(
|
||||
moduleName: String,
|
||||
outputDir: String,
|
||||
sourceFiles: Iterable<File>,
|
||||
javaSourceRoots: Iterable<JvmSourceRoot>,
|
||||
classpathRoots: Iterable<File>,
|
||||
commonSourceFiles: Iterable<File>,
|
||||
modularJdkRoot: File?,
|
||||
targetTypeId: String,
|
||||
isTests: Boolean,
|
||||
directoriesToFilterOut: Set<File>,
|
||||
friendDirs: Iterable<File>,
|
||||
isIncrementalCompilation: Boolean
|
||||
): KotlinModuleXmlBuilder {
|
||||
assert(!done) { "Already done" }
|
||||
|
||||
@@ -67,7 +96,7 @@ class KotlinModuleXmlBuilder {
|
||||
}
|
||||
|
||||
processJavaSourceRoots(javaSourceRoots)
|
||||
processClasspath(classpathRoots, directoriesToFilterOut)
|
||||
processClasspath(classpathRoots, directoriesToFilterOut, isIncrementalCompilation)
|
||||
|
||||
if (modularJdkRoot != null) {
|
||||
p.println("<", MODULAR_JDK_ROOT, " ", PATH, "=\"", getEscapedPath(modularJdkRoot), "\"/>")
|
||||
@@ -79,10 +108,11 @@ class KotlinModuleXmlBuilder {
|
||||
|
||||
private fun processClasspath(
|
||||
files: Iterable<File>,
|
||||
directoriesToFilterOut: Set<File>) {
|
||||
directoriesToFilterOut: Set<File>,
|
||||
isIncrementalCompilation: Boolean) {
|
||||
p.println("<!-- Classpath -->")
|
||||
for (file in files) {
|
||||
val isOutput = directoriesToFilterOut.contains(file) && !IncrementalCompilation.isEnabledForJvm()
|
||||
val isOutput = directoriesToFilterOut.contains(file) && !isIncrementalCompilation
|
||||
if (isOutput) {
|
||||
// For IDEA's make (incremental compilation) purposes, output directories of the current module and its dependencies
|
||||
// appear on the class path, so we are at risk of seeing the results of the previous build, i.e. if some class was
|
||||
|
||||
Reference in New Issue
Block a user