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"
|
||||
else -> throw IllegalStateException("Test target $target is not supported")
|
||||
}
|
||||
return when (target) {
|
||||
val simulatorPath = when (target) {
|
||||
KonanTarget.TVOS_X64,
|
||||
KonanTarget.IOS_X64,
|
||||
KonanTarget.WATCHOS_X64 -> Xcode.current.getLatestSimulatorRuntimeFor(target, configs.osVersionMin)?.let {
|
||||
"${it.bundlePath}/Contents/Resources/RuntimeRoot/usr/lib/swift"
|
||||
} ?: error("Simulator runtime for $target ${configs.osVersionMin} is not available")
|
||||
else -> configs.absoluteTargetToolchain + "/usr/lib/swift/$swiftPlatform"
|
||||
KonanTarget.WATCHOS_X64 -> Xcode.current.getLatestSimulatorRuntimeFor(target, configs.osVersionMin)?.bundlePath?.let {
|
||||
"$it/Contents/Resources/RuntimeRoot/usr/lib/swift"
|
||||
}
|
||||
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> {
|
||||
|
||||
@@ -38,7 +38,7 @@ fun Xcode.getLatestSimulatorRuntimeFor(target: KonanTarget, osMinVersion: String
|
||||
else -> error("Unexpected simulator target: $target")
|
||||
}
|
||||
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
|
||||
data class SimulatorRuntimeDescriptor(
|
||||
val version: String,
|
||||
val bundlePath: String,
|
||||
val isAvailable: Boolean,
|
||||
// bundlePath field may not exist in the old Xcode (prior to 10.3).
|
||||
val bundlePath: String? = null,
|
||||
val isAvailable: Boolean? = null,
|
||||
val availability: String? = null,
|
||||
val name: String,
|
||||
val identifier: 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