Revert "[K/N] add testing setup for header klibs and caches"
This reverts commit a89893a2c5.
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
// Looks like the call to `k` fails as `k` is not exported from the lib module.
|
// Looks like the call to `k` fails as `k` is not exported from the lib module.
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
// IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_USE_HEADERS_EVERYWHERE
|
|
||||||
// MODULE: lib
|
// MODULE: lib
|
||||||
// FILE: Z.kt
|
// FILE: Z.kt
|
||||||
package z
|
package z
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// KT-64511: lateinit is not lowered with caches
|
// KT-64511: lateinit is not lowered with caches
|
||||||
// DISABLE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
// DISABLE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
||||||
// DISABLE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
// DISABLE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
||||||
// DISABLE_NATIVE: cacheMode=STATIC_USE_HEADERS_EVERYWHERE
|
|
||||||
// MODULE: lib
|
// MODULE: lib
|
||||||
// FILE: lib.kt
|
// FILE: lib.kt
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// ISSUE: KT-58421
|
// ISSUE: KT-58421
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_USE_HEADERS_EVERYWHERE
|
|
||||||
|
|
||||||
// MODULE: lib
|
// MODULE: lib
|
||||||
// FILE: ContinuationImpl.kt
|
// FILE: ContinuationImpl.kt
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// test is disabled now because of https://youtrack.jetbrains.com/issue/KT-55426
|
// test is disabled now because of https://youtrack.jetbrains.com/issue/KT-55426
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
// IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_USE_HEADERS_EVERYWHERE
|
|
||||||
|
|
||||||
// MODULE: lib
|
// MODULE: lib
|
||||||
// FILE: lib.kt
|
// FILE: lib.kt
|
||||||
|
|||||||
-1
@@ -6,7 +6,6 @@
|
|||||||
// kotlin.AssertionError: Expected <class codegen.kclass.kclass0.MainKt$1>, actual <class codegen.kclass.kclass0.box$$inlined$getHasFoo$1>.
|
// kotlin.AssertionError: Expected <class codegen.kclass.kclass0.MainKt$1>, actual <class codegen.kclass.kclass0.box$$inlined$getHasFoo$1>.
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
// IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
||||||
// IGNORE_NATIVE: cacheMode=STATIC_USE_HEADERS_EVERYWHERE
|
|
||||||
|
|
||||||
package codegen.kclass.kclass0
|
package codegen.kclass.kclass0
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|||||||
+2
-25
@@ -13,8 +13,6 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.TestModule
|
|||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.*
|
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.*
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact.KLIB
|
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact.KLIB
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact.KLIBStaticCache
|
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact.KLIBStaticCache
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact.KLIBStaticCacheImpl
|
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact.KLIBStaticCacheHeader
|
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationResult.Companion.assertSuccess
|
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.group.UsePartialLinkage
|
import org.jetbrains.kotlin.konan.test.blackbox.support.group.UsePartialLinkage
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable
|
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable
|
||||||
@@ -149,28 +147,13 @@ abstract class AbstractNativeKlibEvolutionTest : AbstractNativeSimpleTest() {
|
|||||||
) {
|
) {
|
||||||
val klib = module.klibFile
|
val klib = module.klibFile
|
||||||
|
|
||||||
if (useHeaders) {
|
|
||||||
val compilation = StaticCacheCompilation(
|
|
||||||
settings = testRunSettings,
|
|
||||||
freeCompilerArgs = COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE,
|
|
||||||
options = staticCacheCompilationOptions,
|
|
||||||
pipelineType = testRunSettings.get(),
|
|
||||||
dependencies = moduleDependencies.map {
|
|
||||||
it.klibFile.toHeaderCacheArtifact().toDependency()
|
|
||||||
} + klib.toKlib().toDependency(),
|
|
||||||
createHeaderCache = true,
|
|
||||||
expectedArtifact = klib.toHeaderCacheArtifact()
|
|
||||||
)
|
|
||||||
compilation.trigger()
|
|
||||||
}
|
|
||||||
|
|
||||||
val compilation = StaticCacheCompilation(
|
val compilation = StaticCacheCompilation(
|
||||||
settings = testRunSettings,
|
settings = testRunSettings,
|
||||||
freeCompilerArgs = COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE,
|
freeCompilerArgs = COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE,
|
||||||
options = staticCacheCompilationOptions,
|
options = staticCacheCompilationOptions,
|
||||||
pipelineType = testRunSettings.get(),
|
pipelineType = testRunSettings.get(),
|
||||||
dependencies = moduleDependencies.map {
|
dependencies = moduleDependencies.map {
|
||||||
if (useHeaders) it.klibFile.toHeaderCacheArtifact().toDependency() else it.klibFile.toStaticCacheArtifact().toDependency()
|
it.klibFile.toStaticCacheArtifact().toDependency()
|
||||||
} + klib.toKlib().toDependency(),
|
} + klib.toKlib().toDependency(),
|
||||||
expectedArtifact = klib.toStaticCacheArtifact()
|
expectedArtifact = klib.toStaticCacheArtifact()
|
||||||
)
|
)
|
||||||
@@ -300,7 +283,6 @@ abstract class AbstractNativeKlibEvolutionTest : AbstractNativeSimpleTest() {
|
|||||||
|
|
||||||
private val buildDir: File get() = testRunSettings.get<Binaries>().testBinariesDir
|
private val buildDir: File get() = testRunSettings.get<Binaries>().testBinariesDir
|
||||||
private val useStaticCacheForUserLibraries: Boolean get() = testRunSettings.get<CacheMode>().useStaticCacheForUserLibraries
|
private val useStaticCacheForUserLibraries: Boolean get() = testRunSettings.get<CacheMode>().useStaticCacheForUserLibraries
|
||||||
private val useHeaders: Boolean get() = testRunSettings.get<CacheMode>().useHeaders
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val COMPILER_ARGS_FOR_KLIB = TestCompilerArgs.EMPTY
|
private val COMPILER_ARGS_FOR_KLIB = TestCompilerArgs.EMPTY
|
||||||
@@ -319,16 +301,11 @@ private fun File.resolveKlibFileWithVersion(moduleName: String, version: Int): F
|
|||||||
resolveModuleWithVersion(moduleName, version).resolve("${moduleName}.klib")
|
resolveModuleWithVersion(moduleName, version).resolve("${moduleName}.klib")
|
||||||
|
|
||||||
private fun File.toKlib(): KLIB = KLIB(this)
|
private fun File.toKlib(): KLIB = KLIB(this)
|
||||||
private fun File.toStaticCacheArtifact() = KLIBStaticCacheImpl(
|
private fun File.toStaticCacheArtifact() = KLIBStaticCache(
|
||||||
cacheDir = parentFile.resolve(STATIC_CACHE_DIR_NAME).apply { mkdirs() },
|
cacheDir = parentFile.resolve(STATIC_CACHE_DIR_NAME).apply { mkdirs() },
|
||||||
klib = KLIB(this)
|
klib = KLIB(this)
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun File.toHeaderCacheArtifact() = KLIBStaticCacheHeader(
|
|
||||||
cacheDir = parentFile.resolve(HEADER_CACHE_DIR_NAME).apply { mkdirs() },
|
|
||||||
klib = KLIB(this)
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun KLIB.toDependency() = ExistingDependency(this, TestCompilationDependencyType.Library)
|
private fun KLIB.toDependency() = ExistingDependency(this, TestCompilationDependencyType.Library)
|
||||||
private fun KLIB.toIncludedDependency() = ExistingDependency(this, TestCompilationDependencyType.IncludedLibrary)
|
private fun KLIB.toIncludedDependency() = ExistingDependency(this, TestCompilationDependencyType.IncludedLibrary)
|
||||||
private fun KLIBStaticCache.toDependency() = ExistingDependency(this, TestCompilationDependencyType.LibraryStaticCache)
|
private fun KLIBStaticCache.toDependency() = ExistingDependency(this, TestCompilationDependencyType.LibraryStaticCache)
|
||||||
|
|||||||
+1
-1
@@ -209,7 +209,7 @@ abstract class AbstractNativePartialLinkageTest : AbstractNativeSimpleTest() {
|
|||||||
private fun KLIB.toFriendDependency() = ExistingDependency(this, FriendLibrary)
|
private fun KLIB.toFriendDependency() = ExistingDependency(this, FriendLibrary)
|
||||||
private fun KLIBStaticCache.toDependency() = ExistingDependency(this, LibraryStaticCache)
|
private fun KLIBStaticCache.toDependency() = ExistingDependency(this, LibraryStaticCache)
|
||||||
|
|
||||||
private fun KLIB.toStaticCacheArtifact() = KLIBStaticCacheImpl(
|
private fun KLIB.toStaticCacheArtifact() = KLIBStaticCache(
|
||||||
cacheDir = klibFile.parentFile.resolve(STATIC_CACHE_DIR_NAME).apply { mkdirs() },
|
cacheDir = klibFile.parentFile.resolve(STATIC_CACHE_DIR_NAME).apply { mkdirs() },
|
||||||
klib = this
|
klib = this
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -201,7 +201,7 @@ internal fun AbstractNativeSimpleTest.compileToStaticCache(
|
|||||||
this += klib.asLibraryDependency()
|
this += klib.asLibraryDependency()
|
||||||
dependencies.mapTo(this) { it.asStaticCacheDependency() }
|
dependencies.mapTo(this) { it.asStaticCacheDependency() }
|
||||||
},
|
},
|
||||||
expectedArtifact = TestCompilationArtifact.KLIBStaticCacheImpl(cacheDir, klib)
|
expectedArtifact = TestCompilationArtifact.KLIBStaticCache(cacheDir, klib)
|
||||||
)
|
)
|
||||||
return compilation.result.assertSuccess().resultingArtifact
|
return compilation.result.assertSuccess().resultingArtifact
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -277,10 +277,8 @@ internal object NativeTestSupport {
|
|||||||
CacheMode.Alias.STATIC_ONLY_DIST -> false
|
CacheMode.Alias.STATIC_ONLY_DIST -> false
|
||||||
CacheMode.Alias.STATIC_EVERYWHERE -> true
|
CacheMode.Alias.STATIC_EVERYWHERE -> true
|
||||||
CacheMode.Alias.STATIC_PER_FILE_EVERYWHERE -> true
|
CacheMode.Alias.STATIC_PER_FILE_EVERYWHERE -> true
|
||||||
CacheMode.Alias.STATIC_USE_HEADERS_EVERYWHERE -> true
|
|
||||||
}
|
}
|
||||||
val makePerFileCaches = cacheMode == CacheMode.Alias.STATIC_PER_FILE_EVERYWHERE
|
val makePerFileCaches = cacheMode == CacheMode.Alias.STATIC_PER_FILE_EVERYWHERE
|
||||||
val useHeaders = cacheMode == CacheMode.Alias.STATIC_USE_HEADERS_EVERYWHERE
|
|
||||||
|
|
||||||
return if (defaultCache == CacheMode.Alias.NO)
|
return if (defaultCache == CacheMode.Alias.NO)
|
||||||
CacheMode.WithoutCache
|
CacheMode.WithoutCache
|
||||||
@@ -290,7 +288,6 @@ internal object NativeTestSupport {
|
|||||||
optimizationMode,
|
optimizationMode,
|
||||||
useStaticCacheForUserLibraries,
|
useStaticCacheForUserLibraries,
|
||||||
makePerFileCaches,
|
makePerFileCaches,
|
||||||
useHeaders,
|
|
||||||
cacheMode
|
cacheMode
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-33
@@ -224,6 +224,7 @@ abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
||||||
|
addFlattened(dependencies.libraries) { library -> listOf("-l", library.path) }
|
||||||
dependencies.friends.takeIf(Collection<*>::isNotEmpty)?.let { friends ->
|
dependencies.friends.takeIf(Collection<*>::isNotEmpty)?.let { friends ->
|
||||||
add("-friend-modules", friends.joinToString(File.pathSeparator) { friend -> friend.path })
|
add("-friend-modules", friends.joinToString(File.pathSeparator) { friend -> friend.path })
|
||||||
}
|
}
|
||||||
@@ -268,29 +269,15 @@ internal class LibraryCompilation(
|
|||||||
dependencies = CategorizedDependencies(dependencies),
|
dependencies = CategorizedDependencies(dependencies),
|
||||||
expectedArtifact = expectedArtifact
|
expectedArtifact = expectedArtifact
|
||||||
) {
|
) {
|
||||||
private val useHeaders: Boolean = settings.get<CacheMode>().useHeaders
|
|
||||||
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting(optimizationMode, freeCompilerArgs.assertionsMode)
|
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting(optimizationMode, freeCompilerArgs.assertionsMode)
|
||||||
|
|
||||||
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
|
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
|
||||||
add(
|
add(
|
||||||
"-produce", "library",
|
"-produce", "library",
|
||||||
"-output", expectedArtifact.path,
|
"-output", expectedArtifact.path
|
||||||
)
|
)
|
||||||
if (useHeaders) {
|
|
||||||
add("-Xheader-klib-path=${expectedArtifact.headerKlib.path}")
|
|
||||||
}
|
|
||||||
super.applySpecificArgs(argsBuilder)
|
super.applySpecificArgs(argsBuilder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
|
||||||
super.applyDependencies(argsBuilder)
|
|
||||||
addFlattened(dependencies.libraries) { library ->
|
|
||||||
listOf(
|
|
||||||
"-l",
|
|
||||||
library.headerKlib.takeIf { useHeaders && it.exists() }?.path ?: library.path
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class ObjCFrameworkCompilation(
|
internal class ObjCFrameworkCompilation(
|
||||||
@@ -566,7 +553,6 @@ class ExecutableCompilation(
|
|||||||
|
|
||||||
override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
||||||
super.applyDependencies(argsBuilder)
|
super.applyDependencies(argsBuilder)
|
||||||
addFlattened(dependencies.libraries) { library -> listOf("-l", library.path) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun postCompileCheck() {
|
override fun postCompileCheck() {
|
||||||
@@ -614,9 +600,8 @@ internal class StaticCacheCompilation(
|
|||||||
private val options: Options,
|
private val options: Options,
|
||||||
private val pipelineType: PipelineType,
|
private val pipelineType: PipelineType,
|
||||||
dependencies: Iterable<TestCompilationDependency<*>>,
|
dependencies: Iterable<TestCompilationDependency<*>>,
|
||||||
|
expectedArtifact: KLIBStaticCache,
|
||||||
makePerFileCacheOverride: Boolean? = null,
|
makePerFileCacheOverride: Boolean? = null,
|
||||||
private val createHeaderCache: Boolean = false,
|
|
||||||
expectedArtifact: KLIBStaticCache
|
|
||||||
) : BasicCompilation<KLIBStaticCache>(
|
) : BasicCompilation<KLIBStaticCache>(
|
||||||
targets = settings.get(),
|
targets = settings.get(),
|
||||||
home = settings.get(),
|
home = settings.get(),
|
||||||
@@ -641,10 +626,8 @@ internal class StaticCacheCompilation(
|
|||||||
|
|
||||||
private val partialLinkageConfig: UsedPartialLinkageConfig = settings.get()
|
private val partialLinkageConfig: UsedPartialLinkageConfig = settings.get()
|
||||||
|
|
||||||
private val useHeaders: Boolean = settings.get<CacheMode>().useHeaders
|
|
||||||
|
|
||||||
override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
||||||
add("-produce", if (createHeaderCache) "header_cache" else "static_cache")
|
add("-produce", "static_cache")
|
||||||
pipelineType.compilerFlags.forEach { compilerFlag -> add(compilerFlag) }
|
pipelineType.compilerFlags.forEach { compilerFlag -> add(compilerFlag) }
|
||||||
|
|
||||||
when (options) {
|
when (options) {
|
||||||
@@ -670,18 +653,9 @@ internal class StaticCacheCompilation(
|
|||||||
|
|
||||||
override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
|
||||||
dependencies.friends.takeIf(Collection<*>::isNotEmpty)?.let { friends ->
|
dependencies.friends.takeIf(Collection<*>::isNotEmpty)?.let { friends ->
|
||||||
add(
|
add("-friend-modules", friends.joinToString(File.pathSeparator) { friend -> friend.path })
|
||||||
"-friend-modules",
|
|
||||||
friends.joinToString(File.pathSeparator) { friend ->
|
|
||||||
friend.headerKlib.takeIf { useHeaders && it.exists() }?.path ?: friend.path
|
|
||||||
})
|
|
||||||
}
|
|
||||||
addFlattened(dependencies.cachedLibraries) { lib ->
|
|
||||||
listOf(
|
|
||||||
"-l",
|
|
||||||
lib.klib.headerKlib.takeIf { useHeaders && it.exists() }?.path ?: lib.klib.path
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
addFlattened(dependencies.cachedLibraries) { (_, library) -> listOf("-l", library.path) }
|
||||||
super.applyDependencies(argsBuilder)
|
super.applyDependencies(argsBuilder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,7 +693,7 @@ class CategorizedDependencies(uncategorizedDependencies: Iterable<TestCompilatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
val uniqueCacheDirs: Set<File> by lazy {
|
val uniqueCacheDirs: Set<File> by lazy {
|
||||||
cachedLibraries.mapToSet { it.cacheDir } // Avoid repeating the same directory more than once.
|
cachedLibraries.mapToSet { (libraryCacheDir, _) -> libraryCacheDir } // Avoid repeating the same directory more than once.
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun <reified A : TestCompilationArtifact, reified T : TestCompilationDependencyType<A>> Iterable<TestCompilationDependency<*>>.collectArtifacts(): List<A> {
|
private inline fun <reified A : TestCompilationArtifact, reified T : TestCompilationDependencyType<A>> Iterable<TestCompilationDependency<*>>.collectArtifacts(): List<A> {
|
||||||
|
|||||||
+1
-12
@@ -12,15 +12,10 @@ sealed interface TestCompilationArtifact {
|
|||||||
|
|
||||||
data class KLIB(val klibFile: File) : TestCompilationArtifact {
|
data class KLIB(val klibFile: File) : TestCompilationArtifact {
|
||||||
val path: String get() = klibFile.path
|
val path: String get() = klibFile.path
|
||||||
|
|
||||||
val headerKlib: File get() = klibFile.resolveSibling(klibFile.name.replaceAfterLast(".", "header.klib"))
|
|
||||||
override val logFile: File get() = klibFile.resolveSibling("${klibFile.name}.log")
|
override val logFile: File get() = klibFile.resolveSibling("${klibFile.name}.log")
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KLIBStaticCache : TestCompilationArtifact {
|
data class KLIBStaticCache(val cacheDir: File, val klib: KLIB, val fileCheckStage: String? = null) : TestCompilationArtifact {
|
||||||
val cacheDir: File
|
|
||||||
val klib: KLIB
|
|
||||||
val fileCheckStage: String?
|
|
||||||
override val logFile: File get() = cacheDir.resolve("${klib.klibFile.nameWithoutExtension}-cache.log")
|
override val logFile: File get() = cacheDir.resolve("${klib.klibFile.nameWithoutExtension}-cache.log")
|
||||||
val fileCheckDump: File?
|
val fileCheckDump: File?
|
||||||
get() = fileCheckStage?.let {
|
get() = fileCheckStage?.let {
|
||||||
@@ -28,12 +23,6 @@ sealed interface TestCompilationArtifact {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class KLIBStaticCacheImpl(override val cacheDir: File, override val klib: KLIB, override val fileCheckStage: String? = null) :
|
|
||||||
KLIBStaticCache
|
|
||||||
|
|
||||||
data class KLIBStaticCacheHeader(override val cacheDir: File, override val klib: KLIB, override val fileCheckStage: String? = null) :
|
|
||||||
KLIBStaticCache
|
|
||||||
|
|
||||||
data class Executable(val executableFile: File, val fileCheckStage: String? = null) : TestCompilationArtifact {
|
data class Executable(val executableFile: File, val fileCheckStage: String? = null) : TestCompilationArtifact {
|
||||||
val path: String get() = executableFile.path
|
val path: String get() = executableFile.path
|
||||||
override val logFile: File get() = executableFile.resolveSibling("${executableFile.name}.log")
|
override val logFile: File get() = executableFile.resolveSibling("${executableFile.name}.log")
|
||||||
|
|||||||
+13
-45
@@ -30,25 +30,24 @@ internal class TestCompilationFactory {
|
|||||||
private val cachedObjCFrameworkCompilations = ThreadSafeCache<ObjCFrameworkCacheKey, ObjCFrameworkCompilation>()
|
private val cachedObjCFrameworkCompilations = ThreadSafeCache<ObjCFrameworkCacheKey, ObjCFrameworkCompilation>()
|
||||||
private val cachedBinaryLibraryCompilations = ThreadSafeCache<BinaryLibraryCacheKey, BinaryLibraryCompilation>()
|
private val cachedBinaryLibraryCompilations = ThreadSafeCache<BinaryLibraryCacheKey, BinaryLibraryCompilation>()
|
||||||
|
|
||||||
private data class KlibCacheKey(val sourceModules: Set<TestModule>, val freeCompilerArgs: TestCompilerArgs, val useHeaders: Boolean)
|
private data class KlibCacheKey(val sourceModules: Set<TestModule>, val freeCompilerArgs: TestCompilerArgs)
|
||||||
private data class ExecutableCacheKey(val sourceModules: Set<TestModule>)
|
private data class ExecutableCacheKey(val sourceModules: Set<TestModule>)
|
||||||
private data class ObjCFrameworkCacheKey(val sourceModules: Set<TestModule>)
|
private data class ObjCFrameworkCacheKey(val sourceModules: Set<TestModule>)
|
||||||
private data class BinaryLibraryCacheKey(val sourceModules: Set<TestModule>, val kind: BinaryLibraryKind)
|
private data class BinaryLibraryCacheKey(val sourceModules: Set<TestModule>, val kind: BinaryLibraryKind)
|
||||||
|
|
||||||
// A pair of compilations for a KLIB itself and for its static cache that are created together.
|
// A pair of compilations for a KLIB itself and for its static cache that are created together.
|
||||||
private data class KlibCompilations(val klib: TestCompilation<KLIB>, val staticCache: TestCompilation<KLIBStaticCache>?, val headerCache: TestCompilation<KLIBStaticCache>?)
|
private data class KlibCompilations(val klib: TestCompilation<KLIB>, val staticCache: TestCompilation<KLIBStaticCache>?)
|
||||||
|
|
||||||
private data class CompilationDependencies(
|
private data class CompilationDependencies(
|
||||||
private val klibDependencies: List<CompiledDependency<KLIB>>,
|
private val klibDependencies: List<CompiledDependency<KLIB>>,
|
||||||
private val staticCacheDependencies: List<CompiledDependency<KLIBStaticCache>>,
|
private val staticCacheDependencies: List<CompiledDependency<KLIBStaticCache>>
|
||||||
private val staticCacheHeaderDependencies: List<CompiledDependency<KLIBStaticCache>>
|
|
||||||
) {
|
) {
|
||||||
/** Dependencies needed to compile KLIB. */
|
/** Dependencies needed to compile KLIB. */
|
||||||
fun forKlib(): Iterable<CompiledDependency<KLIB>> = klibDependencies
|
fun forKlib(): Iterable<CompiledDependency<KLIB>> = klibDependencies
|
||||||
|
|
||||||
/** Dependencies needed to compile KLIB static cache. */
|
/** Dependencies needed to compile KLIB static cache. */
|
||||||
fun forStaticCache(klib: CompiledDependency<KLIB>, useHeaders: Boolean): Iterable<CompiledDependency<*>> =
|
fun forStaticCache(klib: CompiledDependency<KLIB>): Iterable<CompiledDependency<*>> =
|
||||||
(klibDependencies.asSequence().filter { it.type == FriendLibrary } + klib + if (useHeaders) staticCacheHeaderDependencies else staticCacheDependencies).asIterable()
|
(klibDependencies.asSequence().filter { it.type == FriendLibrary } + klib + staticCacheDependencies).asIterable()
|
||||||
|
|
||||||
/** Dependencies needed to compile one-stage executable. */
|
/** Dependencies needed to compile one-stage executable. */
|
||||||
fun forOneStageExecutable(): Iterable<CompiledDependency<*>> =
|
fun forOneStageExecutable(): Iterable<CompiledDependency<*>> =
|
||||||
@@ -211,8 +210,7 @@ internal class TestCompilationFactory {
|
|||||||
produceStaticCache: ProduceStaticCache,
|
produceStaticCache: ProduceStaticCache,
|
||||||
settings: Settings
|
settings: Settings
|
||||||
): KlibCompilations {
|
): KlibCompilations {
|
||||||
val useHeaders: Boolean = settings.get<CacheMode>().useHeaders
|
val cacheKey = KlibCacheKey(sourceModules, freeCompilerArgs)
|
||||||
val cacheKey = KlibCacheKey(sourceModules, freeCompilerArgs, useHeaders)
|
|
||||||
|
|
||||||
// Fast pass.
|
// Fast pass.
|
||||||
cachedKlibCompilations[cacheKey]?.let { return it }
|
cachedKlibCompilations[cacheKey]?.let { return it }
|
||||||
@@ -225,20 +223,12 @@ internal class TestCompilationFactory {
|
|||||||
|
|
||||||
val staticCacheArtifactAndOptions: Pair<KLIBStaticCache, StaticCacheCompilation.Options>? = when (produceStaticCache) {
|
val staticCacheArtifactAndOptions: Pair<KLIBStaticCache, StaticCacheCompilation.Options>? = when (produceStaticCache) {
|
||||||
is ProduceStaticCache.No -> null // No artifact means no static cache should be compiled.
|
is ProduceStaticCache.No -> null // No artifact means no static cache should be compiled.
|
||||||
is ProduceStaticCache.Yes -> KLIBStaticCacheImpl(
|
is ProduceStaticCache.Yes -> KLIBStaticCache(
|
||||||
cacheDir = settings.cacheDirForStaticCache(klibArtifact, isGivenKlibArtifact),
|
cacheDir = settings.cacheDirForStaticCache(klibArtifact, isGivenKlibArtifact),
|
||||||
klib = klibArtifact
|
klib = klibArtifact
|
||||||
) to produceStaticCache.options
|
) to produceStaticCache.options
|
||||||
}
|
}
|
||||||
|
|
||||||
val headerCacheArtifactAndOptions = staticCacheArtifactAndOptions?.let {
|
|
||||||
if (!useHeaders) return@let null
|
|
||||||
KLIBStaticCacheHeader(
|
|
||||||
cacheDir = settings.cacheDirForStaticCache(klibArtifact, isGivenKlibArtifact, header = true),
|
|
||||||
klib = klibArtifact
|
|
||||||
) to it.second
|
|
||||||
}
|
|
||||||
|
|
||||||
return cachedKlibCompilations.computeIfAbsent(cacheKey) {
|
return cachedKlibCompilations.computeIfAbsent(cacheKey) {
|
||||||
val (klibCompilation, makePerFileCacheOverride) = if (isGivenKlibArtifact)
|
val (klibCompilation, makePerFileCacheOverride) = if (isGivenKlibArtifact)
|
||||||
GivenLibraryCompilation(klibArtifact) to false // Don't make per-file-cache from given dependencies(usually, cinterop)
|
GivenLibraryCompilation(klibArtifact) to false // Don't make per-file-cache from given dependencies(usually, cinterop)
|
||||||
@@ -284,32 +274,13 @@ internal class TestCompilationFactory {
|
|||||||
freeCompilerArgs = freeCompilerArgs,
|
freeCompilerArgs = freeCompilerArgs,
|
||||||
options = staticCacheOptions,
|
options = staticCacheOptions,
|
||||||
pipelineType = settings.get(),
|
pipelineType = settings.get(),
|
||||||
dependencies = dependencies.forStaticCache(
|
dependencies = dependencies.forStaticCache(klibCompilation.asKlibDependency(type = /* does not matter in fact*/ Library)),
|
||||||
klibCompilation.asKlibDependency(type = /* does not matter in fact*/ Library),
|
|
||||||
settings.get<CacheMode>().useHeaders
|
|
||||||
),
|
|
||||||
expectedArtifact = staticCacheArtifact,
|
expectedArtifact = staticCacheArtifact,
|
||||||
makePerFileCacheOverride = makePerFileCacheOverride,
|
makePerFileCacheOverride = makePerFileCacheOverride,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val headerCacheCompilation: StaticCacheCompilation? =
|
KlibCompilations(klibCompilation, staticCacheCompilation)
|
||||||
headerCacheArtifactAndOptions?.let { (staticCacheArtifact, staticCacheOptions) ->
|
|
||||||
StaticCacheCompilation(
|
|
||||||
settings = settings,
|
|
||||||
freeCompilerArgs = freeCompilerArgs,
|
|
||||||
options = staticCacheOptions,
|
|
||||||
createHeaderCache = true,
|
|
||||||
pipelineType = settings.get(),
|
|
||||||
dependencies = dependencies.forStaticCache(
|
|
||||||
klibCompilation.asKlibDependency(type = /* does not matter in fact*/ Library),
|
|
||||||
settings.get<CacheMode>().useHeaders
|
|
||||||
),
|
|
||||||
expectedArtifact = staticCacheArtifact
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
KlibCompilations(klibCompilation, staticCacheCompilation, headerCacheCompilation)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +291,6 @@ internal class TestCompilationFactory {
|
|||||||
): CompilationDependencies {
|
): CompilationDependencies {
|
||||||
val klibDependencies = mutableListOf<CompiledDependency<KLIB>>()
|
val klibDependencies = mutableListOf<CompiledDependency<KLIB>>()
|
||||||
val staticCacheDependencies = mutableListOf<CompiledDependency<KLIBStaticCache>>()
|
val staticCacheDependencies = mutableListOf<CompiledDependency<KLIBStaticCache>>()
|
||||||
val staticCacheHeaderDependencies = mutableListOf<CompiledDependency<KLIBStaticCache>>()
|
|
||||||
|
|
||||||
val produceStaticCache = ProduceStaticCache.decideForRegularKlib(settings)
|
val produceStaticCache = ProduceStaticCache.decideForRegularKlib(settings)
|
||||||
|
|
||||||
@@ -329,16 +299,14 @@ internal class TestCompilationFactory {
|
|||||||
val klibCompilations = modulesToKlib(setOf(dependencyModule), freeCompilerArgs, produceStaticCache, settings)
|
val klibCompilations = modulesToKlib(setOf(dependencyModule), freeCompilerArgs, produceStaticCache, settings)
|
||||||
klibDependencies += klibCompilations.klib.asKlibDependency(type)
|
klibDependencies += klibCompilations.klib.asKlibDependency(type)
|
||||||
|
|
||||||
if (type == Library || type == IncludedLibrary) {
|
if (type == Library || type == IncludedLibrary)
|
||||||
staticCacheDependencies.addIfNotNull(klibCompilations.staticCache?.asStaticCacheDependency())
|
staticCacheDependencies.addIfNotNull(klibCompilations.staticCache?.asStaticCacheDependency())
|
||||||
staticCacheHeaderDependencies.addIfNotNull((klibCompilations.headerCache ?: klibCompilations.staticCache)?.asStaticCacheDependency())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceModules.allDependencies().collectDependencies(Library)
|
sourceModules.allDependencies().collectDependencies(Library)
|
||||||
sourceModules.allFriends().collectDependencies(FriendLibrary)
|
sourceModules.allFriends().collectDependencies(FriendLibrary)
|
||||||
|
|
||||||
return CompilationDependencies(klibDependencies, staticCacheDependencies, staticCacheHeaderDependencies)
|
return CompilationDependencies(klibDependencies, staticCacheDependencies)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sortDependsOnTopologically(module: TestModule): List<TestModule> {
|
private fun sortDependsOnTopologically(module: TestModule): List<TestModule> {
|
||||||
@@ -394,7 +362,7 @@ internal class TestCompilationFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Settings.cacheDirForStaticCache(klibArtifact: KLIB, isGivenKlibArtifact: Boolean, header: Boolean = false): File {
|
private fun Settings.cacheDirForStaticCache(klibArtifact: KLIB, isGivenKlibArtifact: Boolean): File {
|
||||||
val artifactBaseDir = if (isGivenKlibArtifact) {
|
val artifactBaseDir = if (isGivenKlibArtifact) {
|
||||||
// Special case for the given (external) KLIB artifacts.
|
// Special case for the given (external) KLIB artifacts.
|
||||||
get<Binaries>().givenBinariesDir
|
get<Binaries>().givenBinariesDir
|
||||||
@@ -403,7 +371,7 @@ internal class TestCompilationFactory {
|
|||||||
klibArtifact.klibFile.parentFile
|
klibArtifact.klibFile.parentFile
|
||||||
}
|
}
|
||||||
|
|
||||||
return artifactBaseDir.resolve(if (header) HEADER_CACHE_DIR_NAME else STATIC_CACHE_DIR_NAME).apply { mkdirs() }
|
return artifactBaseDir.resolve(STATIC_CACHE_DIR_NAME).apply { mkdirs() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Settings.singleModuleArtifactFile(module: TestModule.Exclusive, extension: String): File {
|
private fun Settings.singleModuleArtifactFile(module: TestModule.Exclusive, extension: String): File {
|
||||||
|
|||||||
+1
-4
@@ -210,7 +210,6 @@ sealed class CacheMode {
|
|||||||
abstract val staticCacheForDistributionLibrariesRootDir: File?
|
abstract val staticCacheForDistributionLibrariesRootDir: File?
|
||||||
abstract val useStaticCacheForUserLibraries: Boolean
|
abstract val useStaticCacheForUserLibraries: Boolean
|
||||||
abstract val makePerFileCaches: Boolean
|
abstract val makePerFileCaches: Boolean
|
||||||
abstract val useHeaders: Boolean
|
|
||||||
abstract val alias: Alias
|
abstract val alias: Alias
|
||||||
|
|
||||||
val useStaticCacheForDistributionLibraries: Boolean get() = staticCacheForDistributionLibrariesRootDir != null
|
val useStaticCacheForDistributionLibraries: Boolean get() = staticCacheForDistributionLibrariesRootDir != null
|
||||||
@@ -219,7 +218,6 @@ sealed class CacheMode {
|
|||||||
override val staticCacheForDistributionLibrariesRootDir: File? get() = null
|
override val staticCacheForDistributionLibrariesRootDir: File? get() = null
|
||||||
override val useStaticCacheForUserLibraries: Boolean get() = false
|
override val useStaticCacheForUserLibraries: Boolean get() = false
|
||||||
override val makePerFileCaches: Boolean = false
|
override val makePerFileCaches: Boolean = false
|
||||||
override val useHeaders = false
|
|
||||||
override val alias = Alias.NO
|
override val alias = Alias.NO
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +227,6 @@ sealed class CacheMode {
|
|||||||
optimizationMode: OptimizationMode,
|
optimizationMode: OptimizationMode,
|
||||||
override val useStaticCacheForUserLibraries: Boolean,
|
override val useStaticCacheForUserLibraries: Boolean,
|
||||||
override val makePerFileCaches: Boolean,
|
override val makePerFileCaches: Boolean,
|
||||||
override val useHeaders: Boolean,
|
|
||||||
override val alias: Alias,
|
override val alias: Alias,
|
||||||
) : CacheMode() {
|
) : CacheMode() {
|
||||||
init {
|
init {
|
||||||
@@ -258,7 +255,7 @@ sealed class CacheMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Alias { NO, STATIC_ONLY_DIST, STATIC_EVERYWHERE, STATIC_PER_FILE_EVERYWHERE, STATIC_USE_HEADERS_EVERYWHERE }
|
enum class Alias { NO, STATIC_ONLY_DIST, STATIC_EVERYWHERE, STATIC_PER_FILE_EVERYWHERE }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun defaultForTestTarget(distribution: Distribution, kotlinNativeTargets: KotlinNativeTargets): Alias {
|
fun defaultForTestTarget(distribution: Distribution, kotlinNativeTargets: KotlinNativeTargets): Alias {
|
||||||
|
|||||||
-1
@@ -33,7 +33,6 @@ internal const val SHARED_MODULES_DIR_NAME = "__shared_modules__"
|
|||||||
internal const val GIVEN_MODULES_DIR_NAME = "__given_modules__"
|
internal const val GIVEN_MODULES_DIR_NAME = "__given_modules__"
|
||||||
|
|
||||||
internal const val STATIC_CACHE_DIR_NAME = "__static_cache__"
|
internal const val STATIC_CACHE_DIR_NAME = "__static_cache__"
|
||||||
internal const val HEADER_CACHE_DIR_NAME = "__header_cache__"
|
|
||||||
|
|
||||||
internal fun prettyHash(hash: Int): String = hash.toUInt().toString(16).padStart(8, '0')
|
internal fun prettyHash(hash: Int): String = hash.toUInt().toString(16).padStart(8, '0')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user