Better superenv support for Xcode elsewhere
- The Library/ENV/4.3/xcrun shim now respects ENV['DEVELOPER_DIR'] instead assuming the location of /Applications/Xcode.app/Contents/Developer. - The env var DEVELOPER_DIR is set if it is not already. So, during superenv this var is always set and we no longer have to care about people with unset or wrongly set xcode-select stuff. This has been a major PITA in the past. - determine_developer_dir (which is used to set the DEVELOPER_DIR var) now uses MacOS::Xcode.prefix which is proven and very capable and uses splotlight correctly. - Replace (and remove) MacSystem.xcode43_developer_dir with Xcode.prefix Closes Homebrew/homebrew#18618
This commit is contained in:
parent
29af53d451
commit
c6b0b563e8
@ -19,8 +19,8 @@ end
|
||||
arg0 = ARGV.shift
|
||||
try `/usr/bin/xcrun --find #{arg0}`.chomp
|
||||
# Nuts, Xcode is not setup properly or something. Try to find the tools anyway!
|
||||
try "/Applications/Xcode.app/Contents/Developer/usr/bin/#{arg0}"
|
||||
try "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/#{arg0}"
|
||||
try "#{ENV['DEVELOPER_DIR']}/usr/bin/#{arg0}"
|
||||
try "#{ENV['DEVELOPER_DIR']}/Toolchains/XcodeDefault.xctoolchain/usr/bin/#{arg0}"
|
||||
try "/usr/bin/#{arg0}"
|
||||
|
||||
abort <<-EOS
|
||||
|
@ -76,7 +76,7 @@ module MacOS::Xcode extend self
|
||||
|
||||
# this shortcut makes version work for people who don't realise you
|
||||
# need to install the CLI tools
|
||||
xcode43build = V4_BUNDLE_PATH/'Contents/Developer/usr/bin/xcodebuild'
|
||||
xcode43build = prefix/'usr/bin/xcodebuild'
|
||||
if xcode43build.file?
|
||||
`#{xcode43build} -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/
|
||||
return $1 if $1
|
||||
|
@ -18,10 +18,7 @@ end
|
||||
|
||||
def superenv?
|
||||
not (MacSystem.xcode43_without_clt? and
|
||||
MacOS.sdk_path.nil?) and # because superenv will fail to find stuff
|
||||
not (MacSystem.xcode43_without_clt? and
|
||||
!MacSystem.xcode43_developer_dir) and # because superenv's logic might not find it
|
||||
not MacOS::Xcode.folder.nil? and # because xcrun won't work
|
||||
MacOS.sdk_path.nil?) and # because superenv will fail to find stuff
|
||||
superbin and superbin.directory? and
|
||||
not ARGV.include? "--env=std"
|
||||
rescue # blanket rescue because there are naked raises
|
||||
@ -112,8 +109,8 @@ class << ENV
|
||||
def determine_path
|
||||
paths = [superbin]
|
||||
if MacSystem.xcode43_without_clt?
|
||||
paths << "#{MacSystem.xcode43_developer_dir}/usr/bin"
|
||||
paths << "#{MacSystem.xcode43_developer_dir}/Toolchains/XcodeDefault.xctoolchain/usr/bin"
|
||||
paths << "#{MacOS::Xcode.prefix}/usr/bin"
|
||||
paths << "#{MacOS::Xcode.prefix}/Toolchains/XcodeDefault.xctoolchain/usr/bin"
|
||||
end
|
||||
paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/bin" }
|
||||
paths << "#{HOMEBREW_PREFIX}/opt/python/bin" if brewed_python?
|
||||
@ -197,11 +194,7 @@ class << ENV
|
||||
# If Xcode path is fucked then this is basically a fix. In the case where
|
||||
# nothing is valid, it still fixes most usage to supply a valid path that
|
||||
# is not "/".
|
||||
if MacOS::Xcode.bad_xcode_select_path?
|
||||
(MacOS::Xcode.prefix || HOMEBREW_PREFIX).to_s
|
||||
elsif ENV['DEVELOPER_DIR']
|
||||
ENV['DEVELOPER_DIR']
|
||||
end
|
||||
MacOS::Xcode.prefix || ENV['DEVELOPER_DIR']
|
||||
end
|
||||
|
||||
def brewed_python?
|
||||
|
@ -1,7 +1,7 @@
|
||||
# new code because I don't really trust the Xcode code now having researched it more
|
||||
module MacSystem extend self
|
||||
def xcode_clt_installed?
|
||||
File.executable? "/usr/bin/clang" and File.executable? "/usr/bin/lldb"
|
||||
File.executable? "/usr/bin/clang" and File.executable? "/usr/bin/lldb" and File.executable? "/usr/bin/make"
|
||||
end
|
||||
|
||||
def xcode43_without_clt?
|
||||
@ -13,16 +13,6 @@ module MacSystem extend self
|
||||
#{MacOS.sdk_path}/usr/X11].find{|path| File.directory? "#{path}/include" }
|
||||
end
|
||||
|
||||
def xcode43_developer_dir
|
||||
@xcode43_developer_dir ||=
|
||||
tst(ENV['DEVELOPER_DIR']) ||
|
||||
tst(`xcode-select -print-path 2>/dev/null`) ||
|
||||
tst("/Applications/Xcode.app/Contents/Developer") ||
|
||||
MacOS.mdfind("com.apple.dt.Xcode").find{|path| tst(path) }
|
||||
raise unless @xcode43_developer_dir
|
||||
@xcode43_developer_dir
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def tst prefix
|
||||
|
Loading…
x
Reference in New Issue
Block a user