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
|
||||
# if true, ignores Xcode version check.
|
||||
ignoreXcodeVersionCheck = false
|
||||
# Disabled until decided better mechanism.
|
||||
# useFixedXcodeVersion = 11.0
|
||||
|
||||
minimalXcodeVersion=11.0
|
||||
|
||||
downloadingAttempts = 10
|
||||
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.Properties
|
||||
import org.jetbrains.kotlin.konan.util.InternalServer
|
||||
import kotlin.math.max
|
||||
|
||||
class AppleConfigurablesImpl(
|
||||
target: KonanTarget,
|
||||
@@ -63,19 +64,36 @@ class AppleConfigurablesImpl(
|
||||
XcodePartsProvider.InternalServer
|
||||
} else {
|
||||
val xcode = Xcode.current
|
||||
properties.getProperty("useFixedXcodeVersion")?.let { requiredXcodeVersion ->
|
||||
val currentXcodeVersion = xcode.version
|
||||
|
||||
if (properties.getProperty("ignoreXcodeVersionCheck") != "true" &&
|
||||
currentXcodeVersion != requiredXcodeVersion) {
|
||||
error("expected Xcode version $requiredXcodeVersion, got $currentXcodeVersion, consider updating " +
|
||||
"Xcode or use \"ignoreXcodeVersionCheck\" variable in konan.properties")
|
||||
if (properties.getProperty("ignoreXcodeVersionCheck") != "true") {
|
||||
properties.getProperty("minimalXcodeVersion")?.let { minimalXcodeVersion ->
|
||||
val currentXcodeVersion = xcode.version
|
||||
checkXcodeVersion(minimalXcodeVersion, currentXcodeVersion)
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
class Local(val xcode: Xcode) : XcodePartsProvider()
|
||||
object InternalServer : XcodePartsProvider()
|
||||
|
||||
Reference in New Issue
Block a user