MacOS.xcode_prefix
More robust code than before, and replaces all usage of `xcode-select -print-path`.
This commit is contained in:
parent
48fe922456
commit
d78b89dd2e
@ -121,10 +121,8 @@ module HomebrewEnvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def llvm
|
def llvm
|
||||||
xcode_path = `/usr/bin/xcode-select -print-path`.chomp
|
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc"
|
||||||
xcode_path = "/Developer" if xcode_path.to_s.empty?
|
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++"
|
||||||
self['CC'] = "#{xcode_path}/usr/bin/llvm-gcc"
|
|
||||||
self['CXX'] = "#{xcode_path}/usr/bin/llvm-g++"
|
|
||||||
self['LD'] = self['CC']
|
self['LD'] = self['CC']
|
||||||
self.O4
|
self.O4
|
||||||
end
|
end
|
||||||
|
|||||||
@ -232,12 +232,31 @@ module MacOS extend self
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# usually /Developer
|
||||||
|
def xcode_prefix
|
||||||
|
@xcode_prefix ||= begin
|
||||||
|
path = `/usr/bin/xcode-select -print-path 2>&1`.chomp
|
||||||
|
path = Pathname.new path
|
||||||
|
if path.directory? and path.absolute?
|
||||||
|
path
|
||||||
|
elsif File.directory? '/Developer'
|
||||||
|
# we do this to support cowboys who insist on installing
|
||||||
|
# only a subset of Xcode
|
||||||
|
'/Developer'
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def llvm_build_version
|
def llvm_build_version
|
||||||
if MACOS_VERSION >= 10.6
|
unless xcode_prefix.to_s.empty?
|
||||||
xcode_path = `/usr/bin/xcode-select -print-path`.chomp
|
llvm_gcc_path = xcode_prefix/"usr/bin/llvm-gcc"
|
||||||
return nil if xcode_path.empty?
|
# for Xcode 3 on OS X 10.5 this will not exist
|
||||||
`#{xcode_path}/usr/bin/llvm-gcc -v 2>&1` =~ /LLVM build (\d{4,})/
|
if llvm_gcc_path.file?
|
||||||
$1.to_i
|
`#{llvm_gcc_path} -v 2>&1` =~ /LLVM build (\d{4,})/
|
||||||
|
$1.to_i # if nil this raises and then you fix the regex
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user