Minor: Formatted

This commit is contained in:
Dmitriy Dolovov
2020-01-29 21:53:39 +07:00
parent 8028a3f55b
commit 1053428ee4
@@ -8,7 +8,7 @@ import org.jetbrains.kotlin.util.*
const val KOTLIN_STDLIB_NAME = "stdlib" const val KOTLIN_STDLIB_NAME = "stdlib"
interface SearchPathResolver<L: KotlinLibrary> : WithLogger { interface SearchPathResolver<L : KotlinLibrary> : WithLogger {
val searchRoots: List<File> val searchRoots: List<File>
fun resolutionSequence(givenPath: String): Sequence<File> fun resolutionSequence(givenPath: String): Sequence<File>
fun resolve(unresolved: UnresolvedLibrary, isDefaultLink: Boolean = false): L fun resolve(unresolved: UnresolvedLibrary, isDefaultLink: Boolean = false): L
@@ -18,19 +18,19 @@ interface SearchPathResolver<L: KotlinLibrary> : WithLogger {
fun isProvidedByDefault(unresolved: UnresolvedLibrary): Boolean = false fun isProvidedByDefault(unresolved: UnresolvedLibrary): Boolean = false
} }
interface SearchPathResolverWithAttributes<L: KotlinLibrary>: SearchPathResolver<L> { interface SearchPathResolverWithAttributes<L : KotlinLibrary> : SearchPathResolver<L> {
val knownAbiVersions: List<KotlinAbiVersion>? val knownAbiVersions: List<KotlinAbiVersion>?
val knownCompilerVersions: List<CompilerVersion>? val knownCompilerVersions: List<CompilerVersion>?
} }
// This is a simple library resolver that only cares for file names. // This is a simple library resolver that only cares for file names.
abstract class KotlinLibrarySearchPathResolver<L: KotlinLibrary> ( abstract class KotlinLibrarySearchPathResolver<L : KotlinLibrary>(
repositories: List<String>, repositories: List<String>,
directLibs: List<String>, directLibs: List<String>,
val distributionKlib: String?, val distributionKlib: String?,
val localKotlinDir: String?, val localKotlinDir: String?,
val skipCurrentDir: Boolean, val skipCurrentDir: Boolean,
override val logger: Logger override val logger: Logger
) : SearchPathResolver<L> { ) : SearchPathResolver<L> {
val localHead: File? val localHead: File?
@@ -96,14 +96,14 @@ abstract class KotlinLibrarySearchPathResolver<L: KotlinLibrary> (
return sequence.filterNotNull() return sequence.filterNotNull()
} }
private fun Sequence<File>.filterOutPre_1_4_libraries(): Sequence<File> = this.filter{ private fun Sequence<File>.filterOutPre_1_4_libraries(): Sequence<File> = this.filter {
if (it.isPre_1_4_Library) { if (it.isPre_1_4_Library) {
logger.warning("Skipping \"$it\" as it is a pre 1.4 library") logger.warning("Skipping \"$it\" as it is a pre 1.4 library")
false false
} else { } else {
true true
}
} }
}
override fun resolve(unresolved: UnresolvedLibrary, isDefaultLink: Boolean): L { override fun resolve(unresolved: UnresolvedLibrary, isDefaultLink: Boolean): L {
val givenPath = unresolved.path val givenPath = unresolved.path
@@ -171,15 +171,15 @@ abstract class KotlinLibrarySearchPathResolver<L: KotlinLibrary> (
} }
fun CompilerVersion.compatible(other: CompilerVersion) = fun CompilerVersion.compatible(other: CompilerVersion) =
this.major == other.major this.major == other.major
&& this.minor == other.minor && this.minor == other.minor
&& this.maintenance == other.maintenance && this.maintenance == other.maintenance
// This is a library resolver aware of attributes shared between platforms, // This is a library resolver aware of attributes shared between platforms,
// such as abi version. // such as abi version.
// JS and Native resolvers are inherited from this one. // JS and Native resolvers are inherited from this one.
abstract class KotlinLibraryProperResolverWithAttributes<L: KotlinLibrary>( abstract class KotlinLibraryProperResolverWithAttributes<L : KotlinLibrary>(
repositories: List<String>, repositories: List<String>,
directLibs: List<String>, directLibs: List<String>,
override val knownAbiVersions: List<KotlinAbiVersion>?, override val knownAbiVersions: List<KotlinAbiVersion>?,
@@ -190,8 +190,7 @@ abstract class KotlinLibraryProperResolverWithAttributes<L: KotlinLibrary>(
override val logger: Logger, override val logger: Logger,
private val knownIrProviders: List<String> private val knownIrProviders: List<String>
) : KotlinLibrarySearchPathResolver<L>(repositories, directLibs, distributionKlib, localKotlinDir, skipCurrentDir, logger), ) : KotlinLibrarySearchPathResolver<L>(repositories, directLibs, distributionKlib, localKotlinDir, skipCurrentDir, logger),
SearchPathResolverWithAttributes<L> SearchPathResolverWithAttributes<L> {
{
override fun libraryMatch(candidate: L, unresolved: UnresolvedLibrary): Boolean { override fun libraryMatch(candidate: L, unresolved: UnresolvedLibrary): Boolean {
val candidatePath = candidate.libraryFile.absolutePath val candidatePath = candidate.libraryFile.absolutePath
@@ -239,13 +238,14 @@ class SingleKlibComponentResolver(
override fun libraryComponentBuilder(file: File, isDefault: Boolean) = createKotlinLibraryComponents(file, isDefault) override fun libraryComponentBuilder(file: File, isDefault: Boolean) = createKotlinLibraryComponents(file, isDefault)
} }
fun resolveSingleFileKlib(libraryFile: File, fun resolveSingleFileKlib(
logger: Logger = object : Logger { libraryFile: File,
override fun log(message: String) {} logger: Logger = object : Logger {
override fun error(message: String) = kotlin.error("e: $message") override fun log(message: String) {}
override fun warning(message: String) {} override fun error(message: String) = kotlin.error("e: $message")
override fun fatal(message: String) = kotlin.error("e: $message") override fun warning(message: String) {}
} override fun fatal(message: String) = kotlin.error("e: $message")
}
): KotlinLibrary { ): KotlinLibrary {
return SingleKlibComponentResolver(libraryFile.absolutePath, listOf(KotlinAbiVersion.CURRENT), logger).resolve(libraryFile.absolutePath) return SingleKlibComponentResolver(libraryFile.absolutePath, listOf(KotlinAbiVersion.CURRENT), logger).resolve(libraryFile.absolutePath)
} }