From 5ff62a39470b028178ab923a3efe0151fe64de7c Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Mon, 17 Apr 2017 17:51:16 +0100 Subject: Add an 'all at once' builder to the D tools. --- src/engine/SCons/Tool/dmd.py | 5 +++ src/engine/SCons/Tool/gdc.py | 4 ++ src/engine/SCons/Tool/ldc.py | 4 ++ test/D/AllAtOnce/Common/__init__.py | 0 test/D/AllAtOnce/Common/common.py | 71 ++++++++++++++++++++++++++++++ test/D/AllAtOnce/Common/sconstest.skip | 0 test/D/AllAtOnce/Image/SConstruct_template | 13 ++++++ test/D/AllAtOnce/Image/amod.d | 5 +++ test/D/AllAtOnce/Image/bmod.d | 3 ++ test/D/AllAtOnce/Image/main.d | 8 ++++ test/D/AllAtOnce/sconstest-dmd.py | 37 ++++++++++++++++ test/D/AllAtOnce/sconstest-gdc.py | 37 ++++++++++++++++ test/D/AllAtOnce/sconstest-ldc.py | 37 ++++++++++++++++ test/D/Issues/2994/image/SConstruct | 2 +- test/D/MixedDAndC/Image/SConstruct | 2 +- 15 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 test/D/AllAtOnce/Common/__init__.py create mode 100644 test/D/AllAtOnce/Common/common.py create mode 100644 test/D/AllAtOnce/Common/sconstest.skip create mode 100644 test/D/AllAtOnce/Image/SConstruct_template create mode 100644 test/D/AllAtOnce/Image/amod.d create mode 100644 test/D/AllAtOnce/Image/bmod.d create mode 100644 test/D/AllAtOnce/Image/main.d create mode 100644 test/D/AllAtOnce/sconstest-dmd.py create mode 100644 test/D/AllAtOnce/sconstest-gdc.py create mode 100644 test/D/AllAtOnce/sconstest-ldc.py diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py index 3722936..926786f 100644 --- a/src/engine/SCons/Tool/dmd.py +++ b/src/engine/SCons/Tool/dmd.py @@ -152,6 +152,11 @@ def generate(env): SCons.Tool.createStaticLibBuilder(env) + env['BUILDERS']['ProgramAllAtOnce'] = SCons.Builder.Builder( + action='$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -of$TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS', + ) + + def exists(env): return env.Detect(['dmd', 'gdmd']) diff --git a/src/engine/SCons/Tool/gdc.py b/src/engine/SCons/Tool/gdc.py index 32199b3..9ec12a5 100644 --- a/src/engine/SCons/Tool/gdc.py +++ b/src/engine/SCons/Tool/gdc.py @@ -128,6 +128,10 @@ def generate(env): SCons.Tool.createStaticLibBuilder(env) + env['BUILDERS']['ProgramAllAtOnce'] = SCons.Builder.Builder( + action='$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -o $TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS', + ) + def exists(env): return env.Detect('gdc') diff --git a/src/engine/SCons/Tool/ldc.py b/src/engine/SCons/Tool/ldc.py index ade95db..e478e11 100644 --- a/src/engine/SCons/Tool/ldc.py +++ b/src/engine/SCons/Tool/ldc.py @@ -144,6 +144,10 @@ def generate(env): SCons.Tool.createStaticLibBuilder(env) + env['BUILDERS']['ProgramAllAtOnce'] = SCons.Builder.Builder( + action='$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -of=$TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS', + ) + def exists(env): return env.Detect('ldc2') diff --git a/test/D/AllAtOnce/Common/__init__.py b/test/D/AllAtOnce/Common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/D/AllAtOnce/Common/common.py b/test/D/AllAtOnce/Common/common.py new file mode 100644 index 0000000..8750221 --- /dev/null +++ b/test/D/AllAtOnce/Common/common.py @@ -0,0 +1,71 @@ +""" +Test compiling and executing a project with a C module. +""" + +# +# __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 os.path import abspath, dirname + +import sys +sys.path.insert(1, abspath(dirname(__file__) + '/../../Support')) + +from executablesSearch import isExecutableOfToolAvailable + +def testForTool(tool): + + test = TestSCons.TestSCons() + + if not isExecutableOfToolAvailable(test, tool) : + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) + + test.dir_fixture('Image') + test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool)) + + test.run() + + test.must_not_exist(test.workpath('amod.o')) + test.must_not_exist(test.workpath('bmod.o')) + test.must_not_exist(test.workpath('main.o')) + if tool == 'gdc': + test.must_not_exist(test.workpath('project.o')) + else: + test.must_exist(test.workpath('project.o')) + test.must_exist(test.workpath('project')) + + test.run(program=test.workpath('project'+TestSCons._exe)) + test.fail_test(test.stdout() != '''This is a test program for a new SCons D builder. +The value is 42. +''') + + test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/D/AllAtOnce/Common/sconstest.skip b/test/D/AllAtOnce/Common/sconstest.skip new file mode 100644 index 0000000..e69de29 diff --git a/test/D/AllAtOnce/Image/SConstruct_template b/test/D/AllAtOnce/Image/SConstruct_template new file mode 100644 index 0000000..89d058e --- /dev/null +++ b/test/D/AllAtOnce/Image/SConstruct_template @@ -0,0 +1,13 @@ +# -*- coding:utf-8; -*- + +import os + +environment = Environment( + tools=['{}', 'link'], +) + +environment.ProgramAllAtOnce('project', [ +'main.d', +'amod.d', +'bmod.d', +]) diff --git a/test/D/AllAtOnce/Image/amod.d b/test/D/AllAtOnce/Image/amod.d new file mode 100644 index 0000000..a32aa75 --- /dev/null +++ b/test/D/AllAtOnce/Image/amod.d @@ -0,0 +1,5 @@ +import std.stdio; + +void print_message() { + writeln("This is a test program for a new SCons D builder."); +} diff --git a/test/D/AllAtOnce/Image/bmod.d b/test/D/AllAtOnce/Image/bmod.d new file mode 100644 index 0000000..e4c1e1b --- /dev/null +++ b/test/D/AllAtOnce/Image/bmod.d @@ -0,0 +1,3 @@ +int calculate_value() { + return 42; +} diff --git a/test/D/AllAtOnce/Image/main.d b/test/D/AllAtOnce/Image/main.d new file mode 100644 index 0000000..8b99458 --- /dev/null +++ b/test/D/AllAtOnce/Image/main.d @@ -0,0 +1,8 @@ +import std.stdio: writefln; +import amod: print_message; +import bmod: calculate_value; + +void main() { + print_message(); + writefln("The value is %d.", calculate_value()); +} diff --git a/test/D/AllAtOnce/sconstest-dmd.py b/test/D/AllAtOnce/sconstest-dmd.py new file mode 100644 index 0000000..df66255 --- /dev/null +++ b/test/D/AllAtOnce/sconstest-dmd.py @@ -0,0 +1,37 @@ +""" +Test compiling and executing a project with a C module. +""" + +# +# __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__" + +from Common.common import testForTool +testForTool('dmd') + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/D/AllAtOnce/sconstest-gdc.py b/test/D/AllAtOnce/sconstest-gdc.py new file mode 100644 index 0000000..7ac95c0 --- /dev/null +++ b/test/D/AllAtOnce/sconstest-gdc.py @@ -0,0 +1,37 @@ +""" +Test compiling and executing a project with a C module. +""" + +# +# __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__" + +from Common.common import testForTool +testForTool('gdc') + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/D/AllAtOnce/sconstest-ldc.py b/test/D/AllAtOnce/sconstest-ldc.py new file mode 100644 index 0000000..f9ab342 --- /dev/null +++ b/test/D/AllAtOnce/sconstest-ldc.py @@ -0,0 +1,37 @@ +""" +Test compiling and executing a project with a C module. +""" + +# +# __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__" + +from Common.common import testForTool +testForTool('ldc') + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/D/Issues/2994/image/SConstruct b/test/D/Issues/2994/image/SConstruct index 3d059e7..92f76c2 100644 --- a/test/D/Issues/2994/image/SConstruct +++ b/test/D/Issues/2994/image/SConstruct @@ -1,4 +1,4 @@ -# -*- coding:utf-8; -*- +# -*- mode:python; coding:utf-8; -*- env=Environment() diff --git a/test/D/MixedDAndC/Image/SConstruct b/test/D/MixedDAndC/Image/SConstruct index 176c4d3..f24e2b3 100644 --- a/test/D/MixedDAndC/Image/SConstruct +++ b/test/D/MixedDAndC/Image/SConstruct @@ -1,4 +1,4 @@ -# -*- codig:utf-8; -*- +# -*- mode:python; coding:utf-8; -*- import os -- cgit v0.12 From f41b6c8c5e74b85875bb7c0a621a863e242e83ef Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Tue, 18 Apr 2017 07:24:24 +0100 Subject: Update the src/CHANGES.txt file to reflect the new builder in the D tools. --- src/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 2b0c3cd..edd4f49 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -24,6 +24,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Russel Winder: - Reordered the default D tools from "dmd, gdc, ldc" to "dmd, ldc, gdc". + - Add a ProgramAllAtOnce builder to the dmd, ldc, and gdc tools. (PR #448) From William Blevins: - Updated D language scanner support to latest: 2.071.1. (PR #1924) -- cgit v0.12 From 43d08fb616192406272eb86ccb289adb9a664927 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Tue, 18 Apr 2017 12:31:09 +0100 Subject: Ensure all files pass pycodestyle caveat E501. Add an emitter to the D tool all at once builder to ensure the generate object file with dmd and ldc is noted, especially for deletion. --- src/engine/SCons/Tool/DCommon.py | 12 ++++++++++++ src/engine/SCons/Tool/dmd.py | 8 +++++--- src/engine/SCons/Tool/gdc.py | 4 ++++ src/engine/SCons/Tool/ldc.py | 11 +++++++---- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/engine/SCons/Tool/DCommon.py b/src/engine/SCons/Tool/DCommon.py index 02a5e73..c8ca8b9 100644 --- a/src/engine/SCons/Tool/DCommon.py +++ b/src/engine/SCons/Tool/DCommon.py @@ -1,3 +1,5 @@ +from __future__ import print_function + """SCons.Tool.DCommon Common code for the various D tools. @@ -32,6 +34,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path + def isD(env, source): if not source: return 0 @@ -42,6 +45,7 @@ def isD(env, source): return 1 return 0 + def addDPATHToEnv(env, executable): dPath = env.WhereIs(executable) if dPath: @@ -49,6 +53,14 @@ def addDPATHToEnv(env, executable): if os.path.isdir(phobosDir): env.Append(DPATH=[phobosDir]) + +def allAtOnceEmitter(target, source, env): + if env['DC'] in ('ldc2', 'dmd'): + env.SideEffect(str(target[0]) + '.o', str(target[0])) + env.Clean(str(target[0]), str(target[0]) + '.o') + return target, source + + # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py index 926786f..76e885b 100644 --- a/src/engine/SCons/Tool/dmd.py +++ b/src/engine/SCons/Tool/dmd.py @@ -1,3 +1,5 @@ +from __future__ import print_function + """SCons.Tool.dmd Tool-specific initialization for the Digital Mars D compiler. @@ -124,11 +126,10 @@ def generate(env): env['DLIBDIRSUFFIX'] = '' env['_DLIBDIRFLAGS'] = '${_concat(DLIBDIRPREFIX, LIBPATH, DLIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)}' - env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr' env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {0}$TARGET $SOURCES $_DLIBFLAGS'.format('-c ' if env['PLATFORM'] == 'win32' else '') - #env['_DLIBFLAGS'] = '${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)}' + # env['_DLIBFLAGS'] = '${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)}' env['DLIBFLAGPREFIX'] = '-' env['DLIBFLAGSUFFIX'] = '' @@ -154,13 +155,14 @@ def generate(env): env['BUILDERS']['ProgramAllAtOnce'] = SCons.Builder.Builder( action='$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -of$TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS', + emitter=SCons.Tool.DCommon.allAtOnceEmitter, ) - def exists(env): return env.Detect(['dmd', 'gdmd']) + # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/src/engine/SCons/Tool/gdc.py b/src/engine/SCons/Tool/gdc.py index 9ec12a5..9433643 100644 --- a/src/engine/SCons/Tool/gdc.py +++ b/src/engine/SCons/Tool/gdc.py @@ -1,3 +1,5 @@ +from __future__ import print_function + """SCons.Tool.gdc Tool-specific initialization for the GDC compiler. @@ -130,12 +132,14 @@ def generate(env): env['BUILDERS']['ProgramAllAtOnce'] = SCons.Builder.Builder( action='$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -o $TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS', + emitter=SCons.Tool.DCommon.allAtOnceEmitter, ) def exists(env): return env.Detect('gdc') + # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/src/engine/SCons/Tool/ldc.py b/src/engine/SCons/Tool/ldc.py index e478e11..d0585af 100644 --- a/src/engine/SCons/Tool/ldc.py +++ b/src/engine/SCons/Tool/ldc.py @@ -1,3 +1,5 @@ +from __future__ import print_function + """SCons.Tool.ldc Tool-specific initialization for the LDC compiler. @@ -103,24 +105,23 @@ def generate(env): env['DSHLINK'] = '$DC' env['DSHLINKFLAGS'] = SCons.Util.CLVar('$DLINKFLAGS -shared -defaultlib=phobos2-ldc') # Hack for Fedora the packages of which use the wrong name :-( - if os.path.exists('/usr/lib64/libphobos-ldc.so') or os.path.exists('/usr/lib32/libphobos-ldc.so') or os.path.exists('/usr/lib/libphobos-ldc.so') : + if os.path.exists('/usr/lib64/libphobos-ldc.so') or os.path.exists('/usr/lib32/libphobos-ldc.so') or os.path.exists('/usr/lib/libphobos-ldc.so'): env['DSHLINKFLAGS'] = SCons.Util.CLVar('$DLINKFLAGS -shared -defaultlib=phobos-ldc') env['SHDLINKCOM'] = '$DLINK -of=$TARGET $DSHLINKFLAGS $__DSHLIBVERSIONFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS' env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l' env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else '' - #env['_DLIBFLAGS'] = '${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)}' + # env['_DLIBFLAGS'] = '${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)}' env['_DLIBFLAGS'] = '${_stripixes(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__)}' env['DLIBDIRPREFIX'] = '-L-L' env['DLIBDIRSUFFIX'] = '' env['_DLIBDIRFLAGS'] = '${_concat(DLIBDIRPREFIX, LIBPATH, DLIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)}' - env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr' env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {0}$TARGET $SOURCES $_DLIBFLAGS'.format('-c ' if env['PLATFORM'] == 'win32' else '') - #env['_DLIBFLAGS'] = '${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)}' + # env['_DLIBFLAGS'] = '${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)}' env['DLIBFLAGPREFIX'] = '-' env['DLIBFLAGSUFFIX'] = '' @@ -146,12 +147,14 @@ def generate(env): env['BUILDERS']['ProgramAllAtOnce'] = SCons.Builder.Builder( action='$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -of=$TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS', + emitter=SCons.Tool.DCommon.allAtOnceEmitter, ) def exists(env): return env.Detect('ldc2') + # Local Variables: # tab-width:4 # indent-tabs-mode:nil -- cgit v0.12 From dc99a01347366fe7dcf0ac4485d6a7343a7c5afb Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Wed, 19 Apr 2017 03:46:32 +0100 Subject: Add tests for correct cleaning of correctly built and executing project built with ProgramAllAtOnce. --- test/D/AllAtOnce/Common/common.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/D/AllAtOnce/Common/common.py b/test/D/AllAtOnce/Common/common.py index 8750221..1713028 100644 --- a/test/D/AllAtOnce/Common/common.py +++ b/test/D/AllAtOnce/Common/common.py @@ -62,6 +62,14 @@ def testForTool(tool): The value is 42. ''') + test.run('-c') + + test.must_not_exist(test.workpath('amod.o')) + test.must_not_exist(test.workpath('bmod.o')) + test.must_not_exist(test.workpath('main.o')) + test.must_not_exist(test.workpath('project.o')) + test.must_not_exist(test.workpath('project')) + test.pass_test() # Local Variables: -- cgit v0.12 From 50f02b518073365437f57ab46924037c7f7e60ec Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Fri, 21 Apr 2017 09:55:57 +0100 Subject: First cut at proper documentation for the D tools. --- src/engine/SCons/Tool/dmd.xml | 168 +++++++++++++++++++++++++-- src/engine/SCons/Tool/gdc.xml | 262 +++++++++--------------------------------- src/engine/SCons/Tool/ldc.xml | 166 ++++++++++++++++++++++++-- 3 files changed, 371 insertions(+), 225 deletions(-) diff --git a/src/engine/SCons/Tool/dmd.xml b/src/engine/SCons/Tool/dmd.xml index f8936c1..dbbe9eb 100644 --- a/src/engine/SCons/Tool/dmd.xml +++ b/src/engine/SCons/Tool/dmd.xml @@ -32,10 +32,6 @@ Sets construction variables for D language compiler DMD. DC DCOM -_DINCFLAGS -_DVERFLAGS -_DDEBUGFLAGS -_DFLAGS SHDC SHDCOM DPATH @@ -59,21 +55,177 @@ Sets construction variables for D language compiler DMD. SHDLINKCOM DLIBLINKPREFIX DLIBLINKSUFFIX -_DLIBFLAGS DLIBDIRPREFIX DLIBDIRSUFFIX -_DLIBDIRFLAGS DLIB DLIBCOM -_DLIBFLAGS DLIBFLAGPREFIX DLIBFLAGSUFFIX +DLINKFLAGPREFIX +DLINKFLAGSUFFIX RPATHPREFIX RPATHSUFFIX -_RPATH + + + +The D compiler to use. + + + + + + + + The command line used to compile a D file to an object file. + Any options specified in the &cv-link-DFLAGS; construction variable + is included on this command line. + + + + + + + + List of debug tags to enable when compiling. + + + + + + + + General options that are passed to the D compiler. + + + + + + + + Name of the lib tool to use for D codes. + + + + + + + + The command line to use when creating libraries. + + + + + + + + Name of the linker to use for linking systems including D sources. + + + + + + + + The command line to use when linking systems including D sources. + + + + + + + +List of linker flags. + + + + + + + + List of paths to search for import modules. + + + + + + + + List of version tags to enable when compiling. + + + + + + + + The name of the compiler to use when compiling D source + destined to be in a shared objects. + + + + + + + + The command line to use when compiling code to be part of shared objects. + + + + + + + + The linker to use when creating shared objects for code bases + include D sources. + + + + + + + + The command line to use when generating shared objects. + + + + + + + + The list of flags to use when generating a shared object. + + + + + + + + Builds an executable from D sources without first creating individual + objects for each file. + + + D sources can be compiled file-by-file as C and C++ source are, and + D is integrated into the &scons; Object and Program builders for + this model of build. D codes can though do whole source + meta-programming (some of the testing frameworks do this). For this + it is imperative that all sources are compiled and linked in a single call of + the D compiler. This builder serves that purpose. + + + env.ProgramAllAtOnce('executable', ['mod_a.d, mod_b.d', 'mod_c.d']) + + + This command will compile the modules mod_a, mod_b, and mod_c in a + single compilation process without first creating object files for + the modules. Some of the D compilers will create executable.o others + will not. + + + + diff --git a/src/engine/SCons/Tool/gdc.xml b/src/engine/SCons/Tool/gdc.xml index 20544b0..5ef1f9a 100644 --- a/src/engine/SCons/Tool/gdc.xml +++ b/src/engine/SCons/Tool/gdc.xml @@ -32,10 +32,6 @@ Sets construction variables for the D language compiler GDC. DC DCOM -_DINCFLAGS -_DVERFLAGS -_DDEBUGFLAGS -_DFLAGS SHDC SHDCOM DPATH @@ -57,16 +53,18 @@ Sets construction variables for the D language compiler GDC. SHDLINK SHDLINKFLAGS SHDLINKCOM +DLIBLINKPREFIX +DLIBLINKSUFFIX +DLIBDIRPREFIX +DLIBDIRSUFFIX DLIB DLIBCOM -_DLIBFLAGS DLIBFLAGPREFIX DLIBFLAGSUFFIX DLINKFLAGPREFIX DLINKFLAGSUFFIX RPATHPREFIX RPATHSUFFIX -_RPATH @@ -75,7 +73,7 @@ Sets construction variables for the D language compiler GDC. -DC. +The D compiler to use. @@ -83,7 +81,9 @@ DC. -DCOM. + The command line used to compile a D file to an object file. + Any options specified in the &cv-link-DFLAGS; construction variable + is included on this command line. @@ -91,39 +91,7 @@ DCOM. -DDEBUG. - - - - - - - -DDEBUGPREFIX. - - - - - - - -DDEBUGSUFFIX. - - - - - - - -DFILESUFFIX. - - - - - - - -DFLAGPREFIX. + List of debug tags to enable when compiling. @@ -131,31 +99,7 @@ DFLAGPREFIX. -DFLAGS. - - - - - - - -DFLAGSUFFIX. - - - - - - - -DINCPREFIX. - - - - - - - -DINCSUFFIX. + General options that are passed to the D compiler. @@ -163,7 +107,7 @@ DINCSUFFIX. -DLIB. + Name of the lib tool to use for D codes. @@ -171,55 +115,7 @@ DLIB. -DLIBCOM. - - - - - - - -DLIBDIRPREFIX. - - - - - - - -DLIBDIRSUFFIX. - - - - - - - -DLIBFLAGPREFIX. - - - - - - - -DLIBFLAGSUFFIX. - - - - - - - -DLIBLINKPREFIX. - - - - - - - -DLIBLINKSUFFIX. + The command line to use when creating libraries. @@ -227,7 +123,7 @@ DLIBLINKSUFFIX. -DLINK. + Name of the linker to use for linking systems including D sources. @@ -235,15 +131,7 @@ DLINK. -DLINKCOM. - - - - - - - -DLINKFLAGPREFIX. + The command line to use when linking systems including D sources. @@ -251,15 +139,7 @@ DLINKFLAGPREFIX. -DLINKFLAGS. - - - - - - - -DLINKFLAGSUFFIX. +List of linker flags. @@ -267,15 +147,7 @@ DLINKFLAGSUFFIX. -DPATH. - - - - - - - -DVERPREFIX. + List of paths to search for import modules. @@ -283,15 +155,7 @@ DVERPREFIX. -DVERSIONS. - - - - - - - -DVERSUFFIX. + List of version tags to enable when compiling. @@ -299,7 +163,8 @@ DVERSUFFIX. -SHDC. + The name of the compiler to use when compiling D source + destined to be in a shared objects. @@ -307,7 +172,7 @@ SHDC. -SHDCOM. + The command line to use when compiling code to be part of shared objects. @@ -315,7 +180,8 @@ SHDCOM. -SHDLINK. + The linker to use when creating shared objects for code bases + include D sources. @@ -323,7 +189,7 @@ SHDLINK. -SHDLINKCOM. + The command line to use when generating shared objects. @@ -331,57 +197,35 @@ SHDLINKCOM. -SHDLINKFLAGS. - - - - - - - -_DDEBUGFLAGS. - - - - - - - -_DFLAGS. - - - - - - - -_DINCFLAGS. - - - - - - - -_DLIBDIRFLAGS. - - - - - - - -_DLIBFLAGS. - - - - - - - -_DVERFLAGS. - - - + The list of flags to use when generating a shared object. + + + + + + + + Builds an executable from D sources without first creating individual + objects for each file. + + + D sources can be compiled file-by-file as C and C++ source are, and + D is integrated into the &scons; Object and Program builders for + this model of build. D codes can though do whole source + meta-programming (some of the testing frameworks do this). For this + it is imperative that all sources are compiled and linked in a single call of + the D compiler. This builder serves that purpose. + + + env.ProgramAllAtOnce('executable', ['mod_a.d, mod_b.d', 'mod_c.d']) + + + This command will compile the modules mod_a, mod_b, and mod_c in a + single compilation process without first creating object files for + the modules. Some of the D compilers will create executable.o others + will not. + + + diff --git a/src/engine/SCons/Tool/ldc.xml b/src/engine/SCons/Tool/ldc.xml index f07144b..9593f41 100644 --- a/src/engine/SCons/Tool/ldc.xml +++ b/src/engine/SCons/Tool/ldc.xml @@ -32,10 +32,6 @@ Sets construction variables for the D language compiler LDC2. DC DCOM -_DINCFLAGS -_DVERFLAGS -_DDEBUGFLAGS -_DFLAGS SHDC SHDCOM DPATH @@ -59,23 +55,177 @@ Sets construction variables for the D language compiler LDC2. SHDLINKCOM DLIBLINKPREFIX DLIBLINKSUFFIX -_DLIBFLAGS DLIBDIRPREFIX DLIBDIRSUFFIX -_DLIBDIRFLAGS DLIB DLIBCOM -_DLIBFLAGS DLIBFLAGPREFIX DLIBFLAGSUFFIX DLINKFLAGPREFIX DLINKFLAGSUFFIX RPATHPREFIX RPATHSUFFIX -_RPATH + + + +The D compiler to use. + + + + + + + + The command line used to compile a D file to an object file. + Any options specified in the &cv-link-DFLAGS; construction variable + is included on this command line. + + + + + + + + List of debug tags to enable when compiling. + + + + + + + + General options that are passed to the D compiler. + + + + + + + + Name of the lib tool to use for D codes. + + + + + + + + The command line to use when creating libraries. + + + + + + + + Name of the linker to use for linking systems including D sources. + + + + + + + + The command line to use when linking systems including D sources. + + + + + + + +List of linker flags. + + + + + + + + List of paths to search for import modules. + + + + + + + + List of version tags to enable when compiling. + + + + + + + + The name of the compiler to use when compiling D source + destined to be in a shared objects. + + + + + + + + The command line to use when compiling code to be part of shared objects. + + + + + + + + The linker to use when creating shared objects for code bases + include D sources. + + + + + + + + The command line to use when generating shared objects. + + + + + + + + The list of flags to use when generating a shared object. + + + + + + + + Builds an executable from D sources without first creating individual + objects for each file. + + + D sources can be compiled file-by-file as C and C++ source are, and + D is integrated into the &scons; Object and Program builders for + this model of build. D codes can though do whole source + meta-programming (some of the testing frameworks do this). For this + it is imperative that all sources are compiled and linked in a single call of + the D compiler. This builder serves that purpose. + + + env.ProgramAllAtOnce('executable', ['mod_a.d, mod_b.d', 'mod_c.d']) + + + This command will compile the modules mod_a, mod_b, and mod_c in a + single compilation process without first creating object files for + the modules. Some of the D compilers will create executable.o others + will not. + + + + -- cgit v0.12 From 334c534cb365ff206a2ddef5e09c9e8f728b9eb0 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Mon, 1 May 2017 15:41:18 +0100 Subject: Simplify a couple of calls. --- src/engine/SCons/Tool/DCommon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Tool/DCommon.py b/src/engine/SCons/Tool/DCommon.py index c8ca8b9..c08f040 100644 --- a/src/engine/SCons/Tool/DCommon.py +++ b/src/engine/SCons/Tool/DCommon.py @@ -56,8 +56,8 @@ def addDPATHToEnv(env, executable): def allAtOnceEmitter(target, source, env): if env['DC'] in ('ldc2', 'dmd'): - env.SideEffect(str(target[0]) + '.o', str(target[0])) - env.Clean(str(target[0]), str(target[0]) + '.o') + env.SideEffect(str(target[0]) + '.o', target[0]) + env.Clean(target[0], str(target[0]) + '.o') return target, source -- cgit v0.12