Move constants so we don't have to load all of ENV to get them
This commit is contained in:
parent
729ee39994
commit
32d84377d5
@ -20,7 +20,6 @@
|
||||
# --ci-testing-upload: Homebrew CI testing bottle upload.
|
||||
|
||||
require 'formula'
|
||||
require 'extend/ENV'
|
||||
require 'utils'
|
||||
require 'date'
|
||||
require 'rexml/document'
|
||||
|
@ -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?
|
||||
|
@ -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
|
||||
|
||||
|
@ -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}" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user