jps: checkCachesVersions for js and common (BuildMetaInfo save/check)
This commit is contained in:
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.build
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
|
import org.jetbrains.kotlin.config.isPreRelease
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
interface BuildMetaInfo {
|
||||||
|
val isEAP: Boolean
|
||||||
|
val compilerBuildVersion: String
|
||||||
|
val languageVersionString: String
|
||||||
|
val apiVersionString: String
|
||||||
|
val coroutinesEnable: Boolean
|
||||||
|
val coroutinesWarn: Boolean
|
||||||
|
val coroutinesError: Boolean
|
||||||
|
val multiplatformEnable: Boolean
|
||||||
|
val metadataVersionMajor: Int
|
||||||
|
val metadataVersionMinor: Int
|
||||||
|
val metadataVersionPatch: Int
|
||||||
|
val ownVersion: Int
|
||||||
|
val coroutinesVersion: Int
|
||||||
|
val multiplatformVersion: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class BuildMetaInfoFactory<T : BuildMetaInfo>(private val metaInfoClass: KClass<T>) {
|
||||||
|
protected abstract fun create(
|
||||||
|
isEAP: Boolean,
|
||||||
|
compilerBuildVersion: String,
|
||||||
|
languageVersionString: String,
|
||||||
|
apiVersionString: String,
|
||||||
|
coroutinesEnable: Boolean,
|
||||||
|
coroutinesWarn: Boolean,
|
||||||
|
coroutinesError: Boolean,
|
||||||
|
multiplatformEnable: Boolean,
|
||||||
|
ownVersion: Int,
|
||||||
|
coroutinesVersion: Int,
|
||||||
|
multiplatformVersion: Int
|
||||||
|
): T
|
||||||
|
|
||||||
|
fun create(args: CommonCompilerArguments): T {
|
||||||
|
val languageVersion = args.languageVersion?.let((LanguageVersion)::fromVersionString) ?: LanguageVersion.LATEST_STABLE
|
||||||
|
|
||||||
|
return create(
|
||||||
|
isEAP = languageVersion.isPreRelease(),
|
||||||
|
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
||||||
|
languageVersionString = languageVersion.versionString,
|
||||||
|
apiVersionString = args.apiVersion ?: languageVersion.versionString,
|
||||||
|
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
|
||||||
|
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
|
||||||
|
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
|
||||||
|
multiplatformEnable = args.multiPlatform,
|
||||||
|
ownVersion = OWN_VERSION,
|
||||||
|
coroutinesVersion = COROUTINES_VERSION,
|
||||||
|
multiplatformVersion = MULTIPLATFORM_VERSION
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun serializeToString(info: T): String =
|
||||||
|
serializeToPlainText(info, metaInfoClass)
|
||||||
|
|
||||||
|
fun deserializeFromString(str: String): T? =
|
||||||
|
deserializeFromPlainText(str, metaInfoClass)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val OWN_VERSION: Int = 0
|
||||||
|
const val COROUTINES_VERSION: Int = 0
|
||||||
|
const val MULTIPLATFORM_VERSION: Int = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.build
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||||
|
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you want to add a new field, check its type is supported by [serializeToPlainText], [deserializeFromPlainText]
|
||||||
|
*/
|
||||||
|
data class CommonBuildMetaInfo(
|
||||||
|
override val isEAP: Boolean,
|
||||||
|
override val compilerBuildVersion: String,
|
||||||
|
override val languageVersionString: String,
|
||||||
|
override val apiVersionString: String,
|
||||||
|
override val coroutinesEnable: Boolean,
|
||||||
|
override val coroutinesWarn: Boolean,
|
||||||
|
override val coroutinesError: Boolean,
|
||||||
|
override val multiplatformEnable: Boolean,
|
||||||
|
override val metadataVersionMajor: Int,
|
||||||
|
override val metadataVersionMinor: Int,
|
||||||
|
override val metadataVersionPatch: Int,
|
||||||
|
override val ownVersion: Int,
|
||||||
|
override val coroutinesVersion: Int,
|
||||||
|
override val multiplatformVersion: Int
|
||||||
|
) : BuildMetaInfo {
|
||||||
|
companion object : BuildMetaInfoFactory<CommonBuildMetaInfo>(CommonBuildMetaInfo::class) {
|
||||||
|
override fun create(
|
||||||
|
isEAP: Boolean,
|
||||||
|
compilerBuildVersion: String,
|
||||||
|
languageVersionString: String,
|
||||||
|
apiVersionString: String,
|
||||||
|
coroutinesEnable: Boolean,
|
||||||
|
coroutinesWarn: Boolean,
|
||||||
|
coroutinesError: Boolean,
|
||||||
|
multiplatformEnable: Boolean,
|
||||||
|
ownVersion: Int,
|
||||||
|
coroutinesVersion: Int,
|
||||||
|
multiplatformVersion: Int
|
||||||
|
) = CommonBuildMetaInfo(
|
||||||
|
isEAP = isEAP,
|
||||||
|
compilerBuildVersion = compilerBuildVersion,
|
||||||
|
languageVersionString = languageVersionString,
|
||||||
|
apiVersionString = apiVersionString,
|
||||||
|
coroutinesEnable = coroutinesEnable,
|
||||||
|
coroutinesWarn = coroutinesWarn,
|
||||||
|
coroutinesError = coroutinesError,
|
||||||
|
multiplatformEnable = multiplatformEnable,
|
||||||
|
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
||||||
|
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
||||||
|
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
||||||
|
ownVersion = ownVersion,
|
||||||
|
coroutinesVersion = coroutinesVersion,
|
||||||
|
multiplatformVersion = multiplatformVersion
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.build
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you want to add a new field, check its type is supported by [serializeToPlainText], [deserializeFromPlainText]
|
||||||
|
*/
|
||||||
|
data class JsBuildMetaInfo(
|
||||||
|
override val isEAP: Boolean,
|
||||||
|
override val compilerBuildVersion: String,
|
||||||
|
override val languageVersionString: String,
|
||||||
|
override val apiVersionString: String,
|
||||||
|
override val coroutinesEnable: Boolean,
|
||||||
|
override val coroutinesWarn: Boolean,
|
||||||
|
override val coroutinesError: Boolean,
|
||||||
|
override val multiplatformEnable: Boolean,
|
||||||
|
override val metadataVersionMajor: Int,
|
||||||
|
override val metadataVersionMinor: Int,
|
||||||
|
override val metadataVersionPatch: Int,
|
||||||
|
override val ownVersion: Int,
|
||||||
|
override val coroutinesVersion: Int,
|
||||||
|
override val multiplatformVersion: Int
|
||||||
|
) : BuildMetaInfo {
|
||||||
|
companion object : BuildMetaInfoFactory<JsBuildMetaInfo>(JsBuildMetaInfo::class) {
|
||||||
|
override fun create(
|
||||||
|
isEAP: Boolean,
|
||||||
|
compilerBuildVersion: String,
|
||||||
|
languageVersionString: String,
|
||||||
|
apiVersionString: String,
|
||||||
|
coroutinesEnable: Boolean,
|
||||||
|
coroutinesWarn: Boolean,
|
||||||
|
coroutinesError: Boolean,
|
||||||
|
multiplatformEnable: Boolean,
|
||||||
|
ownVersion: Int,
|
||||||
|
coroutinesVersion: Int,
|
||||||
|
multiplatformVersion: Int
|
||||||
|
) = JsBuildMetaInfo(
|
||||||
|
isEAP = isEAP,
|
||||||
|
compilerBuildVersion = compilerBuildVersion,
|
||||||
|
languageVersionString = languageVersionString,
|
||||||
|
apiVersionString = apiVersionString,
|
||||||
|
coroutinesEnable = coroutinesEnable,
|
||||||
|
coroutinesWarn = coroutinesWarn,
|
||||||
|
coroutinesError = coroutinesError,
|
||||||
|
multiplatformEnable = multiplatformEnable,
|
||||||
|
metadataVersionMajor = JsMetadataVersion.INSTANCE.major,
|
||||||
|
metadataVersionMinor = JsMetadataVersion.INSTANCE.minor,
|
||||||
|
metadataVersionPatch = JsMetadataVersion.INSTANCE.patch,
|
||||||
|
ownVersion = ownVersion,
|
||||||
|
coroutinesVersion = coroutinesVersion,
|
||||||
|
multiplatformVersion = multiplatformVersion
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.build
|
package org.jetbrains.kotlin.build
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
|
||||||
import org.jetbrains.kotlin.config.LanguageVersion
|
|
||||||
import org.jetbrains.kotlin.config.isPreRelease
|
|
||||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmBytecodeBinaryVersion
|
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmBytecodeBinaryVersion
|
||||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||||
|
|
||||||
@@ -27,54 +23,55 @@ import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
|||||||
* If you want to add a new field, check its type is supported by [serializeToPlainText], [deserializeFromPlainText]
|
* If you want to add a new field, check its type is supported by [serializeToPlainText], [deserializeFromPlainText]
|
||||||
*/
|
*/
|
||||||
data class JvmBuildMetaInfo(
|
data class JvmBuildMetaInfo(
|
||||||
val isEAP: Boolean,
|
override val isEAP: Boolean,
|
||||||
val compilerBuildVersion: String,
|
override val compilerBuildVersion: String,
|
||||||
val languageVersionString: String,
|
override val languageVersionString: String,
|
||||||
val apiVersionString: String,
|
override val apiVersionString: String,
|
||||||
val coroutinesEnable: Boolean,
|
override val coroutinesEnable: Boolean,
|
||||||
val coroutinesWarn: Boolean,
|
override val coroutinesWarn: Boolean,
|
||||||
val coroutinesError: Boolean,
|
override val coroutinesError: Boolean,
|
||||||
val multiplatformEnable: Boolean,
|
override val multiplatformEnable: Boolean,
|
||||||
val metadataVersionMajor: Int,
|
override val metadataVersionMajor: Int,
|
||||||
val metadataVersionMinor: Int,
|
override val metadataVersionMinor: Int,
|
||||||
val metadataVersionPatch: Int,
|
override val metadataVersionPatch: Int,
|
||||||
val bytecodeVersionMajor: Int,
|
val bytecodeVersionMajor: Int,
|
||||||
val bytecodeVersionMinor: Int,
|
val bytecodeVersionMinor: Int,
|
||||||
val bytecodeVersionPatch: Int,
|
val bytecodeVersionPatch: Int,
|
||||||
val ownVersion: Int = JvmBuildMetaInfo.OWN_VERSION,
|
override val ownVersion: Int,
|
||||||
val coroutinesVersion: Int = JvmBuildMetaInfo.COROUTINES_VERSION,
|
override val coroutinesVersion: Int,
|
||||||
val multiplatformVersion: Int = JvmBuildMetaInfo.MULTIPLATFORM_VERSION
|
override val multiplatformVersion: Int
|
||||||
) {
|
) : BuildMetaInfo {
|
||||||
companion object {
|
companion object : BuildMetaInfoFactory<JvmBuildMetaInfo>(JvmBuildMetaInfo::class) {
|
||||||
const val OWN_VERSION: Int = 0
|
override fun create(
|
||||||
const val COROUTINES_VERSION: Int = 0
|
isEAP: Boolean,
|
||||||
const val MULTIPLATFORM_VERSION: Int = 0
|
compilerBuildVersion: String,
|
||||||
|
languageVersionString: String,
|
||||||
fun serializeToString(info: JvmBuildMetaInfo): String =
|
apiVersionString: String,
|
||||||
serializeToPlainText(info)
|
coroutinesEnable: Boolean,
|
||||||
|
coroutinesWarn: Boolean,
|
||||||
fun deserializeFromString(str: String): JvmBuildMetaInfo? =
|
coroutinesError: Boolean,
|
||||||
deserializeFromPlainText(str)
|
multiplatformEnable: Boolean,
|
||||||
}
|
ownVersion: Int,
|
||||||
}
|
coroutinesVersion: Int,
|
||||||
|
multiplatformVersion: Int
|
||||||
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo {
|
) = JvmBuildMetaInfo(
|
||||||
val languageVersion = args.languageVersion?.let((LanguageVersion)::fromVersionString) ?: LanguageVersion.LATEST_STABLE
|
isEAP = isEAP,
|
||||||
|
compilerBuildVersion = compilerBuildVersion,
|
||||||
return JvmBuildMetaInfo(
|
languageVersionString = languageVersionString,
|
||||||
isEAP = languageVersion.isPreRelease(),
|
apiVersionString = apiVersionString,
|
||||||
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
coroutinesEnable = coroutinesEnable,
|
||||||
languageVersionString = languageVersion.versionString,
|
coroutinesWarn = coroutinesWarn,
|
||||||
apiVersionString = args.apiVersion ?: languageVersion.versionString,
|
coroutinesError = coroutinesError,
|
||||||
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
|
multiplatformEnable = multiplatformEnable,
|
||||||
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
|
|
||||||
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
|
|
||||||
multiplatformEnable = args.multiPlatform,
|
|
||||||
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
||||||
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
||||||
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
||||||
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
|
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
|
||||||
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
|
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
|
||||||
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch
|
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch,
|
||||||
)
|
ownVersion = ownVersion,
|
||||||
|
coroutinesVersion = coroutinesVersion,
|
||||||
|
multiplatformVersion = multiplatformVersion
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-25
@@ -22,52 +22,61 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
|||||||
import org.junit.Assert.assertNotEquals
|
import org.junit.Assert.assertNotEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class JvmBuildMetaInfoTest : TestCase() {
|
class BuildMetaInfoTest : TestCase() {
|
||||||
@Test
|
@Test
|
||||||
fun testSerialization() {
|
fun testJvmSerialization() {
|
||||||
val args = K2JVMCompilerArguments()
|
val args = K2JVMCompilerArguments()
|
||||||
val info = JvmBuildMetaInfo(args)
|
val info = JvmBuildMetaInfo.create(args)
|
||||||
val actual = JvmBuildMetaInfo.serializeToString(info)
|
val actual = JvmBuildMetaInfo.serializeToString(info)
|
||||||
val expectedKeys = listOf(
|
val expectedKeys = listOf(
|
||||||
"apiVersionString",
|
"apiVersionString",
|
||||||
"bytecodeVersionMajor",
|
"bytecodeVersionMajor",
|
||||||
"bytecodeVersionMinor",
|
"bytecodeVersionMinor",
|
||||||
"bytecodeVersionPatch",
|
"bytecodeVersionPatch",
|
||||||
"compilerBuildVersion",
|
"compilerBuildVersion",
|
||||||
"coroutinesEnable",
|
"coroutinesEnable",
|
||||||
"coroutinesError",
|
"coroutinesError",
|
||||||
"coroutinesVersion",
|
"coroutinesVersion",
|
||||||
"coroutinesWarn",
|
"coroutinesWarn",
|
||||||
"isEAP",
|
"isEAP",
|
||||||
"languageVersionString",
|
"languageVersionString",
|
||||||
"metadataVersionMajor",
|
"metadataVersionMajor",
|
||||||
"metadataVersionMinor",
|
"metadataVersionMinor",
|
||||||
"metadataVersionPatch",
|
"metadataVersionPatch",
|
||||||
"multiplatformEnable",
|
"multiplatformEnable",
|
||||||
"multiplatformVersion",
|
"multiplatformVersion",
|
||||||
"ownVersion"
|
"ownVersion"
|
||||||
)
|
)
|
||||||
assertEquals(expectedKeys, actual.split("\r\n", "\n").map { line -> line.split("=").first() })
|
assertEquals(expectedKeys, actual.split("\r\n", "\n").map { line -> line.split("=").first() })
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSerializationDeserialization() {
|
fun testJvmSerializationDeserialization() {
|
||||||
val args = K2JVMCompilerArguments()
|
val args = K2JVMCompilerArguments()
|
||||||
val info = JvmBuildMetaInfo(args)
|
val info = JvmBuildMetaInfo.create(args)
|
||||||
val serialized = JvmBuildMetaInfo.serializeToString(info)
|
val serialized = JvmBuildMetaInfo.serializeToString(info)
|
||||||
val deserialized = JvmBuildMetaInfo.deserializeFromString(serialized)
|
val deserialized = JvmBuildMetaInfo.deserializeFromString(serialized)
|
||||||
assertEquals(info, deserialized)
|
assertEquals(info, deserialized)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testEquals() {
|
fun testJsSerializationDeserialization() {
|
||||||
|
val args = K2JVMCompilerArguments()
|
||||||
|
val info = JvmBuildMetaInfo.create(args)
|
||||||
|
val serialized = JvmBuildMetaInfo.serializeToString(info)
|
||||||
|
val deserialized = JvmBuildMetaInfo.deserializeFromString(serialized)
|
||||||
|
assertEquals(info, deserialized)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testJvmEquals() {
|
||||||
val args1 = K2JVMCompilerArguments()
|
val args1 = K2JVMCompilerArguments()
|
||||||
args1.coroutinesState = CommonCompilerArguments.ENABLE
|
args1.coroutinesState = CommonCompilerArguments.ENABLE
|
||||||
val info1 = JvmBuildMetaInfo(args1)
|
val info1 = JvmBuildMetaInfo.create(args1)
|
||||||
|
|
||||||
val args2 = K2JVMCompilerArguments()
|
val args2 = K2JVMCompilerArguments()
|
||||||
args2.coroutinesState = CommonCompilerArguments.WARN
|
args2.coroutinesState = CommonCompilerArguments.WARN
|
||||||
val info2 = JvmBuildMetaInfo(args2)
|
val info2 = JvmBuildMetaInfo.create(args2)
|
||||||
|
|
||||||
assertNotEquals(info1, info2)
|
assertNotEquals(info1, info2)
|
||||||
assertEquals(info1, info2.copy(coroutinesEnable = true, coroutinesWarn = false))
|
assertEquals(info1, info2.copy(coroutinesEnable = true, coroutinesWarn = false))
|
||||||
+9
-3
@@ -18,15 +18,17 @@ package org.jetbrains.kotlin.jps.build
|
|||||||
|
|
||||||
import com.intellij.testFramework.UsefulTestCase
|
import com.intellij.testFramework.UsefulTestCase
|
||||||
import org.jetbrains.jps.builders.BuildTarget
|
import org.jetbrains.jps.builders.BuildTarget
|
||||||
|
import org.jetbrains.jps.builders.CompileScopeTestBuilder
|
||||||
import org.jetbrains.jps.builders.storage.BuildDataPaths
|
import org.jetbrains.jps.builders.storage.BuildDataPaths
|
||||||
|
import org.jetbrains.jps.incremental.CompileContextImpl
|
||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
|
||||||
import org.jetbrains.kotlin.incremental.KOTLIN_CACHE_DIRECTORY_NAME
|
import org.jetbrains.kotlin.incremental.KOTLIN_CACHE_DIRECTORY_NAME
|
||||||
import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
|
import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
|
||||||
import org.jetbrains.kotlin.incremental.testingUtils.Modification
|
import org.jetbrains.kotlin.incremental.testingUtils.Modification
|
||||||
import org.jetbrains.kotlin.incremental.testingUtils.ModifyContent
|
import org.jetbrains.kotlin.incremental.testingUtils.ModifyContent
|
||||||
import org.jetbrains.kotlin.jps.incremental.CacheVersionProvider
|
import org.jetbrains.kotlin.jps.incremental.CacheVersionProvider
|
||||||
import org.jetbrains.kotlin.jps.incremental.KotlinDataContainerTarget
|
import org.jetbrains.kotlin.jps.incremental.KotlinDataContainerTarget
|
||||||
|
import org.jetbrains.kotlin.jps.platforms.kotlinBuildTargets
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -91,11 +93,15 @@ abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest()
|
|||||||
|
|
||||||
dumpCachesForTarget(p, paths, KotlinDataContainerTarget, versions.dataContainerVersion().formatVersionFile)
|
dumpCachesForTarget(p, paths, KotlinDataContainerTarget, versions.dataContainerVersion().formatVersionFile)
|
||||||
|
|
||||||
|
// for getting kotlin platform only
|
||||||
|
val dummyCompileContext = CompileContextImpl.createContextForTests(CompileScopeTestBuilder.make().build(), projectDescriptor)
|
||||||
|
|
||||||
for (target in targets.sortedBy { it.presentableName }) {
|
for (target in targets.sortedBy { it.presentableName }) {
|
||||||
val jvmMetaBuildInfo = jvmBuildMetaInfoFile(target, dataManager)
|
val kotlinModuleBuildTarget = dummyCompileContext.kotlinBuildTargets[target]!!
|
||||||
|
val metaBuildInfo = kotlinModuleBuildTarget.buildMetaInfoFile(target, dataManager)
|
||||||
dumpCachesForTarget(p, paths, target,
|
dumpCachesForTarget(p, paths, target,
|
||||||
versions.normalVersion(target).formatVersionFile,
|
versions.normalVersion(target).formatVersionFile,
|
||||||
jvmMetaBuildInfo,
|
metaBuildInfo,
|
||||||
subdirectory = KOTLIN_CACHE_DIRECTORY_NAME)
|
subdirectory = KOTLIN_CACHE_DIRECTORY_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ data class DependenciesTxt(
|
|||||||
var index: Int = -1
|
var index: Int = -1
|
||||||
|
|
||||||
val indexedName
|
val indexedName
|
||||||
get() = "${index / 10}${index % 10}_$name"
|
get() = "${index.toString().padStart(2, '0')}_$name"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Facet should not be created for old tests
|
* Facet should not be created for old tests
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
const val KOTLIN_BUILDER_NAME: String = "Kotlin Builder"
|
const val KOTLIN_BUILDER_NAME: String = "Kotlin Builder"
|
||||||
|
|
||||||
val LOG = Logger.getInstance("#org.jetbrains.kotlin.jps.build.KotlinBuilder")
|
val LOG = Logger.getInstance("#org.jetbrains.kotlin.jps.build.KotlinBuilder")
|
||||||
const val JVM_BUILD_META_INFO_FILE_NAME = "jvm-build-meta-info.txt"
|
|
||||||
const val SKIP_CACHE_VERSION_CHECK_PROPERTY = "kotlin.jps.skip.cache.version.check"
|
const val SKIP_CACHE_VERSION_CHECK_PROPERTY = "kotlin.jps.skip.cache.version.check"
|
||||||
const val JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home"
|
const val JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home"
|
||||||
|
|
||||||
@@ -259,7 +258,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
|
|
||||||
private fun doBuild(
|
private fun doBuild(
|
||||||
chunk: ModuleChunk,
|
chunk: ModuleChunk,
|
||||||
representativeTarget: KotlinModuleBuildTarget,
|
representativeTarget: KotlinModuleBuildTarget<*>,
|
||||||
context: CompileContext,
|
context: CompileContext,
|
||||||
kotlinDirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
kotlinDirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
||||||
messageCollector: MessageCollectorAdapter,
|
messageCollector: MessageCollectorAdapter,
|
||||||
@@ -345,7 +344,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
val generatedFiles = getGeneratedFiles(context, chunk, environment.outputItemsCollector)
|
val generatedFiles = getGeneratedFiles(context, chunk, environment.outputItemsCollector)
|
||||||
|
|
||||||
registerOutputItems(outputConsumer, generatedFiles)
|
registerOutputItems(outputConsumer, generatedFiles)
|
||||||
saveVersions(context, chunk, commonArguments)
|
representativeTarget.saveVersions(context, chunk, commonArguments)
|
||||||
|
|
||||||
if (targets.any { hasKotlin[it] == null }) {
|
if (targets.any { hasKotlin[it] == null }) {
|
||||||
fsOperations.markChunk(recursively = false, kotlinOnly = true, excludeFiles = kotlinDirtyFilesHolder.allDirtyFiles)
|
fsOperations.markChunk(recursively = false, kotlinOnly = true, excludeFiles = kotlinDirtyFilesHolder.allDirtyFiles)
|
||||||
@@ -476,26 +475,9 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
dataManager.cleanLookupStorage(LOG)
|
dataManager.cleanLookupStorage(LOG)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveVersions(context: CompileContext, chunk: ModuleChunk, commonArguments: CommonCompilerArguments) {
|
|
||||||
val dataManager = context.projectDescriptor.dataManager
|
|
||||||
val targets = chunk.targets
|
|
||||||
val cacheVersionsProvider = CacheVersionProvider(dataManager.dataPaths)
|
|
||||||
cacheVersionsProvider.allVersions(targets).forEach { it.saveIfNeeded() }
|
|
||||||
|
|
||||||
val isJsModule = context.kotlinBuildTargets[chunk.representativeTarget()] is KotlinJsModuleBuildTarget
|
|
||||||
if (!isJsModule) {
|
|
||||||
val jvmBuildMetaInfo = JvmBuildMetaInfo(commonArguments)
|
|
||||||
val serializedMetaInfo = JvmBuildMetaInfo.serializeToString(jvmBuildMetaInfo)
|
|
||||||
|
|
||||||
for (target in chunk.targets) {
|
|
||||||
jvmBuildMetaInfoFile(target, dataManager).writeText(serializedMetaInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun doCompileModuleChunk(
|
private fun doCompileModuleChunk(
|
||||||
chunk: ModuleChunk,
|
chunk: ModuleChunk,
|
||||||
kotlinTarget: KotlinModuleBuildTarget,
|
kotlinTarget: KotlinModuleBuildTarget<*>,
|
||||||
commonArguments: CommonCompilerArguments,
|
commonArguments: CommonCompilerArguments,
|
||||||
context: CompileContext,
|
context: CompileContext,
|
||||||
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
||||||
@@ -537,15 +519,13 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val isDoneSomething = kotlinTarget.compileModuleChunk(
|
val isDoneSomething = kotlinTarget.compileModuleChunk(chunk, commonArguments, dirtyFilesHolder, environment)
|
||||||
chunk, commonArguments, dirtyFilesHolder, environment
|
|
||||||
)
|
|
||||||
|
|
||||||
return if (isDoneSomething) environment.outputItemsCollector else null
|
return if (isDoneSomething) environment.outputItemsCollector else null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createCompileEnvironment(
|
private fun createCompileEnvironment(
|
||||||
kotlinModuleBuilderTarget: KotlinModuleBuildTarget,
|
kotlinModuleBuilderTarget: KotlinModuleBuildTarget<*>,
|
||||||
incrementalCaches: Map<ModuleBuildTarget, JpsIncrementalCache>,
|
incrementalCaches: Map<ModuleBuildTarget, JpsIncrementalCache>,
|
||||||
lookupTracker: LookupTracker,
|
lookupTracker: LookupTracker,
|
||||||
exceptActualTracer: ExpectActualTracker,
|
exceptActualTracer: ExpectActualTracker,
|
||||||
@@ -753,7 +733,4 @@ fun getDependentTargets(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDependenciesRecursively(module: JpsModule, kind: JpsJavaClasspathKind): Set<JpsModule> =
|
private fun getDependenciesRecursively(module: JpsModule, kind: JpsJavaClasspathKind): Set<JpsModule> =
|
||||||
JpsJavaExtensionService.dependencies(module).includedIn(kind).recursivelyExportedOnly().modules
|
JpsJavaExtensionService.dependencies(module).includedIn(kind).recursivelyExportedOnly().modules
|
||||||
|
|
||||||
fun jvmBuildMetaInfoFile(target: ModuleBuildTarget, dataManager: BuildDataManager): File =
|
|
||||||
File(dataManager.dataPaths.getTargetDataRoot(target), KotlinBuilder.JVM_BUILD_META_INFO_FILE_NAME)
|
|
||||||
@@ -17,7 +17,7 @@ import java.io.File
|
|||||||
|
|
||||||
class MessageCollectorAdapter(
|
class MessageCollectorAdapter(
|
||||||
private val context: CompileContext,
|
private val context: CompileContext,
|
||||||
private val kotlinTarget: KotlinModuleBuildTarget?
|
private val kotlinTarget: KotlinModuleBuildTarget<*>?
|
||||||
) : MessageCollector {
|
) : MessageCollector {
|
||||||
private var hasErrors = false
|
private var hasErrors = false
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class JpsIncrementalJsCache(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class KotlinIncrementalStorageProvider(
|
private class KotlinIncrementalStorageProvider(
|
||||||
private val target: KotlinModuleBuildTarget,
|
private val target: KotlinModuleBuildTarget<*>,
|
||||||
private val paths: BuildDataPaths
|
private val paths: BuildDataPaths
|
||||||
) : StorageProvider<JpsIncrementalCache>() {
|
) : StorageProvider<JpsIncrementalCache>() {
|
||||||
init {
|
init {
|
||||||
@@ -73,7 +73,7 @@ private class KotlinIncrementalStorageProvider(
|
|||||||
override fun createStorage(targetDataDir: File): JpsIncrementalCache = target.createCacheStorage(paths)
|
override fun createStorage(targetDataDir: File): JpsIncrementalCache = target.createCacheStorage(paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun BuildDataManager.getKotlinCache(target: KotlinModuleBuildTarget?): JpsIncrementalCache? =
|
fun BuildDataManager.getKotlinCache(target: KotlinModuleBuildTarget<*>?): JpsIncrementalCache? =
|
||||||
if (target == null || !target.hasCaches) null
|
if (target == null || !target.hasCaches) null
|
||||||
else getStorage(target.jpsModuleBuildTarget, KotlinIncrementalStorageProvider(target, dataPaths))
|
else getStorage(target.jpsModuleBuildTarget, KotlinIncrementalStorageProvider(target, dataPaths))
|
||||||
|
|
||||||
|
|||||||
@@ -12,17 +12,25 @@ import org.jetbrains.jps.incremental.ModuleBuildTarget
|
|||||||
import org.jetbrains.jps.model.library.JpsOrderRootType
|
import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||||
import org.jetbrains.jps.model.module.JpsModule
|
import org.jetbrains.jps.model.module.JpsModule
|
||||||
import org.jetbrains.jps.util.JpsPathUtil
|
import org.jetbrains.jps.util.JpsPathUtil
|
||||||
|
import org.jetbrains.kotlin.build.CommonBuildMetaInfo
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
||||||
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalJvmCache
|
|
||||||
import org.jetbrains.kotlin.jps.model.k2MetadataCompilerArguments
|
import org.jetbrains.kotlin.jps.model.k2MetadataCompilerArguments
|
||||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings
|
import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings
|
||||||
|
|
||||||
|
private const val COMMON_BUILD_META_INFO_FILE_NAME = "common-build-meta-info.txt"
|
||||||
|
|
||||||
class KotlinCommonModuleBuildTarget(context: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
class KotlinCommonModuleBuildTarget(context: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
||||||
KotlinModuleBuildTarget(context, jpsModuleBuildTarget) {
|
KotlinModuleBuildTarget<CommonBuildMetaInfo>(context, jpsModuleBuildTarget) {
|
||||||
|
|
||||||
|
override val buildMetaInfoFactory
|
||||||
|
get() = CommonBuildMetaInfo
|
||||||
|
|
||||||
|
override val buildMetaInfoFileName
|
||||||
|
get() = COMMON_BUILD_META_INFO_FILE_NAME
|
||||||
|
|
||||||
override fun compileModuleChunk(
|
override fun compileModuleChunk(
|
||||||
chunk: ModuleChunk,
|
chunk: ModuleChunk,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.jetbrains.jps.model.library.JpsOrderRootType
|
|||||||
import org.jetbrains.jps.model.module.JpsModule
|
import org.jetbrains.jps.model.module.JpsModule
|
||||||
import org.jetbrains.jps.util.JpsPathUtil
|
import org.jetbrains.jps.util.JpsPathUtil
|
||||||
import org.jetbrains.kotlin.build.GeneratedFile
|
import org.jetbrains.kotlin.build.GeneratedFile
|
||||||
|
import org.jetbrains.kotlin.build.JsBuildMetaInfo
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||||
@@ -39,8 +40,16 @@ import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils.META_JS_SUFFIX
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
|
private const val JS_BUILD_META_INFO_FILE_NAME = "js-build-meta-info.txt"
|
||||||
|
|
||||||
class KotlinJsModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
class KotlinJsModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
||||||
KotlinModuleBuildTarget(compileContext, jpsModuleBuildTarget) {
|
KotlinModuleBuildTarget<JsBuildMetaInfo>(compileContext, jpsModuleBuildTarget) {
|
||||||
|
|
||||||
|
override val buildMetaInfoFactory
|
||||||
|
get() = JsBuildMetaInfo
|
||||||
|
|
||||||
|
override val buildMetaInfoFileName: String
|
||||||
|
get() = JS_BUILD_META_INFO_FILE_NAME
|
||||||
|
|
||||||
val isFirstBuild: Boolean
|
val isFirstBuild: Boolean
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import org.jetbrains.jps.builders.java.JavaBuilderUtil
|
|||||||
import org.jetbrains.jps.builders.storage.BuildDataPaths
|
import org.jetbrains.jps.builders.storage.BuildDataPaths
|
||||||
import org.jetbrains.jps.incremental.CompileContext
|
import org.jetbrains.jps.incremental.CompileContext
|
||||||
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||||
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
|
||||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||||
import org.jetbrains.jps.model.module.JpsSdkDependency
|
import org.jetbrains.jps.model.module.JpsSdkDependency
|
||||||
import org.jetbrains.kotlin.build.GeneratedFile
|
import org.jetbrains.kotlin.build.GeneratedFile
|
||||||
@@ -27,15 +26,15 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||||
import org.jetbrains.kotlin.config.ApiVersion
|
|
||||||
import org.jetbrains.kotlin.config.LanguageVersion
|
|
||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
import org.jetbrains.kotlin.incremental.*
|
import org.jetbrains.kotlin.incremental.ChangesCollector
|
||||||
|
import org.jetbrains.kotlin.incremental.IncrementalCompilationComponentsImpl
|
||||||
|
import org.jetbrains.kotlin.incremental.IncrementalJvmCache
|
||||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
|
import org.jetbrains.kotlin.incremental.updateIncrementalCache
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
||||||
import org.jetbrains.kotlin.jps.build.jvmBuildMetaInfoFile
|
|
||||||
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache
|
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache
|
||||||
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalJvmCache
|
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalJvmCache
|
||||||
import org.jetbrains.kotlin.jps.model.k2JvmCompilerArguments
|
import org.jetbrains.kotlin.jps.model.k2JvmCompilerArguments
|
||||||
@@ -49,56 +48,18 @@ import org.jetbrains.org.objectweb.asm.ClassReader
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
private const val JVM_BUILD_META_INFO_FILE_NAME = "jvm-build-meta-info.txt"
|
||||||
|
|
||||||
class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildTarget: ModuleBuildTarget) :
|
||||||
KotlinModuleBuildTarget(compileContext, jpsModuleBuildTarget) {
|
KotlinModuleBuildTarget<JvmBuildMetaInfo>(compileContext, jpsModuleBuildTarget) {
|
||||||
|
|
||||||
override fun createCacheStorage(paths: BuildDataPaths) = JpsIncrementalJvmCache(jpsModuleBuildTarget, paths)
|
override fun createCacheStorage(paths: BuildDataPaths) = JpsIncrementalJvmCache(jpsModuleBuildTarget, paths)
|
||||||
|
|
||||||
override fun checkCachesVersions(chunk: ModuleChunk, dataManager: BuildDataManager, actions: MutableSet<CacheVersion.Action>) {
|
override val buildMetaInfoFactory
|
||||||
val args = compilerArgumentsForChunk(chunk)
|
get() = JvmBuildMetaInfo
|
||||||
val currentBuildMetaInfo = JvmBuildMetaInfo(args)
|
|
||||||
|
|
||||||
for (target in chunk.targets) {
|
override val buildMetaInfoFileName
|
||||||
val file = jvmBuildMetaInfoFile(target, dataManager)
|
get() = JVM_BUILD_META_INFO_FILE_NAME
|
||||||
if (!file.exists()) continue
|
|
||||||
|
|
||||||
val lastBuildMetaInfo =
|
|
||||||
try {
|
|
||||||
JvmBuildMetaInfo.deserializeFromString(file.readText()) ?: continue
|
|
||||||
} catch (e: Exception) {
|
|
||||||
KotlinBuilder.LOG.error("Could not deserialize jvm build meta info", e)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
val lastBuildLangVersion = LanguageVersion.fromVersionString(lastBuildMetaInfo.languageVersionString)
|
|
||||||
val lastBuildApiVersion = ApiVersion.parse(lastBuildMetaInfo.apiVersionString)
|
|
||||||
val currentLangVersion =
|
|
||||||
args.languageVersion?.let { LanguageVersion.fromVersionString(it) } ?: LanguageVersion.LATEST_STABLE
|
|
||||||
val currentApiVersion =
|
|
||||||
args.apiVersion?.let { ApiVersion.parse(it) } ?: ApiVersion.createByLanguageVersion(currentLangVersion)
|
|
||||||
|
|
||||||
val reasonToRebuild = when {
|
|
||||||
currentLangVersion != lastBuildLangVersion -> {
|
|
||||||
"Language version was changed ($lastBuildLangVersion -> $currentLangVersion)"
|
|
||||||
}
|
|
||||||
|
|
||||||
currentApiVersion != lastBuildApiVersion -> {
|
|
||||||
"Api version was changed ($lastBuildApiVersion -> $currentApiVersion)"
|
|
||||||
}
|
|
||||||
|
|
||||||
lastBuildLangVersion != LanguageVersion.KOTLIN_1_0 && lastBuildMetaInfo.isEAP && !currentBuildMetaInfo.isEAP -> {
|
|
||||||
// If EAP->Non-EAP build with IC, then rebuild all kotlin
|
|
||||||
"Last build was compiled with EAP-plugin"
|
|
||||||
}
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reasonToRebuild != null) {
|
|
||||||
KotlinBuilder.LOG.info("$reasonToRebuild. Performing non-incremental rebuild (kotlin only)")
|
|
||||||
actions.add(CacheVersion.Action.REBUILD_ALL_KOTLIN)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun makeServices(
|
override fun makeServices(
|
||||||
builder: Services.Builder,
|
builder: Services.Builder,
|
||||||
@@ -174,7 +135,7 @@ class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildT
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateModuleDescription(chunk: ModuleChunk, dirtyFilesHolder: KotlinDirtySourceFilesHolder): File? {
|
private fun generateModuleDescription(chunk: ModuleChunk, dirtyFilesHolder: KotlinDirtySourceFilesHolder): File? {
|
||||||
val builder = KotlinModuleXmlBuilder()
|
val builder = KotlinModuleXmlBuilder()
|
||||||
|
|
||||||
var hasDirtySources = false
|
var hasDirtySources = false
|
||||||
@@ -241,7 +202,7 @@ class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findClassPathRoots(): Collection<File> {
|
private fun findClassPathRoots(): Collection<File> {
|
||||||
return allDependencies.classes().roots.filter { file ->
|
return allDependencies.classes().roots.filter { file ->
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
val extension = file.extension
|
val extension = file.extension
|
||||||
@@ -256,7 +217,7 @@ class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findModularJdkRoot(): File? {
|
private fun findModularJdkRoot(): File? {
|
||||||
// List of paths to JRE modules in the following format:
|
// List of paths to JRE modules in the following format:
|
||||||
// jrt:///Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home!/java.base
|
// jrt:///Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home!/java.base
|
||||||
val urls = JpsJavaExtensionService.dependencies(module)
|
val urls = JpsJavaExtensionService.dependencies(module)
|
||||||
|
|||||||
@@ -15,18 +15,26 @@ import org.jetbrains.jps.model.java.JpsJavaClasspathKind
|
|||||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||||
import org.jetbrains.jps.model.module.JpsModule
|
import org.jetbrains.jps.model.module.JpsModule
|
||||||
import org.jetbrains.jps.util.JpsPathUtil
|
import org.jetbrains.jps.util.JpsPathUtil
|
||||||
|
import org.jetbrains.kotlin.build.BuildMetaInfo
|
||||||
|
import org.jetbrains.kotlin.build.BuildMetaInfoFactory
|
||||||
import org.jetbrains.kotlin.build.GeneratedFile
|
import org.jetbrains.kotlin.build.GeneratedFile
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||||
|
import org.jetbrains.kotlin.config.ApiVersion
|
||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||||
import org.jetbrains.kotlin.incremental.ChangesCollector
|
import org.jetbrains.kotlin.incremental.ChangesCollector
|
||||||
import org.jetbrains.kotlin.incremental.ExpectActualTrackerImpl
|
import org.jetbrains.kotlin.incremental.ExpectActualTrackerImpl
|
||||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.jps.build.*
|
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||||
|
import org.jetbrains.kotlin.jps.build.KotlinCommonModuleSourceRoot
|
||||||
|
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
||||||
|
import org.jetbrains.kotlin.jps.build.isKotlinSourceFile
|
||||||
|
import org.jetbrains.kotlin.jps.incremental.CacheVersionProvider
|
||||||
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache
|
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache
|
||||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments
|
import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments
|
||||||
import org.jetbrains.kotlin.jps.model.productionOutputFilePath
|
import org.jetbrains.kotlin.jps.model.productionOutputFilePath
|
||||||
@@ -40,7 +48,10 @@ import java.io.File
|
|||||||
/**
|
/**
|
||||||
* Properties and actions for Kotlin test / production module build target.
|
* Properties and actions for Kotlin test / production module build target.
|
||||||
*/
|
*/
|
||||||
abstract class KotlinModuleBuildTarget(val context: CompileContext, val jpsModuleBuildTarget: ModuleBuildTarget) {
|
abstract class KotlinModuleBuildTarget<BuildMetaInfoType : BuildMetaInfo>(
|
||||||
|
val context: CompileContext,
|
||||||
|
val jpsModuleBuildTarget: ModuleBuildTarget
|
||||||
|
) {
|
||||||
val module: JpsModule
|
val module: JpsModule
|
||||||
get() = jpsModuleBuildTarget.module
|
get() = jpsModuleBuildTarget.module
|
||||||
|
|
||||||
@@ -69,9 +80,9 @@ abstract class KotlinModuleBuildTarget(val context: CompileContext, val jpsModul
|
|||||||
?: throw ProjectBuildException("No output directory found for " + this)
|
?: throw ProjectBuildException("No output directory found for " + this)
|
||||||
}
|
}
|
||||||
|
|
||||||
val friendBuildTargets: List<KotlinModuleBuildTarget>
|
val friendBuildTargets: List<KotlinModuleBuildTarget<*>>
|
||||||
get() {
|
get() {
|
||||||
val result = mutableListOf<KotlinModuleBuildTarget>()
|
val result = mutableListOf<KotlinModuleBuildTarget<*>>()
|
||||||
|
|
||||||
if (isTests) {
|
if (isTests) {
|
||||||
result.addIfNotNull(context.kotlinBuildTargets[module.productionBuildTarget])
|
result.addIfNotNull(context.kotlinBuildTargets[module.productionBuildTarget])
|
||||||
@@ -224,7 +235,7 @@ abstract class KotlinModuleBuildTarget(val context: CompileContext, val jpsModul
|
|||||||
* Should be used only for particular target in chunk (jvm)
|
* Should be used only for particular target in chunk (jvm)
|
||||||
*/
|
*/
|
||||||
protected fun collectSourcesToCompile(
|
protected fun collectSourcesToCompile(
|
||||||
target: KotlinModuleBuildTarget,
|
target: KotlinModuleBuildTarget<BuildMetaInfoType>,
|
||||||
dirtyFilesHolder: KotlinDirtySourceFilesHolder
|
dirtyFilesHolder: KotlinDirtySourceFilesHolder
|
||||||
): Collection<File> {
|
): Collection<File> {
|
||||||
// Should not be cached since may be vary in different rounds
|
// Should not be cached since may be vary in different rounds
|
||||||
@@ -241,7 +252,7 @@ abstract class KotlinModuleBuildTarget(val context: CompileContext, val jpsModul
|
|||||||
* Should be used only for particular target in chunk (jvm)
|
* Should be used only for particular target in chunk (jvm)
|
||||||
*/
|
*/
|
||||||
protected fun checkShouldCompileAndLog(
|
protected fun checkShouldCompileAndLog(
|
||||||
target: KotlinModuleBuildTarget,
|
target: KotlinModuleBuildTarget<BuildMetaInfoType>,
|
||||||
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
||||||
moduleSources: Collection<File>
|
moduleSources: Collection<File>
|
||||||
): Boolean {
|
): Boolean {
|
||||||
@@ -257,7 +268,70 @@ abstract class KotlinModuleBuildTarget(val context: CompileContext, val jpsModul
|
|||||||
return hasDirtyOrRemovedSources
|
return hasDirtyOrRemovedSources
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun checkCachesVersions(chunk: ModuleChunk, dataManager: BuildDataManager, actions: MutableSet<CacheVersion.Action>) {
|
abstract val buildMetaInfoFactory: BuildMetaInfoFactory<BuildMetaInfoType>
|
||||||
|
|
||||||
|
abstract val buildMetaInfoFileName: String
|
||||||
|
|
||||||
|
fun buildMetaInfoFile(target: ModuleBuildTarget, dataManager: BuildDataManager): File =
|
||||||
|
File(dataManager.dataPaths.getTargetDataRoot(target), buildMetaInfoFileName)
|
||||||
|
|
||||||
|
fun saveVersions(context: CompileContext, chunk: ModuleChunk, commonArguments: CommonCompilerArguments) {
|
||||||
|
val dataManager = context.projectDescriptor.dataManager
|
||||||
|
val targets = chunk.targets
|
||||||
|
val cacheVersionsProvider = CacheVersionProvider(dataManager.dataPaths)
|
||||||
|
cacheVersionsProvider.allVersions(targets).forEach { it.saveIfNeeded() }
|
||||||
|
|
||||||
|
val buildMetaInfo = buildMetaInfoFactory.create(commonArguments)
|
||||||
|
val serializedMetaInfo = buildMetaInfoFactory.serializeToString(buildMetaInfo)
|
||||||
|
|
||||||
|
for (target in chunk.targets) {
|
||||||
|
buildMetaInfoFile(target, dataManager).writeText(serializedMetaInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkCachesVersions(chunk: ModuleChunk, dataManager: BuildDataManager, actions: MutableSet<CacheVersion.Action>) {
|
||||||
|
val args = compilerArgumentsForChunk(chunk)
|
||||||
|
val currentBuildMetaInfo = buildMetaInfoFactory.create(args)
|
||||||
|
|
||||||
|
for (target in chunk.targets) {
|
||||||
|
val file = buildMetaInfoFile(target, dataManager)
|
||||||
|
if (!file.exists()) continue
|
||||||
|
|
||||||
|
val lastBuildMetaInfo =
|
||||||
|
try {
|
||||||
|
buildMetaInfoFactory.deserializeFromString(file.readText()) ?: continue
|
||||||
|
} catch (e: Exception) {
|
||||||
|
KotlinBuilder.LOG.error("Could not deserialize build meta info", e)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
val lastBuildLangVersion = LanguageVersion.fromVersionString(lastBuildMetaInfo.languageVersionString)
|
||||||
|
val lastBuildApiVersion = ApiVersion.parse(lastBuildMetaInfo.apiVersionString)
|
||||||
|
val currentLangVersion =
|
||||||
|
args.languageVersion?.let { LanguageVersion.fromVersionString(it) } ?: LanguageVersion.LATEST_STABLE
|
||||||
|
val currentApiVersion =
|
||||||
|
args.apiVersion?.let { ApiVersion.parse(it) } ?: ApiVersion.createByLanguageVersion(currentLangVersion)
|
||||||
|
|
||||||
|
val reasonToRebuild = when {
|
||||||
|
currentLangVersion != lastBuildLangVersion -> {
|
||||||
|
"Language version was changed ($lastBuildLangVersion -> $currentLangVersion)"
|
||||||
|
}
|
||||||
|
|
||||||
|
currentApiVersion != lastBuildApiVersion -> {
|
||||||
|
"Api version was changed ($lastBuildApiVersion -> $currentApiVersion)"
|
||||||
|
}
|
||||||
|
|
||||||
|
lastBuildLangVersion != LanguageVersion.KOTLIN_1_0 && lastBuildMetaInfo.isEAP && !currentBuildMetaInfo.isEAP -> {
|
||||||
|
// If EAP->Non-EAP build with IC, then rebuild all kotlin
|
||||||
|
"Last build was compiled with EAP-plugin"
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reasonToRebuild != null) {
|
||||||
|
KotlinBuilder.LOG.info("$reasonToRebuild. Performing non-incremental rebuild (kotlin only)")
|
||||||
|
actions.add(CacheVersion.Action.REBUILD_ALL_KOTLIN)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,16 +45,16 @@ val CompileContext.kotlinBuildTargets: KotlinBuildTargets
|
|||||||
}
|
}
|
||||||
|
|
||||||
class KotlinBuildTargets internal constructor(val compileContext: CompileContext) {
|
class KotlinBuildTargets internal constructor(val compileContext: CompileContext) {
|
||||||
private val byJpsModuleBuildTarget = ConcurrentHashMap<ModuleBuildTarget, KotlinModuleBuildTarget>()
|
private val byJpsModuleBuildTarget = ConcurrentHashMap<ModuleBuildTarget, KotlinModuleBuildTarget<*>>()
|
||||||
private val isKotlinJsStdlibJar = ConcurrentHashMap<String, Boolean>()
|
private val isKotlinJsStdlibJar = ConcurrentHashMap<String, Boolean>()
|
||||||
|
|
||||||
@JvmName("getNullable")
|
@JvmName("getNullable")
|
||||||
operator fun get(target: ModuleBuildTarget?): KotlinModuleBuildTarget? {
|
operator fun get(target: ModuleBuildTarget?): KotlinModuleBuildTarget<*>? {
|
||||||
if (target == null) return null
|
if (target == null) return null
|
||||||
return get(target)
|
return get(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(target: ModuleBuildTarget): KotlinModuleBuildTarget? {
|
operator fun get(target: ModuleBuildTarget): KotlinModuleBuildTarget<*>? {
|
||||||
if (target.module.moduleType != JpsJavaModuleType.INSTANCE) return null
|
if (target.module.moduleType != JpsJavaModuleType.INSTANCE) return null
|
||||||
|
|
||||||
return byJpsModuleBuildTarget.computeIfAbsent(target) {
|
return byJpsModuleBuildTarget.computeIfAbsent(target) {
|
||||||
|
|||||||
Reference in New Issue
Block a user