diff options
| author | Jack Nagel | 2013-11-21 14:50:35 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-11-21 17:17:56 -0600 |
| commit | be08993a79a8d616b8719e364833e1f235d32127 (patch) | |
| tree | 50b6e664168df79e98d18c416f074ab86728a66a /Library | |
| parent | ce5f4ad4dfc99f5f058ec724136c226ecabaf7d8 (diff) | |
| download | brew-be08993a79a8d616b8719e364833e1f235d32127.tar.bz2 | |
Avoid globals when ivars will do
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/ENV/4.3/cc | 18 | ||||
| -rw-r--r-- | Library/ENV/libsuperenv.rb | 3 |
2 files changed, 11 insertions, 10 deletions
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index b29acb64d..fc3d4bf1e 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -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'] diff --git a/Library/ENV/libsuperenv.rb b/Library/ENV/libsuperenv.rb index c87e6a499..5e7035eb2 100644 --- a/Library/ENV/libsuperenv.rb +++ b/Library/ENV/libsuperenv.rb @@ -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'] |
