From 5c58fce9cf4e0fc3e8d0f44ec9181700f1380092 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Wed, 21 Jun 2017 17:47:21 +0100 Subject: Change the name of the tool to avoid + in filename. Add alias so clang++ still works as a tool name. --- src/engine/SCons/Tool/__init__.py | 5 ++- src/engine/SCons/Tool/clang++.py | 92 --------------------------------------- src/engine/SCons/Tool/clang++.xml | 41 ----------------- src/engine/SCons/Tool/clangxx.py | 91 ++++++++++++++++++++++++++++++++++++++ src/engine/SCons/Tool/clangxx.xml | 41 +++++++++++++++++ 5 files changed, 136 insertions(+), 134 deletions(-) delete mode 100644 src/engine/SCons/Tool/clang++.py delete mode 100644 src/engine/SCons/Tool/clang++.xml create mode 100644 src/engine/SCons/Tool/clangxx.py create mode 100644 src/engine/SCons/Tool/clangxx.xml diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index e5b4b05..f022a1f 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -101,7 +101,10 @@ for suffix in LaTeXSuffixes: # Tool aliases are needed for those tools whos module names also # occur in the python standard library. This causes module shadowing and # can break using python library functions under python3 -TOOL_ALIASES = {'gettext':'gettext_tool'} +TOOL_ALIASES = { + 'gettext':'gettext_tool', + 'clang++': 'clangxx', +} class Tool(object): def __init__(self, name, toolpath=[], **kw): diff --git a/src/engine/SCons/Tool/clang++.py b/src/engine/SCons/Tool/clang++.py deleted file mode 100644 index 07c89ad..0000000 --- a/src/engine/SCons/Tool/clang++.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- encoding: utf-8 -*- - -"""SCons.Tool.clang++ - -Tool-specific initialization for clang++. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -# __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -# Based on SCons/Tool/g++.py by Paweł Tomulik 2014 as a separate tool. -# Brought into the SCons mainline by Russel Winder 2017. - -import os.path -import re -import subprocess -import sys - -import SCons.Tool -import SCons.Util - -cplusplus = __import__(__package__ + '.c++', globals(), locals(), ['*']) - -compilers = ['clang++'] - -def generate(env): - """Add Builders and construction variables for clang++ to an Environment.""" - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - - cplusplus.generate(env) - - env['CXX'] = env.Detect(compilers) or 'clang++' - - # platform specific settings - if env['PLATFORM'] == 'aix': - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc') - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 - env['SHOBJSUFFIX'] = '$OBJSUFFIX' - elif env['PLATFORM'] == 'hpux': - env['SHOBJSUFFIX'] = '.pic.o' - elif env['PLATFORM'] == 'sunos': - env['SHOBJSUFFIX'] = '.pic.o' - # determine compiler version - if env['CXX']: - pipe = SCons.Action._subproc(env, [env['CXX'], '--version'], - stdin='devnull', - stderr='devnull', - stdout=subprocess.PIPE) - if pipe.wait() != 0: return - # clang -dumpversion is of no use - line = pipe.stdout.readline() - if sys.version_info[0] > 2: - line = line.decode() - match = re.search(r'clang +version +([0-9]+(?:\.[0-9]+)+)', line) - if match: - env['CXXVERSION'] = match.group(1) - -def exists(env): - return env.Detect(compilers) - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/clang++.xml b/src/engine/SCons/Tool/clang++.xml deleted file mode 100644 index ad30b26..0000000 --- a/src/engine/SCons/Tool/clang++.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - -%scons; - -%builders-mod; - -%functions-mod; - -%tools-mod; - -%variables-mod; -]> - - - - - - -Set construction variables for the Clang C++ compiler. - - - -CXX -SHCXXFLAGS - -SHOBJSUFFIX -CXXVERSION - - - - diff --git a/src/engine/SCons/Tool/clangxx.py b/src/engine/SCons/Tool/clangxx.py new file mode 100644 index 0000000..60617db --- /dev/null +++ b/src/engine/SCons/Tool/clangxx.py @@ -0,0 +1,91 @@ +# -*- encoding: utf-8 -*- + +"""SCons.Tool.clang++ + +Tool-specific initialization for clang++. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +# __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +# Based on SCons/Tool/g++.py by Paweł Tomulik 2014 as a separate tool. +# Brought into the SCons mainline by Russel Winder 2017. + +import os.path +import re +import subprocess +import sys + +import SCons.Tool +import SCons.Util +import SCons.Tool.cxx + +compilers = ['clang++'] + +def generate(env): + """Add Builders and construction variables for clang++ to an Environment.""" + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + SCons.Tool.cxx.generate(env) + + env['CXX'] = env.Detect(compilers) or 'clang++' + + # platform specific settings + if env['PLATFORM'] == 'aix': + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc') + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 + env['SHOBJSUFFIX'] = '$OBJSUFFIX' + elif env['PLATFORM'] == 'hpux': + env['SHOBJSUFFIX'] = '.pic.o' + elif env['PLATFORM'] == 'sunos': + env['SHOBJSUFFIX'] = '.pic.o' + # determine compiler version + if env['CXX']: + pipe = SCons.Action._subproc(env, [env['CXX'], '--version'], + stdin='devnull', + stderr='devnull', + stdout=subprocess.PIPE) + if pipe.wait() != 0: return + # clang -dumpversion is of no use + line = pipe.stdout.readline() + if sys.version_info[0] > 2: + line = line.decode() + match = re.search(r'clang +version +([0-9]+(?:\.[0-9]+)+)', line) + if match: + env['CXXVERSION'] = match.group(1) + +def exists(env): + return env.Detect(compilers) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/clangxx.xml b/src/engine/SCons/Tool/clangxx.xml new file mode 100644 index 0000000..25ed1d4 --- /dev/null +++ b/src/engine/SCons/Tool/clangxx.xml @@ -0,0 +1,41 @@ + + + + +%scons; + +%builders-mod; + +%functions-mod; + +%tools-mod; + +%variables-mod; +]> + + + + + + +Set construction variables for the Clang C++ compiler. + + + +CXX +SHCXXFLAGS + +SHOBJSUFFIX +CXXVERSION + + + + -- cgit v0.12