Allow to set dependencies from user's system
Currently it is impossible to set something like llvmHome.linux_x64 = /usr because DependencyProcessor has only `resolveRelative` method which looks only inside dependencies folder. Introduction of less restrictive `resolve` method solves this problem.
This commit is contained in:
committed by
Sergey Bogolepov
parent
f76cf52c81
commit
1615817905
Vendored
+1
-1
@@ -98,7 +98,7 @@ platformManager.filteredOutEnabledButNotSupported.each { target ->
|
||||
DependencyKind.values().each { kind ->
|
||||
def dir = kind.getDirectory(loader)
|
||||
if (dir != null) {
|
||||
String path = dependencyProcessor.resolveRelative(dir).canonicalPath
|
||||
String path = dependencyProcessor.resolve(dir).canonicalPath
|
||||
rootProject.ext.set(kind.getPropertyName(target), path)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ abstract class KonanPropertiesLoader(override val target: KonanTarget,
|
||||
= properties.hostTargetList(key, target, host)
|
||||
|
||||
override fun absolute(value: String?): String =
|
||||
dependencyProcessor!!.resolveRelative(value!!).absolutePath
|
||||
dependencyProcessor!!.resolve(value!!).absolutePath
|
||||
private val dependencyProcessor by lazy {
|
||||
baseDir?.let {
|
||||
DependencyProcessor(
|
||||
|
||||
@@ -249,7 +249,22 @@ class DependencyProcessor(dependenciesRoot: File,
|
||||
}
|
||||
}
|
||||
|
||||
fun resolveRelative(relative: String): File {
|
||||
/**
|
||||
* If given [path] is relative, resolves it relative to dependecies directory.
|
||||
* In case of absolute path just wraps it into a [File].
|
||||
*
|
||||
* Support of both relative and absolute path kinds allows to substitute predefined
|
||||
* dependencies with system ones.
|
||||
*
|
||||
* TODO: It looks like DependencyProcessor have two split responsibilities:
|
||||
* * Dependency resolving
|
||||
* * Dependency downloading
|
||||
* Also it is tightly tied to KonanProperties.
|
||||
*/
|
||||
fun resolve(path: String): File =
|
||||
if (Paths.get(path).isAbsolute) File(path) else resolveRelative(path)
|
||||
|
||||
private fun resolveRelative(relative: String): File {
|
||||
val path = Paths.get(relative)
|
||||
if (path.isAbsolute) error("not a relative path: $relative")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user