xcode: avoid invoking 'xcodebuild -version' twice
This primarily benefits CLT-only systems where invoking the `xcodebuild` wrapper in `/usr/bin` will fail (twice) with the following message: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance Closes #198. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
This commit is contained in:
parent
5ee797eb61
commit
d579dbb4ca
@ -81,14 +81,19 @@ module OS
|
|||||||
|
|
||||||
return nil if !MacOS::Xcode.installed? && !MacOS::CLT.installed?
|
return nil if !MacOS::Xcode.installed? && !MacOS::CLT.installed?
|
||||||
|
|
||||||
%W[#{prefix}/usr/bin/xcodebuild #{which("xcodebuild")}].uniq.each do |path|
|
%W[
|
||||||
if File.file? path
|
#{prefix}/usr/bin/xcodebuild
|
||||||
Utils.popen_read(path, "-version") =~ /Xcode (\d(\.\d)*)/
|
#{which("xcodebuild")}
|
||||||
return $1 if $1
|
].uniq.each do |xcodebuild_path|
|
||||||
|
if File.executable? xcodebuild_path
|
||||||
|
xcodebuild_output = Utils.popen_read(xcodebuild_path, "-version")
|
||||||
|
next unless $?.success?
|
||||||
|
|
||||||
|
xcode_version = xcodebuild_output[/Xcode (\d(\.\d)*)/, 1]
|
||||||
|
return xcode_version if xcode_version
|
||||||
|
|
||||||
# Xcode 2.x's xcodebuild has a different version string
|
# Xcode 2.x's xcodebuild has a different version string
|
||||||
Utils.popen_read(path, "-version") =~ /DevToolsCore-(\d+\.\d)/
|
case xcodebuild_output[/DevToolsCore-(\d+\.\d)/, 1]
|
||||||
case $1
|
|
||||||
when "515.0" then return "2.0"
|
when "515.0" then return "2.0"
|
||||||
when "798.0" then return "2.5"
|
when "798.0" then return "2.5"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user