aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/ENV/shared.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/extend/ENV/shared.rb')
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb104
1 files changed, 67 insertions, 37 deletions
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index fe98e5af9..740ed347d 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -4,8 +4,8 @@ require "compilers"
module SharedEnvExtension
include CompilerConstants
- CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
- FC_FLAG_VARS = %w{FCFLAGS FFLAGS}
+ CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS]
+ FC_FLAG_VARS = %w[FCFLAGS FFLAGS]
SANITIZED_VARS = %w[
CDPATH GREP_OPTIONS CLICOLOR_FORCE
@@ -18,7 +18,7 @@ module SharedEnvExtension
LIBRARY_PATH
]
- def setup_build_environment(formula=nil)
+ def setup_build_environment(formula = nil)
@formula = formula
reset
end
@@ -28,20 +28,23 @@ module SharedEnvExtension
end
def remove_cc_etc
- keys = %w{CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS}
- removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten]
+ keys = %w[CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS]
+ removed = Hash[*keys.map { |key| [key, self[key]] }.flatten]
keys.each do |key|
delete(key)
end
removed
end
- def append_to_cflags newflags
+
+ def append_to_cflags(newflags)
append(CC_FLAG_VARS, newflags)
end
- def remove_from_cflags val
+
+ def remove_from_cflags(val)
remove CC_FLAG_VARS, val
end
- def append keys, value, separator = ' '
+
+ def append(keys, value, separator = " ")
value = value.to_s
Array(keys).each do |key|
old = self[key]
@@ -52,7 +55,8 @@ module SharedEnvExtension
end
end
end
- def prepend keys, value, separator = ' '
+
+ def prepend(keys, value, separator = " ")
value = value.to_s
Array(keys).each do |key|
old = self[key]
@@ -64,37 +68,63 @@ module SharedEnvExtension
end
end
- def append_path key, path
+ def append_path(key, path)
append key, path, File::PATH_SEPARATOR if File.directory? path
end
- def prepend_path key, path
+ def prepend_path(key, path)
prepend key, path, File::PATH_SEPARATOR if File.directory? path
end
- def prepend_create_path key, path
+ def prepend_create_path(key, path)
path = Pathname.new(path) unless path.is_a? Pathname
path.mkpath
prepend_path key, path
end
- def remove keys, value
+ def remove(keys, value)
Array(keys).each do |key|
next unless self[key]
- self[key] = self[key].sub(value, '')
+ self[key] = self[key].sub(value, "")
delete(key) if self[key].empty?
end if value
end
- def cc; self['CC']; end
- def cxx; self['CXX']; end
- def cflags; self['CFLAGS']; end
- def cxxflags; self['CXXFLAGS']; end
- def cppflags; self['CPPFLAGS']; end
- def ldflags; self['LDFLAGS']; end
- def fc; self['FC']; end
- def fflags; self['FFLAGS']; end
- def fcflags; self['FCFLAGS']; end
+ def cc
+ self["CC"]
+ end
+
+ def cxx
+ self["CXX"]
+ end
+
+ def cflags
+ self["CFLAGS"]
+ end
+
+ def cxxflags
+ self["CXXFLAGS"]
+ end
+
+ def cppflags
+ self["CPPFLAGS"]
+ end
+
+ def ldflags
+ self["LDFLAGS"]
+ end
+
+ def fc
+ self["FC"]
+ end
+
+ def fflags
+ self["FFLAGS"]
+ end
+
+ def fcflags
+ self["FCFLAGS"]
+ end
def compiler
@compiler ||= if (cc = ARGV.cc)
@@ -133,14 +163,14 @@ module SharedEnvExtension
# See: https://bugs.python.org/issue6848
# Currently only used by aalib in core
def ncurses_define
- append 'CPPFLAGS', "-DNCURSES_OPAQUE=0"
+ append "CPPFLAGS", "-DNCURSES_OPAQUE=0"
end
def userpaths!
- paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w{/usr/X11/bin /opt/X11/bin}
- self['PATH'] = paths.unshift(*self['PATH'].split(File::PATH_SEPARATOR)).uniq.join(File::PATH_SEPARATOR)
+ paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w[/usr/X11/bin /opt/X11/bin]
+ self["PATH"] = paths.unshift(*self["PATH"].split(File::PATH_SEPARATOR)).uniq.join(File::PATH_SEPARATOR)
# XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
- prepend_path 'PATH', HOMEBREW_PREFIX/'bin'
+ prepend_path "PATH", HOMEBREW_PREFIX/"bin"
end
def fortran
@@ -149,9 +179,9 @@ module SharedEnvExtension
if fc
ohai "Building with an alternative Fortran compiler"
puts "This is unsupported."
- self['F77'] ||= fc
+ self["F77"] ||= fc
- if ARGV.include? '--default-fortran-flags'
+ if ARGV.include? "--default-fortran-flags"
flags = FC_FLAG_VARS.reject { |key| self[key] }
elsif values_at(*FC_FLAG_VARS).compact.empty?
opoo <<-EOS.undent
@@ -165,14 +195,14 @@ module SharedEnvExtension
end
else
- if (gfortran = which('gfortran', (HOMEBREW_PREFIX/'bin').to_s))
+ if (gfortran = which("gfortran", (HOMEBREW_PREFIX/"bin").to_s))
ohai "Using Homebrew-provided fortran compiler."
- elsif (gfortran = which('gfortran', ORIGINAL_PATHS.join(File::PATH_SEPARATOR)))
+ elsif (gfortran = which("gfortran", ORIGINAL_PATHS.join(File::PATH_SEPARATOR)))
ohai "Using a fortran compiler found at #{gfortran}."
end
if gfortran
puts "This may be changed by setting the FC environment variable."
- self['FC'] = self['F77'] = gfortran
+ self["FC"] = self["F77"] = gfortran
flags = FC_FLAG_VARS
end
end
@@ -183,14 +213,14 @@ module SharedEnvExtension
# ld64 is a newer linker provided for Xcode 2.5
def ld64
- ld64 = Formulary.factory('ld64')
- self['LD'] = ld64.bin/'ld'
+ ld64 = Formulary.factory("ld64")
+ self["LD"] = ld64.bin/"ld"
append "LDFLAGS", "-B#{ld64.bin}/"
end
def gcc_version_formula(name)
version = name[GNU_GCC_REGEXP, 1]
- gcc_version_name = "gcc#{version.delete('.')}"
+ gcc_version_name = "gcc#{version.delete(".")}"
gcc = Formulary.factory("gcc")
if gcc.opt_bin.join(name).exist?
@@ -222,11 +252,11 @@ module SharedEnvExtension
private
- def cc= val
+ def cc=(val)
self["CC"] = self["OBJC"] = val.to_s
end
- def cxx= val
+ def cxx=(val)
self["CXX"] = self["OBJCXX"] = val.to_s
end