Move constants so we don't have to load all of ENV to get them

This commit is contained in:
Jack Nagel 2014-07-02 21:57:52 -05:00
parent 729ee39994
commit 32d84377d5
4 changed files with 21 additions and 14 deletions

View File

@ -20,7 +20,6 @@
# --ci-testing-upload: Homebrew CI testing bottle upload. # --ci-testing-upload: Homebrew CI testing bottle upload.
require 'formula' require 'formula'
require 'extend/ENV'
require 'utils' require 'utils'
require 'date' require 'date'
require 'rexml/document' require 'rexml/document'

View File

@ -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) class Compiler < Struct.new(:name, :version, :priority)
# The major version for non-Apple compilers. Used to indicate a compiler # 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". # series; for instance, if the version is 4.8.2, it would return "4.8".
@ -93,7 +98,7 @@ class CompilerSelector
end end
# non-Apple GCC 4.x # non-Apple GCC 4.x
SharedEnvExtension::GNU_GCC_VERSIONS.each do |v| CompilerConstants::GNU_GCC_VERSIONS.each do |v|
name = "gcc-4.#{v}" name = "gcc-4.#{v}"
version = @versions.non_apple_gcc_version(name) version = @versions.non_apple_gcc_version(name)
unless version.nil? unless version.nil?

View File

@ -1,3 +1,5 @@
require "compilers"
class CxxStdlib class CxxStdlib
attr_accessor :type, :compiler attr_accessor :type, :compiler
@ -11,7 +13,7 @@ class CxxStdlib
end end
def apple_compiler? def apple_compiler?
not compiler.to_s =~ SharedEnvExtension::GNU_GCC_REGEXP not compiler.to_s =~ CompilerConstants::GNU_GCC_REGEXP
end end
def compatible_with?(other) def compatible_with?(other)
@ -24,8 +26,8 @@ class CxxStdlib
# libstdc++ is compatible across Apple compilers, but # libstdc++ is compatible across Apple compilers, but
# not between Apple and GNU compilers, or between GNU compiler versions # not between Apple and GNU compilers, or between GNU compiler versions
return false if apple_compiler? && !other.apple_compiler? return false if apple_compiler? && !other.apple_compiler?
if compiler.to_s =~ SharedEnvExtension::GNU_GCC_REGEXP if compiler.to_s =~ CompilerConstants::GNU_GCC_REGEXP
return false unless other.compiler.to_s =~ SharedEnvExtension::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] return false unless compiler.to_s[4..6] == other.compiler.to_s[4..6]
end end

View File

@ -1,17 +1,18 @@
require 'formula' require "formula"
require "compilers"
module SharedEnvExtension module SharedEnvExtension
include CompilerConstants
CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS} CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
FC_FLAG_VARS = %w{FCFLAGS FFLAGS} FC_FLAG_VARS = %w{FCFLAGS FFLAGS}
# Update these every time a new GNU GCC branch is released COMPILER_SYMBOL_MAP = {
GNU_GCC_VERSIONS = (3..9) "gcc-4.0" => :gcc_4_0,
GNU_GCC_REGEXP = /gcc-(4\.[3-9])/ "gcc-4.2" => :gcc,
"llvm-gcc" => :llvm,
COMPILER_SYMBOL_MAP = { 'gcc-4.0' => :gcc_4_0, "clang" => :clang,
'gcc-4.2' => :gcc, }
'llvm-gcc' => :llvm,
'clang' => :clang }
COMPILERS = COMPILER_SYMBOL_MAP.values + COMPILERS = COMPILER_SYMBOL_MAP.values +
GNU_GCC_VERSIONS.map { |n| "gcc-4.#{n}" } GNU_GCC_VERSIONS.map { |n| "gcc-4.#{n}" }