mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-19 20:35:49 +00:00

SCons stupidly treats Clang as if it were GCC (hint: it's not) and that causes the config check to fail due to the version symbols being absent/not what we expect. So just ignore the GCC version when Clang is detected, in the config test program; we can probably expect whoever is using Clang to be able to deal with any issues that may arise from attempting to use a Clang version we don't support. As for why we don't test the Clang version number, according to <http://clang.llvm.org/docs/LanguageExtensions.html#builtin-macros>, "marketing version numbers should not be used to check for language features, as different vendors use different numbering schemes." And indeed, it is the case with the versions of Clang shipped with XCode that they do not accurately reflect the upstream version they correspond to and have weird version numbers such as 5 (as of this writing upstrema hasn't even released version 4.0 yet). Such is life.
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
# vi: syntax=python:et:ts=4
|
|
def CheckCPlusPlus(context, gcc_version = None):
|
|
message = "Checking whether C++ compiler works "
|
|
test_program = """
|
|
#include <iostream>
|
|
int main()
|
|
{
|
|
std::cout << "Hello, world\\n";
|
|
}
|
|
"""
|
|
if gcc_version and "gcc" in context.env["TOOLS"]:
|
|
message += "(g++ version >= %s required)" % gcc_version
|
|
import operator
|
|
version = gcc_version.split(".", 3)
|
|
version = map(int, version)
|
|
version = map(lambda x,y: x or y, version, (0,0,0))
|
|
multipliers = (10000, 100, 1)
|
|
version_num = sum(map(operator.mul, version, multipliers))
|
|
test_program += """
|
|
#ifndef __clang__
|
|
|
|
#define GCC_VERSION (__GNUC__ * 10000 \\
|
|
+ __GNUC_MINOR__ * 100 \\
|
|
+ __GNUC_PATCHLEVEL__)
|
|
|
|
#if GCC_VERSION < %d
|
|
#error Compiler version is too old!
|
|
#endif
|
|
|
|
#endif
|
|
\n""" % version_num
|
|
message += "... "
|
|
context.Message(message)
|
|
if context.TryBuild(context.env.Program, test_program, ".cpp") == 1 and context.lastTarget.get_contents() != "":
|
|
context.Result("yes")
|
|
return True
|
|
else:
|
|
context.Result("no")
|
|
return False
|
|
|
|
config_checks = { "CheckCPlusPlus" : CheckCPlusPlus }
|