From 14b3ea887a06a296d3c3c2cb48d7f06d302a94e5 Mon Sep 17 00:00:00 2001
From: Adam Vandenberg <flangy@gmail.com>
Date: Fri, 25 Sep 2009 19:55:24 -0700
Subject: [PATCH] Add option to downgrade from LLVM to gcc.

Signed-off-by: Max Howell <max@methylblue.com>

I added ENV tests.
---
 Library/Homebrew/brewkit.rb  |  7 +++++++
 Library/Homebrew/unittest.rb | 13 +++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb
index 34eb28c95b..451911143d 100644
--- a/Library/Homebrew/brewkit.rb
+++ b/Library/Homebrew/brewkit.rb
@@ -110,6 +110,7 @@ module HomebrewEnvExtension
       self['CC']='gcc-4.0'
       self['CXX']='g++-4.0'
       remove_from_cflags '-march=core2'
+      self.O3
     end
     remove_from_cflags '-msse4.1'
     remove_from_cflags '-msse4.2'
@@ -119,6 +120,12 @@ module HomebrewEnvExtension
     remove_from_cflags '-O4'
     append_to_cflags '-O3'
   end
+  def gcc_4_2
+    # Sometimes you want to downgrade from LLVM to GCC 4.2
+    self['CC']="gcc-4.2"
+    self['CXX']="g++-4.2"
+    self.O3
+  end
   def osx_10_4
     self['MACOSX_DEPLOYMENT_TARGET']=nil
     remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/)
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb
index 082306069e..0968e8f5ff 100755
--- a/Library/Homebrew/unittest.rb
+++ b/Library/Homebrew/unittest.rb
@@ -607,6 +607,19 @@ class BeerTasting <Test::Unit::TestCase
     end
     @fixture_data
   end
+  
+  def test_ENV_options
+    ENV.gcc_4_0_1
+    ENV.gcc_4_2
+    ENV.O3
+    ENV.minimal_optimization
+    ENV.no_optimization
+    ENV.libxml2
+    ENV.x11
+    ENV.enable_warnings
+    assert !ENV.cc.empty?
+    assert !ENV.cxx.empty?
+  end
 end
 
 __END__
-- 
GitLab