Slightly tweaked klib utility to work with suffix-less klib names.

This commit is contained in:
Alexander Gorshenev
2017-06-20 13:38:46 +03:00
committed by alexander-gorshenev
parent 1ad50bc33f
commit 7615c36f2e
4 changed files with 90 additions and 39 deletions
@@ -89,11 +89,11 @@ interface SplitLibraryScheme {
}
class SplitLibraryReader(override val libDir: File, currentAbiVersion: Int,
override val target: String) :
override val target: String?) :
FileBasedLibraryReader(libDir, currentAbiVersion, SplitMetadataReader(libDir)),
SplitLibraryScheme {
public constructor(path: String, currentAbiVersion: Int, target: String) :
public constructor(path: String, currentAbiVersion: Int, target: String?) :
this(File(path), currentAbiVersion, target)
init {
@@ -26,16 +26,16 @@ interface SearchPathResolver {
}
class KonanLibrarySearchPathResolver(repositories: List<String>,
val distributionKlib: String, val localKonanDir: String): SearchPathResolver {
val distributionKlib: String?, val localKonanDir: String?, val skipCurrentDir: Boolean = false): SearchPathResolver {
val localHead: File
get() = File(localKonanDir).klib
val localHead: File?
get() = localKonanDir?.File()?.klib
val distHead: File
get() = File(distributionKlib)
val distHead: File?
get() = distributionKlib?.File()
val currentDirHead: File
get() = File.userDir
val currentDirHead: File?
get() = if (!skipCurrentDir) File.userDir else null
private val repoRoots: List<File> by lazy {
repositories.map{File(it).klib}
@@ -43,7 +43,7 @@ class KonanLibrarySearchPathResolver(repositories: List<String>,
// This is the place where we specify the order of library search.
override val searchRoots: List<File> by lazy {
listOf(currentDirHead) + repoRoots + listOf(localHead, distHead)
(listOf(currentDirHead) + repoRoots + listOf(localHead, distHead)).filterNotNull()
}
private fun found(candidate: File): File? {
@@ -68,10 +68,10 @@ class KonanLibrarySearchPathResolver(repositories: List<String>,
found(File(it, givenPath))?.apply{return this}
}
}
error("Could not find \"$givenPath\" in any of the provided locations.")
error("Could not find \"$givenPath\" in ${searchRoots.map{it.absolutePath}}.")
}
private val File.klib
private val File.klib
get() = File(this, "klib")
}
@@ -64,9 +64,13 @@ class File(val path: String) {
companion object {
val userDir
get() = File(System.getProperty("user.dir"))
val userHome
get() = File(System.getProperty("user.home"))
}
}
fun String.File() = File(this)
private val File.zipUri: URI
get() = URI.create("jar:${this.toPath().toUri()}")