Merge pull request #16388 from Bo98/fast-xcode-version

os/mac/xcode: add fast path for Xcode version detection
This commit is contained in:
Bo Anderson 2023-12-23 03:09:16 +00:00 committed by GitHub
commit 3798cacc40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,6 +192,15 @@ module OS
# if return is used in the middle, which we do many times in here.
return if !MacOS::Xcode.installed? && !MacOS::CLT.installed?
if MacOS::Xcode.installed?
# Fast path that will probably almost always work unless `xcode-select -p` is misconfigured
version_plist = T.must(prefix).parent/"version.plist"
if version_plist.file?
data = Plist.parse_xml(version_plist, marshal: false)
version = data["CFBundleShortVersionString"] if data
return version if version
end
%W[
#{prefix}/usr/bin/xcodebuild
#{which("xcodebuild")}
@ -210,6 +219,7 @@ module OS
when "515.0" then return "2.0"
end
end
end
detect_version_from_clang_version
end