aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2014-07-02 21:57:52 -0500
committerJack Nagel2014-07-02 21:58:43 -0500
commit32d84377d54ab1c7de897cd19fc1df458c622ae8 (patch)
tree08e1fe27ee5dd46347a62610824d09d248ba08ca
parent729ee39994faf25803d50e33dec0620dae5d964e (diff)
downloadbrew-32d84377d54ab1c7de897cd19fc1df458c622ae8.tar.bz2
Move constants so we don't have to load all of ENV to get them
-rwxr-xr-xLibrary/Contributions/cmd/brew-test-bot.rb1
-rw-r--r--Library/Homebrew/compilers.rb7
-rw-r--r--Library/Homebrew/cxxstdlib.rb8
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb19
4 files changed, 21 insertions, 14 deletions
diff --git a/Library/Contributions/cmd/brew-test-bot.rb b/Library/Contributions/cmd/brew-test-bot.rb
index 8dc327484..adcaf3d19 100755
--- a/Library/Contributions/cmd/brew-test-bot.rb
+++ b/Library/Contributions/cmd/brew-test-bot.rb
@@ -20,7 +20,6 @@
# --ci-testing-upload: Homebrew CI testing bottle upload.
require 'formula'
-require 'extend/ENV'
require 'utils'
require 'date'
require 'rexml/document'
diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb
index e60322060..2d9bb908f 100644
--- a/Library/Homebrew/compilers.rb
+++ b/Library/Homebrew/compilers.rb
@@ -1,3 +1,8 @@
+module CompilerConstants
+ GNU_GCC_VERSIONS = 3..9
+ GNU_GCC_REGEXP = /gcc-(4\.[3-9])/
+end
+
class Compiler < Struct.new(:name, :version, :priority)
# The major version for non-Apple compilers. Used to indicate a compiler
# series; for instance, if the version is 4.8.2, it would return "4.8".
@@ -93,7 +98,7 @@ class CompilerSelector
end
# non-Apple GCC 4.x
- SharedEnvExtension::GNU_GCC_VERSIONS.each do |v|
+ CompilerConstants::GNU_GCC_VERSIONS.each do |v|
name = "gcc-4.#{v}"
version = @versions.non_apple_gcc_version(name)
unless version.nil?
diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb
index 7525f6ab9..0fc9beacc 100644
--- a/Library/Homebrew/cxxstdlib.rb
+++ b/Library/Homebrew/cxxstdlib.rb
@@ -1,3 +1,5 @@
+require "compilers"
+
class CxxStdlib
attr_accessor :type, :compiler
@@ -11,7 +13,7 @@ class CxxStdlib
end
def apple_compiler?
- not compiler.to_s =~ SharedEnvExtension::GNU_GCC_REGEXP
+ not compiler.to_s =~ CompilerConstants::GNU_GCC_REGEXP
end
def compatible_with?(other)
@@ -24,8 +26,8 @@ class CxxStdlib
# libstdc++ is compatible across Apple compilers, but
# not between Apple and GNU compilers, or between GNU compiler versions
return false if apple_compiler? && !other.apple_compiler?
- if compiler.to_s =~ SharedEnvExtension::GNU_GCC_REGEXP
- return false unless other.compiler.to_s =~ SharedEnvExtension::GNU_GCC_REGEXP
+ if compiler.to_s =~ CompilerConstants::GNU_GCC_REGEXP
+ return false unless other.compiler.to_s =~ CompilerConstants::GNU_GCC_REGEXP
return false unless compiler.to_s[4..6] == other.compiler.to_s[4..6]
end
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index 8208d185d..9225b997f 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -1,17 +1,18 @@
-require 'formula'
+require "formula"
+require "compilers"
module SharedEnvExtension
+ include CompilerConstants
+
CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
FC_FLAG_VARS = %w{FCFLAGS FFLAGS}
- # Update these every time a new GNU GCC branch is released
- GNU_GCC_VERSIONS = (3..9)
- GNU_GCC_REGEXP = /gcc-(4\.[3-9])/
-
- COMPILER_SYMBOL_MAP = { 'gcc-4.0' => :gcc_4_0,
- 'gcc-4.2' => :gcc,
- 'llvm-gcc' => :llvm,
- 'clang' => :clang }
+ COMPILER_SYMBOL_MAP = {
+ "gcc-4.0" => :gcc_4_0,
+ "gcc-4.2" => :gcc,
+ "llvm-gcc" => :llvm,
+ "clang" => :clang,
+ }
COMPILERS = COMPILER_SYMBOL_MAP.values +
GNU_GCC_VERSIONS.map { |n| "gcc-4.#{n}" }