Move CacheFormatVersion to separate file
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.jps.incremental
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
|
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||||
|
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class CacheFormatVersion(targetDataRoot: File) {
|
||||||
|
companion object {
|
||||||
|
// Change this when incremental cache format changes
|
||||||
|
private val INCREMENTAL_CACHE_OWN_VERSION = 5
|
||||||
|
|
||||||
|
private val CACHE_FORMAT_VERSION =
|
||||||
|
INCREMENTAL_CACHE_OWN_VERSION * 1000000 +
|
||||||
|
JvmAbi.VERSION.major * 1000 +
|
||||||
|
JvmAbi.VERSION.minor
|
||||||
|
|
||||||
|
private val NON_INCREMENTAL_MODE_PSEUDO_VERSION = Int.MAX_VALUE
|
||||||
|
|
||||||
|
val FORMAT_VERSION_FILE_PATH: String = "$CACHE_DIRECTORY_NAME/format-version.txt"
|
||||||
|
}
|
||||||
|
|
||||||
|
private val file = File(targetDataRoot, FORMAT_VERSION_FILE_PATH)
|
||||||
|
|
||||||
|
private fun actualCacheFormatVersion() = if (IncrementalCompilation.ENABLED) CACHE_FORMAT_VERSION else NON_INCREMENTAL_MODE_PSEUDO_VERSION
|
||||||
|
|
||||||
|
public fun isIncompatible(): Boolean {
|
||||||
|
if (!file.exists()) return false
|
||||||
|
|
||||||
|
val versionNumber = file.readText().toInt()
|
||||||
|
val expectedVersionNumber = actualCacheFormatVersion()
|
||||||
|
|
||||||
|
if (versionNumber != expectedVersionNumber) {
|
||||||
|
KotlinBuilder.LOG.info("Incompatible incremental cache version, expected $expectedVersionNumber, actual $versionNumber")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saveIfNeeded() {
|
||||||
|
if (file.parentFile.exists() && !file.exists()) {
|
||||||
|
file.writeText(actualCacheFormatVersion().toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clean() {
|
||||||
|
file.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,12 +30,10 @@ import org.jetbrains.jps.incremental.ModuleBuildTarget
|
|||||||
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
||||||
import org.jetbrains.jps.incremental.storage.PathStringDescriptor
|
import org.jetbrains.jps.incremental.storage.PathStringDescriptor
|
||||||
import org.jetbrains.jps.incremental.storage.StorageOwner
|
import org.jetbrains.jps.incremental.storage.StorageOwner
|
||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
|
||||||
import org.jetbrains.kotlin.jps.build.GeneratedJvmClass
|
import org.jetbrains.kotlin.jps.build.GeneratedJvmClass
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||||
import org.jetbrains.kotlin.jps.incremental.storage.BasicMap
|
import org.jetbrains.kotlin.jps.incremental.storage.BasicMap
|
||||||
import org.jetbrains.kotlin.jps.incremental.storage.BasicStringMap
|
import org.jetbrains.kotlin.jps.incremental.storage.BasicStringMap
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||||
@@ -56,52 +54,9 @@ import java.util.*
|
|||||||
|
|
||||||
val INLINE_ANNOTATION_DESC = "Lkotlin/inline;"
|
val INLINE_ANNOTATION_DESC = "Lkotlin/inline;"
|
||||||
|
|
||||||
private val CACHE_DIRECTORY_NAME = "kotlin"
|
internal val CACHE_DIRECTORY_NAME = "kotlin"
|
||||||
|
|
||||||
|
|
||||||
class CacheFormatVersion(targetDataRoot: File) {
|
|
||||||
companion object {
|
|
||||||
// Change this when incremental cache format changes
|
|
||||||
private val INCREMENTAL_CACHE_OWN_VERSION = 5
|
|
||||||
|
|
||||||
private val CACHE_FORMAT_VERSION =
|
|
||||||
INCREMENTAL_CACHE_OWN_VERSION * 1000000 +
|
|
||||||
JvmAbi.VERSION.major * 1000 +
|
|
||||||
JvmAbi.VERSION.minor
|
|
||||||
|
|
||||||
private val NON_INCREMENTAL_MODE_PSEUDO_VERSION = Int.MAX_VALUE
|
|
||||||
|
|
||||||
val FORMAT_VERSION_FILE_PATH: String = "$CACHE_DIRECTORY_NAME/format-version.txt"
|
|
||||||
}
|
|
||||||
|
|
||||||
private val file = File(targetDataRoot, FORMAT_VERSION_FILE_PATH)
|
|
||||||
|
|
||||||
private fun actualCacheFormatVersion() = if (IncrementalCompilation.ENABLED) CACHE_FORMAT_VERSION else NON_INCREMENTAL_MODE_PSEUDO_VERSION
|
|
||||||
|
|
||||||
public fun isIncompatible(): Boolean {
|
|
||||||
if (!file.exists()) return false
|
|
||||||
|
|
||||||
val versionNumber = file.readText().toInt()
|
|
||||||
val expectedVersionNumber = actualCacheFormatVersion()
|
|
||||||
|
|
||||||
if (versionNumber != expectedVersionNumber) {
|
|
||||||
KotlinBuilder.LOG.info("Incompatible incremental cache version, expected $expectedVersionNumber, actual $versionNumber")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun saveIfNeeded() {
|
|
||||||
if (file.parentFile.exists() && !file.exists()) {
|
|
||||||
file.writeText(actualCacheFormatVersion().toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clean() {
|
|
||||||
file.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class IncrementalCacheImpl(
|
public class IncrementalCacheImpl(
|
||||||
targetDataRoot: File,
|
targetDataRoot: File,
|
||||||
private val target: ModuleBuildTarget
|
private val target: ModuleBuildTarget
|
||||||
|
|||||||
Reference in New Issue
Block a user