Add Xcode version check
This commit is contained in:
committed by
Ilya Matveev
parent
155fcf1b37
commit
7c3e0bb801
@@ -25,8 +25,8 @@ dependencyProfiles = default alt
|
|||||||
airplaneMode = false
|
airplaneMode = false
|
||||||
# if true, ignores Xcode version check.
|
# if true, ignores Xcode version check.
|
||||||
ignoreXcodeVersionCheck = false
|
ignoreXcodeVersionCheck = false
|
||||||
# Disabled until decided better mechanism.
|
|
||||||
# useFixedXcodeVersion = 11.0
|
minimalXcodeVersion=11.0
|
||||||
|
|
||||||
downloadingAttempts = 10
|
downloadingAttempts = 10
|
||||||
downloadingAttemptIntervalMs = 3000
|
downloadingAttemptIntervalMs = 3000
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.konan.target
|
|||||||
import org.jetbrains.kotlin.konan.properties.KonanPropertiesLoader
|
import org.jetbrains.kotlin.konan.properties.KonanPropertiesLoader
|
||||||
import org.jetbrains.kotlin.konan.properties.Properties
|
import org.jetbrains.kotlin.konan.properties.Properties
|
||||||
import org.jetbrains.kotlin.konan.util.InternalServer
|
import org.jetbrains.kotlin.konan.util.InternalServer
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
class AppleConfigurablesImpl(
|
class AppleConfigurablesImpl(
|
||||||
target: KonanTarget,
|
target: KonanTarget,
|
||||||
@@ -63,19 +64,36 @@ class AppleConfigurablesImpl(
|
|||||||
XcodePartsProvider.InternalServer
|
XcodePartsProvider.InternalServer
|
||||||
} else {
|
} else {
|
||||||
val xcode = Xcode.current
|
val xcode = Xcode.current
|
||||||
properties.getProperty("useFixedXcodeVersion")?.let { requiredXcodeVersion ->
|
|
||||||
val currentXcodeVersion = xcode.version
|
|
||||||
|
|
||||||
if (properties.getProperty("ignoreXcodeVersionCheck") != "true" &&
|
if (properties.getProperty("ignoreXcodeVersionCheck") != "true") {
|
||||||
currentXcodeVersion != requiredXcodeVersion) {
|
properties.getProperty("minimalXcodeVersion")?.let { minimalXcodeVersion ->
|
||||||
error("expected Xcode version $requiredXcodeVersion, got $currentXcodeVersion, consider updating " +
|
val currentXcodeVersion = xcode.version
|
||||||
"Xcode or use \"ignoreXcodeVersionCheck\" variable in konan.properties")
|
checkXcodeVersion(minimalXcodeVersion, currentXcodeVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XcodePartsProvider.Local(xcode)
|
XcodePartsProvider.Local(xcode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkXcodeVersion(minimalVersion: String, currentVersion: String) {
|
||||||
|
// Xcode versions contain only numbers (even betas).
|
||||||
|
// But we still split by '-' and whitespaces to take into account versions like 11.2-beta.
|
||||||
|
val minimalVersionParts = minimalVersion.split("(\\s+|\\.|-)".toRegex()).map { it.toIntOrNull() ?: 0 }
|
||||||
|
val currentVersionParts = currentVersion.split("(\\s+|\\.|-)".toRegex()).map { it.toIntOrNull() ?: 0 }
|
||||||
|
val size = max(minimalVersionParts.size, currentVersionParts.size)
|
||||||
|
|
||||||
|
for (i in 0 until size) {
|
||||||
|
val currentPart = currentVersionParts.getOrElse(i) { 0 }
|
||||||
|
val minimalPart = minimalVersionParts.getOrElse(i) { 0 }
|
||||||
|
|
||||||
|
when {
|
||||||
|
currentPart > minimalPart -> return
|
||||||
|
currentPart < minimalPart ->
|
||||||
|
error("Unsupported Xcode version $currentVersion, minimal supported version is $minimalVersion.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private sealed class XcodePartsProvider {
|
private sealed class XcodePartsProvider {
|
||||||
class Local(val xcode: Xcode) : XcodePartsProvider()
|
class Local(val xcode: Xcode) : XcodePartsProvider()
|
||||||
object InternalServer : XcodePartsProvider()
|
object InternalServer : XcodePartsProvider()
|
||||||
|
|||||||
Reference in New Issue
Block a user