From be08993a79a8d616b8719e364833e1f235d32127 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Thu, 21 Nov 2013 14:50:35 -0600 Subject: [PATCH] Avoid globals when ivars will do --- Library/ENV/4.3/cc | 18 +++++++++++------- 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 b29acb64db..fc3d4bf1ef 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 c87e6a4996..5e7035eb2e 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']