From b726447e54cad80cfff3422f52f6afcd5798e59f Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Wed, 21 Jun 2017 15:17:33 +0100 Subject: =?UTF-8?q?Initial=20commit=20for=20bringing=20Pawe=C5=82=20Tomuli?= =?UTF-8?q?k's=20clang=20and=20clang++=20tools=20into=20the=20mainline.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/engine/SCons/Tool/clang++.py | 92 ++++++++++++++++++++++++++++++ src/engine/SCons/Tool/clang++.xml | 41 +++++++++++++ src/engine/SCons/Tool/clang.py | 83 +++++++++++++++++++++++++++ src/engine/SCons/Tool/clang.xml | 39 +++++++++++++ test/Clang/clang++_default_environment.py | 64 +++++++++++++++++++++ test/Clang/clang++_shared_library.py | 56 ++++++++++++++++++ test/Clang/clang++_specific_environment.py | 60 +++++++++++++++++++ test/Clang/clang++_static_library.py | 56 ++++++++++++++++++ test/Clang/clang_default_environment.py | 64 +++++++++++++++++++++ test/Clang/clang_shared_library.py | 56 ++++++++++++++++++ test/Clang/clang_specific_environment.py | 60 +++++++++++++++++++ test/Clang/clang_static_library.py | 56 ++++++++++++++++++ 12 files changed, 727 insertions(+) create mode 100644 src/engine/SCons/Tool/clang++.py create mode 100644 src/engine/SCons/Tool/clang++.xml create mode 100644 src/engine/SCons/Tool/clang.py create mode 100644 src/engine/SCons/Tool/clang.xml create mode 100644 test/Clang/clang++_default_environment.py create mode 100644 test/Clang/clang++_shared_library.py create mode 100644 test/Clang/clang++_specific_environment.py create mode 100644 test/Clang/clang++_static_library.py create mode 100644 test/Clang/clang_default_environment.py create mode 100644 test/Clang/clang_shared_library.py create mode 100644 test/Clang/clang_specific_environment.py create mode 100644 test/Clang/clang_static_library.py diff --git a/src/engine/SCons/Tool/clang++.py b/src/engine/SCons/Tool/clang++.py new file mode 100644 index 0000000..07c89ad --- /dev/null +++ b/src/engine/SCons/Tool/clang++.py @@ -0,0 +1,92 @@ +# -*- 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 new file mode 100644 index 0000000..ad30b26 --- /dev/null +++ b/src/engine/SCons/Tool/clang++.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 + + + + diff --git a/src/engine/SCons/Tool/clang.py b/src/engine/SCons/Tool/clang.py new file mode 100644 index 0000000..3075c46 --- /dev/null +++ b/src/engine/SCons/Tool/clang.py @@ -0,0 +1,83 @@ +# -*- 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/gcc.py by Paweł Tomulik 2014 as a separate tool. +# Brought into the SCons mainline by Russel Winder 2017. + +import os +import re +import subprocess +import sys + +import SCons.Util +import SCons.Tool.cc + +compilers = ['clang'] + +def generate(env): + """Add Builders and construction variables for clang to an Environment.""" + SCons.Tool.cc.generate(env) + + env['CC'] = env.Detect(compilers) or 'clang' + if env['PLATFORM'] in ['cygwin', 'win32']: + env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') + else: + env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -fPIC') + # determine compiler version + if env['CC']: + #pipe = SCons.Action._subproc(env, [env['CC'], '-dumpversion'], + pipe = SCons.Action._subproc(env, [env['CC'], '--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['CCVERSION'] = 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 new file mode 100644 index 0000000..e2e50d4 --- /dev/null +++ b/src/engine/SCons/Tool/clang.xml @@ -0,0 +1,39 @@ + + + + +%scons; + +%builders-mod; + +%functions-mod; + +%tools-mod; + +%variables-mod; +]> + + + + + + +Set construction variables for the Clang C compiler. + + + +CC +SHCCFLAGS +CCVERSION + + + + diff --git a/test/Clang/clang++_default_environment.py b/test/Clang/clang++_default_environment.py new file mode 100644 index 0000000..beef1e5 --- /dev/null +++ b/test/Clang/clang++_default_environment.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +## This will likely NOT use clang++. + +test.write('SConstruct', """\ +env = Environment() +if env['CXX'] != 'clang++': + env['CXX'] = 'clang++' +env.Program('foo.cpp') +""") + +test.write('foo.cpp', """\ +#include +int main(int argc, char ** argv) { + std::cout << "Hello!" << std::endl; + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!\n') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang++_shared_library.py b/test/Clang/clang++_shared_library.py new file mode 100644 index 0000000..d850c98 --- /dev/null +++ b/test/Clang/clang++_shared_library.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +test.write('SConstruct', """\ +env = Environment(tools=['clang++', 'link']) +env.SharedLibrary('foo', 'foo.cpp') +""") + +test.write('foo.cpp', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist(test.workpath('libfoo.so')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang++_specific_environment.py b/test/Clang/clang++_specific_environment.py new file mode 100644 index 0000000..773fa94 --- /dev/null +++ b/test/Clang/clang++_specific_environment.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +test.write('SConstruct', """\ +env = Environment(tools=['clang++', 'link']) +env.Program('foo.cpp') +""") + +test.write('foo.cpp', """\ +#include +int main(int argc, char ** argv) { + std::cout << "Hello!" << std::endl; + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!\n') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang++_static_library.py b/test/Clang/clang++_static_library.py new file mode 100644 index 0000000..77ea58e --- /dev/null +++ b/test/Clang/clang++_static_library.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +test.write('SConstruct', """\ +env = Environment(tools=['clang++', 'ar']) +env.StaticLibrary('foo', 'foo.cpp') +""") + +test.write('foo.cpp', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist(test.workpath('libfoo.a')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang_default_environment.py b/test/Clang/clang_default_environment.py new file mode 100644 index 0000000..4ac1c68 --- /dev/null +++ b/test/Clang/clang_default_environment.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang', skipping test.\n") + +## This will likely NOT use clang + +test.write('SConstruct', """ +env = Environment() +if env['CC'] != 'clang': + env['CC'] = 'clang' +env.Program('foo.c') +""") + +test.write('foo.c', """\ +#include +int main(int argc, char ** argv) { + printf("Hello!"); + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang_shared_library.py b/test/Clang/clang_shared_library.py new file mode 100644 index 0000000..a0a112a --- /dev/null +++ b/test/Clang/clang_shared_library.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang', skipping test.\n") + +test.write('SConstruct', """\ +env = Environment(tools=['clang', 'link']) +env.SharedLibrary('foo', 'foo.c') +""") + +test.write('foo.c', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist(test.workpath('libfoo.so')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang_specific_environment.py b/test/Clang/clang_specific_environment.py new file mode 100644 index 0000000..7266a9f --- /dev/null +++ b/test/Clang/clang_specific_environment.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang', skipping test.\n") + +test.write('SConstruct', """\ +env = Environment(tools=['clang', 'link']) +env.Program('foo.c') +""") + +test.write('foo.c', """\ +#include +int main(int argc, char ** argv) { + printf("Hello!"); + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang_static_library.py b/test/Clang/clang_static_library.py new file mode 100644 index 0000000..39e9931 --- /dev/null +++ b/test/Clang/clang_static_library.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang', skipping test.\n") + +test.write('SConstruct', """\ +env = Environment(tools=['clang', 'ar']) +env.StaticLibrary('foo', 'foo.c') +""") + +test.write('foo.c', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist(test.workpath('libfoo.a')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 1f1871896e0de86e40135bedf519374d65bbde2e Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Wed, 21 Jun 2017 16:40:40 +0100 Subject: Be more careful about the shared library names. --- test/Clang/clang++_shared_library.py | 18 +++++++++++++++++- test/Clang/clang_shared_library.py | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/test/Clang/clang++_shared_library.py b/test/Clang/clang++_shared_library.py index d850c98..d6337ba 100644 --- a/test/Clang/clang++_shared_library.py +++ b/test/Clang/clang++_shared_library.py @@ -26,12 +26,27 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +from SCons.Environment import Base + _exe = TestSCons._exe test = TestSCons.TestSCons() if not test.where_is('clang'): test.skip_test("Could not find 'clang++', skipping test.\n") +platform = Base()['PLATFORM'] +if platform == 'posix': + filename = 'foo.os' + libraryname = 'libfoo.so' +elif platform == 'darwin': + filename = 'foo.os' + libraryname = 'libfoo.dylib' +elif platform == 'win32': + filename = 'foo.obj' + libraryname = 'foo.dll' +else: + test.fail_test() + test.write('SConstruct', """\ env = Environment(tools=['clang++', 'link']) env.SharedLibrary('foo', 'foo.cpp') @@ -45,7 +60,8 @@ int bar() { test.run() -test.must_exist(test.workpath('libfoo.so')) +test.must_exist(test.workpath(filename)) +test.must_exist(test.workpath(libraryname)) test.pass_test() diff --git a/test/Clang/clang_shared_library.py b/test/Clang/clang_shared_library.py index a0a112a..5e4d36f 100644 --- a/test/Clang/clang_shared_library.py +++ b/test/Clang/clang_shared_library.py @@ -25,6 +25,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +from SCons.Environment import Base _exe = TestSCons._exe test = TestSCons.TestSCons() @@ -32,6 +33,19 @@ test = TestSCons.TestSCons() if not test.where_is('clang'): test.skip_test("Could not find 'clang', skipping test.\n") +platform = Base()['PLATFORM'] +if platform == 'posix': + filename = 'foo.os' + libraryname = 'libfoo.so' +elif platform == 'darwin': + filename = 'foo.os' + libraryname = 'libfoo.dylib' +elif platform == 'win32': + filename = 'foo.obj' + libraryname = 'foo.dll' +else: + test.fail_test() + test.write('SConstruct', """\ env = Environment(tools=['clang', 'link']) env.SharedLibrary('foo', 'foo.c') @@ -45,7 +59,8 @@ int bar() { test.run() -test.must_exist(test.workpath('libfoo.so')) +test.must_exist(test.workpath(filename)) +test.must_exist(test.workpath(libraryname)) test.pass_test() -- cgit v0.12 From b6e8b657acfdfcbf3672b7c5894bf2166ab0a0c7 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Wed, 21 Jun 2017 16:49:57 +0100 Subject: Update the CHANGES.txt file. --- src/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 745c69d..9966229 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -82,6 +82,7 @@ RELEASE 3.0.0.alpha.20170614 - Mon, 14 Jun 2017 12:23:56 -0400 - Remove establishing the SharedLibrary builder in the dmd, ldc, and gdc tools, must now include the ar tool to get this builder as is required for other compiler tools. + - Add clang and clang++ tools based on Paweł Tomulik's work. RELEASE 2.5.1 - Mon, 03 Nov 2016 13:37:42 -0400 -- cgit v0.12 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 From 65c8b89f4255a80e45219724ccd49df445927c3e Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 2 Jul 2017 19:00:15 +0100 Subject: Remove inappropriate comment. Correct encoding lines. --- src/engine/SCons/Tool/clang.py | 2 +- src/engine/SCons/Tool/clangxx.py | 2 +- src/engine/SCons/Tool/clangxx.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Tool/clang.py b/src/engine/SCons/Tool/clang.py index 3075c46..177e6b2 100644 --- a/src/engine/SCons/Tool/clang.py +++ b/src/engine/SCons/Tool/clang.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8; -*- """SCons.Tool.clang diff --git a/src/engine/SCons/Tool/clangxx.py b/src/engine/SCons/Tool/clangxx.py index 60617db..dd501af 100644 --- a/src/engine/SCons/Tool/clangxx.py +++ b/src/engine/SCons/Tool/clangxx.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8; -*- """SCons.Tool.clang++ diff --git a/src/engine/SCons/Tool/clangxx.xml b/src/engine/SCons/Tool/clangxx.xml index 25ed1d4..2c1c2ca 100644 --- a/src/engine/SCons/Tool/clangxx.xml +++ b/src/engine/SCons/Tool/clangxx.xml @@ -32,7 +32,7 @@ Set construction variables for the Clang C++ compiler. CXX SHCXXFLAGS - +STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME SHOBJSUFFIX CXXVERSION -- cgit v0.12 From 1b54b04a80618be03001274f3ea75a2fdfb9a6e9 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 2 Jul 2017 19:06:33 +0100 Subject: Amend the test file names to remove + symbols from file names. --- test/Clang/clang++_default_environment.py | 64 -------------------------- test/Clang/clang++_shared_library.py | 72 ------------------------------ test/Clang/clang++_specific_environment.py | 60 ------------------------- test/Clang/clang++_static_library.py | 56 ----------------------- test/Clang/clangxx_default_environment.py | 64 ++++++++++++++++++++++++++ test/Clang/clangxx_shared_library.py | 72 ++++++++++++++++++++++++++++++ test/Clang/clangxx_specific_environment.py | 60 +++++++++++++++++++++++++ test/Clang/clangxx_static_library.py | 56 +++++++++++++++++++++++ 8 files changed, 252 insertions(+), 252 deletions(-) delete mode 100644 test/Clang/clang++_default_environment.py delete mode 100644 test/Clang/clang++_shared_library.py delete mode 100644 test/Clang/clang++_specific_environment.py delete mode 100644 test/Clang/clang++_static_library.py create mode 100644 test/Clang/clangxx_default_environment.py create mode 100644 test/Clang/clangxx_shared_library.py create mode 100644 test/Clang/clangxx_specific_environment.py create mode 100644 test/Clang/clangxx_static_library.py diff --git a/test/Clang/clang++_default_environment.py b/test/Clang/clang++_default_environment.py deleted file mode 100644 index beef1e5..0000000 --- a/test/Clang/clang++_default_environment.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -import TestSCons - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang++', skipping test.\n") - -## This will likely NOT use clang++. - -test.write('SConstruct', """\ -env = Environment() -if env['CXX'] != 'clang++': - env['CXX'] = 'clang++' -env.Program('foo.cpp') -""") - -test.write('foo.cpp', """\ -#include -int main(int argc, char ** argv) { - std::cout << "Hello!" << std::endl; - return 0; -} -""") - -test.run() - -test.run(program=test.workpath('foo'+_exe)) - -test.fail_test(not test.stdout() == 'Hello!\n') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang++_shared_library.py b/test/Clang/clang++_shared_library.py deleted file mode 100644 index d6337ba..0000000 --- a/test/Clang/clang++_shared_library.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -import TestSCons - -from SCons.Environment import Base - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang++', skipping test.\n") - -platform = Base()['PLATFORM'] -if platform == 'posix': - filename = 'foo.os' - libraryname = 'libfoo.so' -elif platform == 'darwin': - filename = 'foo.os' - libraryname = 'libfoo.dylib' -elif platform == 'win32': - filename = 'foo.obj' - libraryname = 'foo.dll' -else: - test.fail_test() - -test.write('SConstruct', """\ -env = Environment(tools=['clang++', 'link']) -env.SharedLibrary('foo', 'foo.cpp') -""") - -test.write('foo.cpp', """\ -int bar() { - return 42; -} -""") - -test.run() - -test.must_exist(test.workpath(filename)) -test.must_exist(test.workpath(libraryname)) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang++_specific_environment.py b/test/Clang/clang++_specific_environment.py deleted file mode 100644 index 773fa94..0000000 --- a/test/Clang/clang++_specific_environment.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -import TestSCons - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang++', skipping test.\n") - -test.write('SConstruct', """\ -env = Environment(tools=['clang++', 'link']) -env.Program('foo.cpp') -""") - -test.write('foo.cpp', """\ -#include -int main(int argc, char ** argv) { - std::cout << "Hello!" << std::endl; - return 0; -} -""") - -test.run() - -test.run(program=test.workpath('foo'+_exe)) - -test.fail_test(not test.stdout() == 'Hello!\n') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang++_static_library.py b/test/Clang/clang++_static_library.py deleted file mode 100644 index 77ea58e..0000000 --- a/test/Clang/clang++_static_library.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -import TestSCons - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang++', skipping test.\n") - -test.write('SConstruct', """\ -env = Environment(tools=['clang++', 'ar']) -env.StaticLibrary('foo', 'foo.cpp') -""") - -test.write('foo.cpp', """\ -int bar() { - return 42; -} -""") - -test.run() - -test.must_exist(test.workpath('libfoo.a')) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clangxx_default_environment.py b/test/Clang/clangxx_default_environment.py new file mode 100644 index 0000000..beef1e5 --- /dev/null +++ b/test/Clang/clangxx_default_environment.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +## This will likely NOT use clang++. + +test.write('SConstruct', """\ +env = Environment() +if env['CXX'] != 'clang++': + env['CXX'] = 'clang++' +env.Program('foo.cpp') +""") + +test.write('foo.cpp', """\ +#include +int main(int argc, char ** argv) { + std::cout << "Hello!" << std::endl; + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!\n') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clangxx_shared_library.py b/test/Clang/clangxx_shared_library.py new file mode 100644 index 0000000..d6337ba --- /dev/null +++ b/test/Clang/clangxx_shared_library.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +from SCons.Environment import Base + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +platform = Base()['PLATFORM'] +if platform == 'posix': + filename = 'foo.os' + libraryname = 'libfoo.so' +elif platform == 'darwin': + filename = 'foo.os' + libraryname = 'libfoo.dylib' +elif platform == 'win32': + filename = 'foo.obj' + libraryname = 'foo.dll' +else: + test.fail_test() + +test.write('SConstruct', """\ +env = Environment(tools=['clang++', 'link']) +env.SharedLibrary('foo', 'foo.cpp') +""") + +test.write('foo.cpp', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist(test.workpath(filename)) +test.must_exist(test.workpath(libraryname)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clangxx_specific_environment.py b/test/Clang/clangxx_specific_environment.py new file mode 100644 index 0000000..773fa94 --- /dev/null +++ b/test/Clang/clangxx_specific_environment.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +test.write('SConstruct', """\ +env = Environment(tools=['clang++', 'link']) +env.Program('foo.cpp') +""") + +test.write('foo.cpp', """\ +#include +int main(int argc, char ** argv) { + std::cout << "Hello!" << std::endl; + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!\n') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clangxx_static_library.py b/test/Clang/clangxx_static_library.py new file mode 100644 index 0000000..77ea58e --- /dev/null +++ b/test/Clang/clangxx_static_library.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +test.write('SConstruct', """\ +env = Environment(tools=['clang++', 'ar']) +env.StaticLibrary('foo', 'foo.cpp') +""") + +test.write('foo.cpp', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist(test.workpath('libfoo.a')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12