Add predicate methods for compiler shim configuration

This commit is contained in:
Jack Nagel 2015-02-08 20:04:06 -05:00
parent 60452a526f
commit fd031f256a

View File

@ -84,7 +84,8 @@ class Cmd
# software uses gcc -v (wrongly) to sniff the GCC version. # software uses gcc -v (wrongly) to sniff the GCC version.
return @args.dup return @args.dup
end end
if !cccfg?("O") || tool == "ld" || configure?
if !refurbish_args? || tool == "ld" || configure?
args = @args.dup args = @args.dup
else else
args = refurbished_args args = refurbished_args
@ -128,13 +129,13 @@ class Cmd
loop do loop do
case arg = enum.next case arg = enum.next
when "-arch" when "-arch"
if cccfg?("K") if permit_arch_flags?
args << arg << enum.next args << arg << enum.next
else else
enum.next enum.next
end end
when "-m32", "-m64" when "-m32", "-m64"
args << arg if cccfg?("K") args << arg if permit_arch_flags?
when /^-Xarch_/ when /^-Xarch_/
refurbished = refurbish_arg(enum.next, enum) refurbished = refurbish_arg(enum.next, enum)
unless refurbished.empty? unless refurbished.empty?
@ -205,7 +206,7 @@ class Cmd
def cflags def cflags
args = [] args = []
return args unless cccfg? 'O' or configure? return args unless refurbish_args? || configure?
args << '-pipe' args << '-pipe'
args << '-w' unless configure? args << '-w' unless configure?
@ -217,9 +218,9 @@ class Cmd
def cxxflags def cxxflags
args = cflags args = cflags
args << '-std=c++11' if cccfg? 'x' args << "-std=c++11" if cxx11?
args << '-stdlib=libc++' if cccfg? 'g' args << "-stdlib=libc++" if libcxx?
args << '-stdlib=libstdc++' if cccfg? 'h' args << "-stdlib=libstdc++" if libstdcxx?
args args
end end
@ -276,7 +277,7 @@ class Cmd
end end
def make_fuss? def make_fuss?
cccfg? 'O' and not configure? refurbish_args? && !configure?
end end
def configure? def configure?
@ -288,6 +289,26 @@ class Cmd
flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG'] flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG']
end end
def refurbish_args?
cccfg?("O")
end
def cxx11?
cccfg?("x")
end
def libcxx?
cccfg?("g")
end
def libstdcxx?
cccfg?("h")
end
def permit_arch_flags?
cccfg?("K")
end
def canonical_path(path) def canonical_path(path)
path = Pathname.new(path) path = Pathname.new(path)
path = path.realpath if path.exist? path = path.realpath if path.exist?