aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-08-31 23:44:36 -0400
committerMax Howell2012-08-31 23:45:10 -0400
commit429226d5628797d071154bff39507f0f8cc1fa31 (patch)
tree8c67b22fae80920f8f8daca3bfd56d46e2c72f4c /Library
parent75a0708865f45449ac0a7fba15ca0181dca8e777 (diff)
downloadbrew-429226d5628797d071154bff39507f0f8cc1fa31.tar.bz2
Hack so that ENV['CFLAGS'] += "foo" always works
So many formula assume CFLAGS etc. are not nil. One fix would be to set them to "" but this would set them in the environment, and that could have consequences for build-scripts. This hack works but with a (hopefully) small caveat. Fixes Homebrew/homebrew#14580.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/superenv.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/Library/Homebrew/superenv.rb b/Library/Homebrew/superenv.rb
index 9b7ec0a23..bb8d7ea39 100644
--- a/Library/Homebrew/superenv.rb
+++ b/Library/Homebrew/superenv.rb
@@ -208,6 +208,26 @@ class << ENV
[$1.to_i, 1].max
end
+ # Many formula assume that CFLAGS etc. will not be nil.
+ # This should be a safe hack to prevent that exception cropping up.
+ # Main consqeuence of this is that ENV['CFLAGS'] is never nil even when it
+ # is which can break if checks, but we don't do such a check in our code.
+ def [] key
+ if has_key? key
+ fetch(key)
+ elsif %w{CPPFLAGS CFLAGS LDFLAGS}.include? key
+ class << (a = "")
+ attr :key, true
+ def + value
+ ENV[key] = value
+ end
+ alias_method '<<', '+'
+ end
+ a.key = key
+ a
+ end
+ end
+
end if superenv?