diff options
| author | David Broder-Rodgers | 2017-01-30 18:31:52 +0000 |
|---|---|---|
| committer | David Broder-Rodgers | 2017-01-30 18:31:52 +0000 |
| commit | 13a3a57fa86678e3a3cb9272fe04285cb538c55b (patch) | |
| tree | c345802d70ff32e2f787986b2f5392ac76f367fb /Library/Homebrew/os/mac/xcode.rb | |
| parent | 3c566399cf8dab3aff8c54381e7b83b0e6ef3995 (diff) | |
| parent | 35045b2934d94eabe302693a05b12fb530827454 (diff) | |
| download | brew-13a3a57fa86678e3a3cb9272fe04285cb538c55b.tar.bz2 | |
Merge remote-tracking branch 'origin/master' into insecure_audit
Diffstat (limited to 'Library/Homebrew/os/mac/xcode.rb')
| -rw-r--r-- | Library/Homebrew/os/mac/xcode.rb | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 8e51fc6b6..aa4504a17 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -3,8 +3,9 @@ module OS module Xcode module_function - V4_BUNDLE_ID = "com.apple.dt.Xcode".freeze - V3_BUNDLE_ID = "com.apple.Xcode".freeze + DEFAULT_BUNDLE_PATH = Pathname.new("/Applications/Xcode.app").freeze + BUNDLE_ID = "com.apple.dt.Xcode".freeze + OLD_BUNDLE_ID = "com.apple.Xcode".freeze def latest_version case MacOS.version @@ -51,9 +52,9 @@ module OS begin dir = MacOS.active_developer_dir - if dir.empty? || dir == CLT::MAVERICKS_PKG_PATH || !File.directory?(dir) + if dir.empty? || dir == CLT::PKG_PATH || !File.directory?(dir) path = bundle_path - path.join("Contents", "Developer") if path + path/"Contents/Developer" if path else # Use cleanpath to avoid pathological trailing slash Pathname.new(dir).cleanpath @@ -67,11 +68,14 @@ module OS Pathname.new("#{prefix}/Toolchains/XcodeDefault.xctoolchain") end - # Ask Spotlight where Xcode is. If the user didn't install the - # helper tools and installed Xcode in a non-conventional place, this - # is our only option. See: https://superuser.com/questions/390757 def bundle_path - MacOS.app_with_bundle_id(V4_BUNDLE_ID, V3_BUNDLE_ID) + # Use the default location if it exists. + return DEFAULT_BUNDLE_PATH if DEFAULT_BUNDLE_PATH.exist? + + # Ask Spotlight where Xcode is. If the user didn't install the + # helper tools and installed Xcode in a non-conventional place, this + # is our only option. See: https://superuser.com/questions/390757 + MacOS.app_with_bundle_id(BUNDLE_ID, OLD_BUNDLE_ID) end def installed? @@ -182,7 +186,7 @@ module OS FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI".freeze MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables".freeze MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base".freeze # obsolete - MAVERICKS_PKG_PATH = "/Library/Developer/CommandLineTools".freeze + PKG_PATH = "/Library/Developer/CommandLineTools".freeze # Returns true even if outdated tools are installed, e.g. # tools from Xcode 4.x on 10.9 @@ -222,7 +226,7 @@ module OS def minimum_version case MacOS.version when "10.12" then "8.0.0" - else "4.0.0" + else "1.0.0" end end @@ -237,7 +241,7 @@ module OS return false if MacOS.version < :lion if MacOS.version >= :mavericks - version = Utils.popen_read("#{MAVERICKS_PKG_PATH}/usr/bin/clang --version") + version = Utils.popen_read("#{PKG_PATH}/usr/bin/clang --version") else version = Utils.popen_read("/usr/bin/clang --version") end @@ -261,7 +265,7 @@ module OS [MAVERICKS_PKG_ID, MAVERICKS_NEW_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].find do |id| if MacOS.version >= :mavericks - next unless File.exist?("#{MAVERICKS_PKG_PATH}/usr/bin/clang") + next unless File.exist?("#{PKG_PATH}/usr/bin/clang") end version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1] return version if version |
