diff --git a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanProperties.kt b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanProperties.kt index f33c991f3b8..7d78389b393 100644 --- a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanProperties.kt +++ b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanProperties.kt @@ -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 = properties.targetList(key, target) override fun hostString(key: String): String? - = properties.hostString(key) + = properties.hostString(key, host) override fun hostList(key: String): List - = 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 - = 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!") } \ No newline at end of file diff --git a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/TargetProperties.kt b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/TargetProperties.kt index ee1c4634086..09983514390 100644 --- a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/TargetProperties.kt +++ b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/TargetProperties.kt @@ -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 - = this.propertyList(name, HostManager.hostName) +fun Properties.hostList(name: String, host: KonanTarget): List + = 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 = 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 - = this.propertyList(name, hostTargetSuffix(HostManager.host, target)) \ No newline at end of file +fun Properties.hostTargetList(name: String, target: KonanTarget, host: KonanTarget): List + = this.propertyList(name, hostTargetSuffix(host, target)) \ No newline at end of file