Avoid globals when ivars will do
This commit is contained in:
parent
ce5f4ad4df
commit
be08993a79
@ -25,9 +25,13 @@ end
|
||||
LOGGER = Logger.new
|
||||
|
||||
class Cmd
|
||||
attr_reader :brewfix, :sdkroot
|
||||
|
||||
def initialize path, args
|
||||
@arg0 = File.basename(path).freeze
|
||||
@args = args.freeze
|
||||
@brewfix = ENV['HOMEBREW_PREFIX']
|
||||
@sdkroot = ENV['HOMEBREW_SDKROOT']
|
||||
end
|
||||
def mode
|
||||
if @arg0 == 'cpp' or @arg0 == 'ld'
|
||||
@ -74,9 +78,9 @@ class Cmd
|
||||
refurbished_args
|
||||
end
|
||||
if tool != 'ld'
|
||||
args << "--sysroot=#$sdkroot"
|
||||
args << "--sysroot=#{sdkroot}"
|
||||
else
|
||||
args << "-syslibroot" << $sdkroot
|
||||
args << "-syslibroot" << sdkroot
|
||||
end if nclt?
|
||||
allflags = case mode
|
||||
when :ccld
|
||||
@ -133,7 +137,7 @@ class Cmd
|
||||
when /^-L(.+)/
|
||||
path = $1.chuzzle || whittler.next
|
||||
doit = case path.cleanpath
|
||||
when %r{^#$brewfix}
|
||||
when %r{^#{brewfix}}
|
||||
# maybe homebrew is installed to /sw or /opt/brew
|
||||
true
|
||||
when %r{^/opt}, %r{^/sw}, %r{/usr/X11}
|
||||
@ -180,7 +184,7 @@ class Cmd
|
||||
end
|
||||
def syspath
|
||||
if nclt?
|
||||
%W{#$sdkroot/usr #$sdkroot/usr/local}
|
||||
%W{#{sdkroot}/usr #{sdkroot}/usr/local}
|
||||
else
|
||||
%W{/usr /usr/local}
|
||||
end
|
||||
@ -189,7 +193,7 @@ class Cmd
|
||||
# We reject brew's lib as we explicitly add this as a -L flag, thus it
|
||||
# is given higher priority by cc, so it surpasses the system libpath.
|
||||
# NOTE this only counts if Homebrew is installed at /usr/local
|
||||
syspath.map{|d| "#{d}/lib" }.reject{|d| d == "#$brewfix/lib" }
|
||||
syspath.map{|d| "#{d}/lib" }.reject{|d| d == "#{brewfix}/lib" }
|
||||
end
|
||||
def syscpath
|
||||
isystem, _ = cpath
|
||||
@ -197,7 +201,7 @@ class Cmd
|
||||
end
|
||||
def cpath
|
||||
cpath = ENV['CMAKE_PREFIX_PATH'].split(':').map{|d| "#{d}/include" } + ENV['CMAKE_INCLUDE_PATH'].split(':')
|
||||
opt = cpath.grep(%r{^#$brewfix/opt})
|
||||
opt = cpath.grep(%r{^#{brewfix}/opt})
|
||||
sys = cpath - opt
|
||||
[sys, opt]
|
||||
end
|
||||
@ -243,7 +247,7 @@ class Cmd
|
||||
ENV.key? 'as_nl'
|
||||
end
|
||||
def nclt?
|
||||
$sdkroot != nil
|
||||
sdkroot != nil
|
||||
end
|
||||
def cccfg? flags
|
||||
flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG']
|
||||
|
||||
@ -20,6 +20,3 @@ class Array
|
||||
select { |path| File.directory? path }.uniq.map { |path| prefix + path }
|
||||
end
|
||||
end
|
||||
|
||||
$brewfix = ENV['HOMEBREW_PREFIX']
|
||||
$sdkroot = ENV['HOMEBREW_SDKROOT']
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user