[KLIB Resolver] Don't log any messages in isKotlinLibrary(File) fun
This function is only used for probing if a library at the given path exists. Any errors or warnings logged by this function could only bring a user to a confusion. So, it's better to avoid any logging here. ^KT-63573
This commit is contained in:
committed by
Space Team
parent
46081f968d
commit
3ab35cd417
@@ -21,6 +21,8 @@ import org.jetbrains.kotlin.konan.file.ZipFileSystemAccessor
|
||||
import org.jetbrains.kotlin.konan.properties.Properties
|
||||
import org.jetbrains.kotlin.konan.properties.loadProperties
|
||||
import org.jetbrains.kotlin.library.*
|
||||
import org.jetbrains.kotlin.util.DummyLogger
|
||||
import org.jetbrains.kotlin.util.Logger
|
||||
|
||||
class BaseKotlinLibraryImpl(
|
||||
val access: BaseLibraryAccess<KotlinLibraryLayout>,
|
||||
@@ -356,8 +358,25 @@ fun createKotlinLibraryComponents(
|
||||
}
|
||||
|
||||
fun isKotlinLibrary(libraryFile: File): Boolean = try {
|
||||
resolveSingleFileKlib(libraryFile)
|
||||
true
|
||||
val libraryPath = libraryFile.absolutePath
|
||||
|
||||
/**
|
||||
* Important: Try to resolve it as a "lenient" library. This will allow to probe a library
|
||||
* without logging any errors to [DummyLogger] and without any side effects such as throwing an
|
||||
* exception from [SingleKlibComponentResolver.resolve] if the library is not found.
|
||||
*/
|
||||
SingleKlibComponentResolver(
|
||||
klibFile = libraryPath,
|
||||
logger = object : Logger {
|
||||
override fun log(message: String) = Unit // don't log
|
||||
override fun error(message: String) = Unit // don't log
|
||||
override fun warning(message: String) = Unit // don't log
|
||||
override fun fatal(message: String): Nothing = kotlin.error("This function should not be called")
|
||||
},
|
||||
knownIrProviders = emptyList()
|
||||
).resolve(
|
||||
LenientUnresolvedLibrary(libraryPath, libraryVersion = null)
|
||||
) != null
|
||||
} catch (e: Throwable) {
|
||||
false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user