Prepare test infrastructure for Apple Silicon simulators.
* Get rid of explicit target enumerations by using TargetTriple. * Remove some code duplication with `project.testTargetConfigurables`
This commit is contained in:
committed by
TeamCityServer
parent
cebf815fed
commit
437a0aa450
@@ -32,16 +32,7 @@ class AppleConfigurablesImpl(
|
||||
private val xcodeAddonDependency = this.additionalToolsDir!!
|
||||
|
||||
override val absoluteTargetSysRoot: String get() = when (val provider = xcodePartsProvider) {
|
||||
is XcodePartsProvider.Local -> when (target) {
|
||||
KonanTarget.MACOS_X64, KonanTarget.MACOS_ARM64 -> provider.xcode.macosxSdk
|
||||
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64 -> provider.xcode.iphoneosSdk
|
||||
KonanTarget.IOS_X64 -> provider.xcode.iphonesimulatorSdk
|
||||
KonanTarget.TVOS_ARM64 -> provider.xcode.appletvosSdk
|
||||
KonanTarget.TVOS_X64 -> provider.xcode.appletvsimulatorSdk
|
||||
KonanTarget.WATCHOS_ARM64, KonanTarget.WATCHOS_ARM32 -> provider.xcode.watchosSdk
|
||||
KonanTarget.WATCHOS_X64, KonanTarget.WATCHOS_X86 -> provider.xcode.watchsimulatorSdk
|
||||
else -> error(target)
|
||||
}
|
||||
is XcodePartsProvider.Local -> provider.xcode.pathToPlatformSdk(platformName())
|
||||
XcodePartsProvider.InternalServer -> absolute(sdkDependency)
|
||||
}
|
||||
|
||||
@@ -101,3 +92,26 @@ class AppleConfigurablesImpl(
|
||||
object InternalServer : XcodePartsProvider()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of an Apple platform as in Xcode.app/Contents/Developer/Platforms.
|
||||
*/
|
||||
fun AppleConfigurables.platformName(): String = when (target.family) {
|
||||
Family.OSX -> "MacOSX"
|
||||
Family.IOS -> if (targetTriple.isSimulator) {
|
||||
"iPhoneSimulator"
|
||||
} else {
|
||||
"iPhoneOS"
|
||||
}
|
||||
Family.TVOS -> if (targetTriple.isSimulator) {
|
||||
"AppleTVSimulator"
|
||||
} else {
|
||||
"AppleTVOS"
|
||||
}
|
||||
Family.WATCHOS -> if (targetTriple.isSimulator) {
|
||||
"WatchSimulator"
|
||||
} else {
|
||||
"WatchOS"
|
||||
}
|
||||
else -> error("Not an Apple target: $target")
|
||||
}
|
||||
|
||||
+15
-1
@@ -50,4 +50,18 @@ data class TargetTriple(
|
||||
?: ""
|
||||
return "$architecture-$vendor-$os$envSuffix"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that given target is Apple simulator.
|
||||
*/
|
||||
val TargetTriple.isSimulator: Boolean
|
||||
get() = environment == "simulator"
|
||||
|
||||
/**
|
||||
* Appends version to OS part of triple.
|
||||
*
|
||||
* Useful for precise target specification in Clang and Swift.
|
||||
*/
|
||||
fun TargetTriple.withOSVersion(osVersion: String): TargetTriple =
|
||||
copy(os = "${os}${osVersion}")
|
||||
@@ -35,6 +35,17 @@ interface Xcode {
|
||||
val additionalTools: String
|
||||
val simulatorRuntimes: String
|
||||
|
||||
fun pathToPlatformSdk(platformName: String): String = when (platformName.toLowerCase()) {
|
||||
"macosx" -> macosxSdk
|
||||
"iphoneos" -> iphoneosSdk
|
||||
"iphonesimulator" -> iphonesimulatorSdk
|
||||
"appletvos" -> appletvosSdk
|
||||
"appletvsimulator" -> appletvsimulatorSdk
|
||||
"watchos" -> watchosSdk
|
||||
"watchsimulator" -> watchsimulatorSdk
|
||||
else -> error("Unknown Apple platform: $platformName")
|
||||
}
|
||||
|
||||
companion object {
|
||||
val current: Xcode by lazy {
|
||||
CurrentXcode
|
||||
|
||||
Reference in New Issue
Block a user