Native: rename Xcode.current to .findCurrent()

To reflect that it is a non-trivial operation with possible performance
overhead.
This commit is contained in:
Svyatoslav Scherbina
2022-02-11 16:30:25 +03:00
committed by Space
parent e92f7b5ec3
commit 5afbbecea4
5 changed files with 12 additions and 7 deletions
@@ -259,7 +259,7 @@ private fun simulator(project: Project): ExecutorService = object : ExecutorServ
}
private val simctl by lazy {
val sdk = Xcode.current.pathToPlatformSdk(configurables.platformName())
val sdk = Xcode.findCurrent().pathToPlatformSdk(configurables.platformName())
val out = ByteArrayOutputStream()
val result = project.exec {
commandLine("/usr/bin/xcrun", "--find", "simctl", "--sdk", sdk)
@@ -638,7 +638,7 @@ fun KonanTestExecutable.configureXcodeBuild() {
}
val sdk = when (project.testTarget) {
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64 -> Xcode.current.iphoneosSdk
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64 -> Xcode.findCurrent().iphoneosSdk
else -> error("Unsupported target: ${project.testTarget}")
}
@@ -200,7 +200,7 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
val configs = project.testTargetConfigurables as AppleConfigurables
val swiftPlatform = configs.platformName().toLowerCase()
val simulatorPath = when (configs.targetTriple.isSimulator) {
true -> Xcode.current.getLatestSimulatorRuntimeFor(configs.target.family, configs.osVersionMin)
true -> xcode.getLatestSimulatorRuntimeFor(configs.target.family, configs.osVersionMin)
?.bundlePath
?.let { "$it/Contents/Resources/RuntimeRoot/usr/lib/swift" }
else -> null
@@ -255,7 +255,7 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
if (configurables.targetTriple.isSimulator) {
return // bitcode-build-tool doesn't support simulators.
}
val sdk = Xcode.current.pathToPlatformSdk(configurables.platformName())
val sdk = xcode.pathToPlatformSdk(configurables.platformName())
val python3 = listOf("/usr/bin/python3", "/usr/local/bin/python3")
.map { Paths.get(it) }.firstOrNull { Files.exists(it) }
@@ -264,4 +264,6 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
runTest(executorService = localExecutorService(project), testExecutable = python3,
args = listOf("-B", bitcodeBuildTool, "--sdk", sdk, "-v", "-t", toolPath, frameworkBinary))
}
private val xcode by lazy { Xcode.findCurrent() }
}
@@ -56,7 +56,7 @@ object PlatformInfo {
&& properties.checkXcodeVersion
&& requiredMajorVersion != null
) {
val currentXcodeVersion = Xcode.current.version
val currentXcodeVersion = Xcode.findCurrent().version
val currentMajorVersion = currentXcodeVersion.splitToSequence('.').first()
if (currentMajorVersion != requiredMajorVersion) {
throw IllegalStateException(
@@ -55,7 +55,7 @@ class AppleConfigurablesImpl(
if (InternalServer.isAvailable) {
XcodePartsProvider.InternalServer
} else {
val xcode = Xcode.current
val xcode = Xcode.findCurrent()
if (properties.getProperty("ignoreXcodeVersionCheck") != "true") {
properties.getProperty("minimalXcodeVersion")?.let { minimalXcodeVersion ->
@@ -56,8 +56,11 @@ interface Xcode {
companion object {
// Don't cache the instance: the compiler might be executed in a Gradle daemon process,
// so current Xcode might actually change between different invocations.
@Deprecated("", ReplaceWith("this.findCurrent()"), DeprecationLevel.WARNING)
val current: Xcode
get() = CurrentXcode()
get() = findCurrent()
fun findCurrent(): Xcode = CurrentXcode()
}
}