Fix simulator runtime availability checking on older Xcode/macOS.
This commit is contained in:
committed by
Sergey Bogolepov
parent
992afd5aed
commit
be846bd1f5
@@ -102,14 +102,17 @@ open class FrameworkTest : DefaultTask() {
|
|||||||
KonanTarget.MACOS_X64 -> "macosx"
|
KonanTarget.MACOS_X64 -> "macosx"
|
||||||
else -> throw IllegalStateException("Test target $target is not supported")
|
else -> throw IllegalStateException("Test target $target is not supported")
|
||||||
}
|
}
|
||||||
return when (target) {
|
val simulatorPath = when (target) {
|
||||||
KonanTarget.TVOS_X64,
|
KonanTarget.TVOS_X64,
|
||||||
KonanTarget.IOS_X64,
|
KonanTarget.IOS_X64,
|
||||||
KonanTarget.WATCHOS_X64 -> Xcode.current.getLatestSimulatorRuntimeFor(target, configs.osVersionMin)?.let {
|
KonanTarget.WATCHOS_X64 -> Xcode.current.getLatestSimulatorRuntimeFor(target, configs.osVersionMin)?.bundlePath?.let {
|
||||||
"${it.bundlePath}/Contents/Resources/RuntimeRoot/usr/lib/swift"
|
"$it/Contents/Resources/RuntimeRoot/usr/lib/swift"
|
||||||
} ?: error("Simulator runtime for $target ${configs.osVersionMin} is not available")
|
}
|
||||||
else -> configs.absoluteTargetToolchain + "/usr/lib/swift/$swiftPlatform"
|
else -> null
|
||||||
}
|
}
|
||||||
|
// Use default path from toolchain if we cannot get `bundlePath` for target.
|
||||||
|
// It may be the case for simulators if Xcode/macOS is old.
|
||||||
|
return simulatorPath ?: configs.absoluteTargetToolchain + "/usr/lib/swift/$swiftPlatform"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildEnvironment(): Map<String, String> {
|
private fun buildEnvironment(): Map<String, String> {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ fun Xcode.getLatestSimulatorRuntimeFor(target: KonanTarget, osMinVersion: String
|
|||||||
else -> error("Unexpected simulator target: $target")
|
else -> error("Unexpected simulator target: $target")
|
||||||
}
|
}
|
||||||
return getSimulatorRuntimeDescriptors().firstOrNull {
|
return getSimulatorRuntimeDescriptors().firstOrNull {
|
||||||
it.isAvailable && it.name.startsWith(osName) && compareStringsAsVersions(it.version, osMinVersion) >= 0
|
it.checkAvailability() && it.name.startsWith(osName) && compareStringsAsVersions(it.version, osMinVersion) >= 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,9 +51,21 @@ data class ListRuntimesReport(
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class SimulatorRuntimeDescriptor(
|
data class SimulatorRuntimeDescriptor(
|
||||||
val version: String,
|
val version: String,
|
||||||
val bundlePath: String,
|
// bundlePath field may not exist in the old Xcode (prior to 10.3).
|
||||||
val isAvailable: Boolean,
|
val bundlePath: String? = null,
|
||||||
|
val isAvailable: Boolean? = null,
|
||||||
|
val availability: String? = null,
|
||||||
val name: String,
|
val name: String,
|
||||||
val identifier: String,
|
val identifier: String,
|
||||||
val buildversion: String
|
val buildversion: String
|
||||||
)
|
) {
|
||||||
|
/**
|
||||||
|
* Different Xcode/macOS combinations give different fields that checks
|
||||||
|
* runtime availability. This method is an umbrella for these fields.
|
||||||
|
*/
|
||||||
|
fun checkAvailability(): Boolean {
|
||||||
|
if (isAvailable == true) return true
|
||||||
|
if (availability?.contains("unavailable") == true) return false
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user