diff options
| author | Martin Afanasjew | 2016-05-04 20:44:19 +0200 |
|---|---|---|
| committer | Martin Afanasjew | 2016-05-05 23:34:40 +0200 |
| commit | d579dbb4cadefb732a907fdda97d400a0cef2f2d (patch) | |
| tree | 726c3a77b93073a32ea2f05c53a85c45cd76d127 /Library | |
| parent | 5ee797eb610205c232ab6d5f76c68bfc5834f6b9 (diff) | |
| download | brew-d579dbb4cadefb732a907fdda97d400a0cef2f2d.tar.bz2 | |
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>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/os/mac/xcode.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index f85cea9f5..fc2762655 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -81,14 +81,19 @@ module OS return nil if !MacOS::Xcode.installed? && !MacOS::CLT.installed? - %W[#{prefix}/usr/bin/xcodebuild #{which("xcodebuild")}].uniq.each do |path| - if File.file? path - Utils.popen_read(path, "-version") =~ /Xcode (\d(\.\d)*)/ - return $1 if $1 + %W[ + #{prefix}/usr/bin/xcodebuild + #{which("xcodebuild")} + ].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 - Utils.popen_read(path, "-version") =~ /DevToolsCore-(\d+\.\d)/ - case $1 + case xcodebuild_output[/DevToolsCore-(\d+\.\d)/, 1] when "515.0" then return "2.0" when "798.0" then return "2.5" end |
