ENV: mark gcc-6 as supporting C++11 (#349)
Add SharedEnvExtension#gcc_with_cxx11_support? to centralise the logic for checking whether a compiler is known to support C++11. Update logic to accept GCC 4.8 and above (including 6). Thereby also address oversight in #163 where support for GCC 6 was added without updating the C++11 compiler whitelist. Add tests for Superenv#cxx11. Closes #346.
This commit is contained in:
parent
62dd4b14ba
commit
01e8e180a8
@ -322,4 +322,9 @@ module SharedEnvExtension
|
|||||||
raise "Non-Apple GCC can't build universal binaries"
|
raise "Non-Apple GCC can't build universal binaries"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def gcc_with_cxx11_support?(cc)
|
||||||
|
version = cc[/^gcc-(\d+(?:\.\d+)?)$/, 1]
|
||||||
|
version && Version.new(version) >= Version.new("4.8")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -287,7 +287,7 @@ module Stdenv
|
|||||||
if compiler == :clang
|
if compiler == :clang
|
||||||
append "CXX", "-std=c++11"
|
append "CXX", "-std=c++11"
|
||||||
append "CXX", "-stdlib=libc++"
|
append "CXX", "-stdlib=libc++"
|
||||||
elsif compiler =~ /gcc-(4\.(8|9)|5)/
|
elsif gcc_with_cxx11_support?(compiler)
|
||||||
append "CXX", "-std=c++11"
|
append "CXX", "-std=c++11"
|
||||||
else
|
else
|
||||||
raise "The selected compiler doesn't support C++11: #{compiler}"
|
raise "The selected compiler doesn't support C++11: #{compiler}"
|
||||||
|
|||||||
@ -303,11 +303,10 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cxx11
|
def cxx11
|
||||||
case homebrew_cc
|
if homebrew_cc == "clang"
|
||||||
when "clang"
|
|
||||||
append "HOMEBREW_CCCFG", "x", ""
|
append "HOMEBREW_CCCFG", "x", ""
|
||||||
append "HOMEBREW_CCCFG", "g", ""
|
append "HOMEBREW_CCCFG", "g", ""
|
||||||
when /gcc-(4\.(8|9)|5)/
|
elsif gcc_with_cxx11_support?(homebrew_cc)
|
||||||
append "HOMEBREW_CCCFG", "x", ""
|
append "HOMEBREW_CCCFG", "x", ""
|
||||||
else
|
else
|
||||||
raise "The selected compiler doesn't support C++11: #{homebrew_cc}"
|
raise "The selected compiler doesn't support C++11: #{homebrew_cc}"
|
||||||
|
|||||||
@ -141,4 +141,33 @@ class SuperenvTests < Homebrew::TestCase
|
|||||||
assert_equal [], @env.deps
|
assert_equal [], @env.deps
|
||||||
assert_equal [], @env.keg_only_deps
|
assert_equal [], @env.keg_only_deps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_unsupported_cxx11
|
||||||
|
%w[gcc gcc-4.7].each do |compiler|
|
||||||
|
@env["HOMEBREW_CC"] = compiler
|
||||||
|
assert_raises do
|
||||||
|
@env.cxx11
|
||||||
|
end
|
||||||
|
refute_match "x", @env["HOMEBREW_CCCFG"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_supported_cxx11_gcc_5
|
||||||
|
@env["HOMEBREW_CC"] = "gcc-5"
|
||||||
|
@env.cxx11
|
||||||
|
assert_match "x", @env["HOMEBREW_CCCFG"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_supported_cxx11_gcc_6
|
||||||
|
@env["HOMEBREW_CC"] = "gcc-6"
|
||||||
|
@env.cxx11
|
||||||
|
assert_match "x", @env["HOMEBREW_CCCFG"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_supported_cxx11_clang
|
||||||
|
@env["HOMEBREW_CC"] = "clang"
|
||||||
|
@env.cxx11
|
||||||
|
assert_match "x", @env["HOMEBREW_CCCFG"]
|
||||||
|
assert_match "g", @env["HOMEBREW_CCCFG"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user