[Target] Make KonanPropertiesLoader host-independent
This commit is contained in:
committed by
Sergey Bogolepov
parent
2d3766b519
commit
bffca00ff4
@@ -18,7 +18,10 @@ package org.jetbrains.kotlin.konan.properties
|
||||
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.Configurables
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.util.ArchiveType
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
import java.io.File
|
||||
|
||||
interface TargetableExternalStorage {
|
||||
fun targetString(key: String): String?
|
||||
@@ -33,7 +36,8 @@ interface TargetableExternalStorage {
|
||||
|
||||
abstract class KonanPropertiesLoader(override val target: KonanTarget,
|
||||
val properties: Properties,
|
||||
val baseDir: String? = null) : Configurables {
|
||||
private val baseDir: String? = null,
|
||||
private val host: KonanTarget = HostManager.host) : Configurables {
|
||||
open val dependencies get() = hostTargetList("dependencies")
|
||||
|
||||
override fun downloadDependencies() {
|
||||
@@ -45,17 +49,30 @@ abstract class KonanPropertiesLoader(override val target: KonanTarget,
|
||||
override fun targetList(key: String): List<String>
|
||||
= properties.targetList(key, target)
|
||||
override fun hostString(key: String): String?
|
||||
= properties.hostString(key)
|
||||
= properties.hostString(key, host)
|
||||
override fun hostList(key: String): List<String>
|
||||
= properties.hostList(key)
|
||||
= properties.hostList(key, host)
|
||||
override fun hostTargetString(key: String): String?
|
||||
= properties.hostTargetString(key, target)
|
||||
= properties.hostTargetString(key, target, host)
|
||||
override fun hostTargetList(key: String): List<String>
|
||||
= properties.hostTargetList(key, target)
|
||||
= properties.hostTargetList(key, target, host)
|
||||
|
||||
override fun absolute(value: String?): String =
|
||||
dependencyProcessor!!.resolveRelative(value!!).absolutePath
|
||||
private val dependencyProcessor by lazy {
|
||||
baseDir?.let { DependencyProcessor(java.io.File(it), this) }
|
||||
baseDir?.let {
|
||||
DependencyProcessor(
|
||||
dependenciesRoot = File(baseDir),
|
||||
properties = this,
|
||||
archiveType = defaultArchiveTypeByHost(host)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun defaultArchiveTypeByHost(host: KonanTarget): ArchiveType = when (host) {
|
||||
KonanTarget.LINUX_X64 -> ArchiveType.TAR_GZ
|
||||
KonanTarget.MACOS_X64 -> ArchiveType.TAR_GZ
|
||||
KonanTarget.MINGW_X64 -> ArchiveType.ZIP
|
||||
else -> error("$host can't be a host platform!")
|
||||
}
|
||||
@@ -18,11 +18,11 @@ package org.jetbrains.kotlin.konan.properties
|
||||
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
|
||||
fun Properties.hostString(name: String): String?
|
||||
= this.propertyString(name, HostManager.hostName)
|
||||
fun Properties.hostString(name: String, host: KonanTarget): String?
|
||||
= this.propertyString(name, host.name)
|
||||
|
||||
fun Properties.hostList(name: String): List<String>
|
||||
= this.propertyList(name, HostManager.hostName)
|
||||
fun Properties.hostList(name: String, host: KonanTarget): List<String>
|
||||
= this.propertyList(name, host.name)
|
||||
|
||||
fun Properties.targetString(name: String, target: KonanTarget): String?
|
||||
= this.propertyString(name, target.name)
|
||||
@@ -30,8 +30,8 @@ fun Properties.targetString(name: String, target: KonanTarget): String?
|
||||
fun Properties.targetList(name: String, target: KonanTarget): List<String>
|
||||
= this.propertyList(name, target.name)
|
||||
|
||||
fun Properties.hostTargetString(name: String, target: KonanTarget): String?
|
||||
= this.propertyString(name, hostTargetSuffix(HostManager.host, target))
|
||||
fun Properties.hostTargetString(name: String, target: KonanTarget, host: KonanTarget): String?
|
||||
= this.propertyString(name, hostTargetSuffix(host, target))
|
||||
|
||||
fun Properties.hostTargetList(name: String, target: KonanTarget): List<String>
|
||||
= this.propertyList(name, hostTargetSuffix(HostManager.host, target))
|
||||
fun Properties.hostTargetList(name: String, target: KonanTarget, host: KonanTarget): List<String>
|
||||
= this.propertyList(name, hostTargetSuffix(host, target))
|
||||
Reference in New Issue
Block a user