ENV: normalize usage of "self" and "ENV"

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-03-21 11:58:32 -05:00
parent a161058bcd
commit 01c14f8775

View File

@ -10,7 +10,7 @@ module HomebrewEnvExtension
remove_cc_etc remove_cc_etc
# make any aclocal stuff installed in Homebrew available # make any aclocal stuff installed in Homebrew available
ENV['ACLOCAL_PATH'] = "#{HOMEBREW_PREFIX}/share/aclocal" if MacOS.xcode_version < "4.3" self['ACLOCAL_PATH'] = "#{HOMEBREW_PREFIX}/share/aclocal" if MacOS.xcode_version < "4.3"
self['MAKEFLAGS'] = "-j#{self.make_jobs}" self['MAKEFLAGS'] = "-j#{self.make_jobs}"
@ -29,12 +29,12 @@ module HomebrewEnvExtension
self.send self.compiler self.send self.compiler
# we must have a working compiler! # we must have a working compiler!
unless ENV['CC'] unless self['CC']
@compiler = MacOS.default_compiler @compiler = MacOS.default_compiler
self.send @compiler self.send @compiler
ENV['CC'] = '/usr/bin/cc' self['CC'] = '/usr/bin/cc'
ENV['CXX'] = '/usr/bin/c++' self['CXX'] = '/usr/bin/c++'
ENV['OBJC'] = ENV['CC'] self['OBJC'] = self['CC']
end end
# In rare cases this may break your builds, as the tool for some reason wants # In rare cases this may break your builds, as the tool for some reason wants
@ -125,11 +125,11 @@ module HomebrewEnvExtension
# if your formula doesn't like CC having spaces use this # if your formula doesn't like CC having spaces use this
def expand_xcrun def expand_xcrun
ENV['CC'] =~ %r{/usr/bin/xcrun (.*)} self['CC'] =~ %r{/usr/bin/xcrun (.*)}
ENV['CC'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1 self['CC'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
ENV['CXX'] =~ %r{/usr/bin/xcrun (.*)} self['CXX'] =~ %r{/usr/bin/xcrun (.*)}
ENV['CXX'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1 self['CXX'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
ENV['OBJC'] = ENV['CC'] self['OBJC'] = self['CC']
end end
def gcc def gcc
@ -137,19 +137,19 @@ module HomebrewEnvExtension
# However they still provide a gcc symlink to llvm # However they still provide a gcc symlink to llvm
# But we don't want LLVM of course. # But we don't want LLVM of course.
ENV['CC'] = xcrun "gcc-4.2" self['CC'] = xcrun "gcc-4.2"
ENV['CXX'] = xcrun "g++-4.2" self['CXX'] = xcrun "g++-4.2"
ENV['OBJC'] = ENV['CC'] self['OBJC'] = self['CC']
unless ENV['CC'] unless self['CC']
ENV['CC'] = "#{HOMEBREW_PREFIX}/bin/gcc-4.2" self['CC'] = "#{HOMEBREW_PREFIX}/bin/gcc-4.2"
ENV['CXX'] = "#{HOMEBREW_PREFIX}/bin/g++-4.2" self['CXX'] = "#{HOMEBREW_PREFIX}/bin/g++-4.2"
ENV['OBJC'] = ENV['CC'] self['OBJC'] = self['CC']
raise "GCC could not be found" if not File.exist? ENV['CC'] raise "GCC could not be found" if not File.exist? self['CC']
end end
if not ENV['CC'] =~ %r{^/usr/bin/xcrun } if not self['CC'] =~ %r{^/usr/bin/xcrun }
raise "GCC could not be found" if Pathname.new(ENV['CC']).realpath.to_s =~ /llvm/ raise "GCC could not be found" if Pathname.new(self['CC']).realpath.to_s =~ /llvm/
end end
replace_in_cflags '-O4', '-O3' replace_in_cflags '-O4', '-O3'
@ -434,9 +434,9 @@ Please take one of the following actions:
def remove_cc_etc def remove_cc_etc
keys = %w{CC CXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS} keys = %w{CC CXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS}
removed = Hash[*keys.map{ |key| [key, ENV[key]] }.flatten] removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten]
keys.each do |key| keys.each do |key|
ENV[key] = nil self[key] = nil
end end
removed removed
end end