Commits

Russel Winder committed b757fe3

The changes to the D support evolved over the last many months packaged as a single changeset.

Comments (0)

Files changed (95)

 
 RELEASE 2.3.2.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
 
+  From Russel Winder:
+    - Revamp of the D language support. Tools for DMD, GDC and LDC provided
+      and integrated with the C and C++ linking.   NB  This is only tested with
+      D v2, D v1 is now deprecated.
+
   From Gary Oberbrunner:
     - get default RPM architecture more robustly when building RPMs
 

src/engine/MANIFEST.in

 SCons/Tool/cyglink.py
 SCons/Tool/cvf.py
 SCons/Tool/CVS.py
+SCons/Tool/DCommon.py
 SCons/Tool/default.py
 SCons/Tool/dmd.py
 SCons/Tool/docbook/__init__.py
 SCons/Tool/g77.py
 SCons/Tool/gas.py
 SCons/Tool/gcc.py
+SCons/Tool/gdc.py
 SCons/Tool/gfortran.py
 SCons/Tool/gnulink.py
 SCons/Tool/gs.py
 SCons/Tool/javac.py
 SCons/Tool/javah.py
 SCons/Tool/latex.py
+SCons/Tool/ldc.py
 SCons/Tool/lex.py
 SCons/Tool/link.py
 SCons/Tool/linkloc.py

src/engine/SCons/Defaults.py

 CXXAction = SCons.Action.Action("$CXXCOM", "$CXXCOMSTR")
 ShCXXAction = SCons.Action.Action("$SHCXXCOM", "$SHCXXCOMSTR")
 
+DAction = SCons.Action.Action("$DCOM", "$DCOMSTR")
+ShDAction = SCons.Action.Action("$SHDCOM", "$SHDCOMSTR")
+
 ASAction = SCons.Action.Action("$ASCOM", "$ASCOMSTR")
 ASPPAction = SCons.Action.Action("$ASPPCOM", "$ASPPCOMSTR")
 
     where it finds them.  This is used by tools (like the GNU linker)
     that need to turn something like 'libfoo.a' into '-lfoo'.
     """
-    
+
     if not itms:
         return itms
 
             c = env_c
         else:
             c = _concat_ixes
-    
+
     stripprefixes = list(map(env.subst, SCons.Util.flatten(stripprefixes)))
     stripsuffixes = list(map(env.subst, SCons.Util.flatten(stripsuffixes)))
 
     """
 
     return c(prefix, env.subst_path(processDefines(defs)), suffix, env)
-    
+
 class NullCmdGenerator(object):
     """This is a callable class that can be used in place of other
     command generators if you don't want them to do anything.
         self.method = method
     def __call__(self, *args, **kw):
         try: 1//0
-        except ZeroDivisionError: 
+        except ZeroDivisionError:
             # Don't start iterating with the current stack-frame to
             # prevent creating reference cycles (f_back is safe).
             frame = sys.exc_info()[2].tb_frame.f_back

src/engine/SCons/Tool/DCommon.py

+"""SCons.Tool.DCommon
+
+Common code for the various D tools.
+
+Coded by Russel Winder (russel@winder.org.uk)
+2012-09-06
+"""
+#
+# __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 os.path
+
+def isD(env, source):
+    if not source:
+        return 0
+    for s in source:
+        if s.sources:
+            ext = os.path.splitext(str(s.sources[0]))[1]
+            if ext == '.d':
+                return 1
+    return 0
+
+def addDPATHToEnv(env, executable):
+    dPath = env.WhereIs(executable)
+    if dPath:
+        phobosDir = dPath[:dPath.rindex(executable)] + '/../src/phobos'
+        if os.path.isdir(phobosDir):
+            env.Append(DPATH=[phobosDir])
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

src/engine/SCons/Tool/__init__.py

         assemblers = ['masm', 'nasm', 'gas', '386asm' ]
         fortran_compilers = ['gfortran', 'g77', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
         ars = ['mslib', 'ar', 'tlib']
-        other_plat_tools=['msvs','midl']
+        other_plat_tools = ['msvs', 'midl']
     elif str(platform) == 'os2':
         "prefer IBM tools on OS/2"
         linkers = ['ilink', 'gnulink', ]#'mslink']
         fortran_compiler = FindTool(fortran_compilers, env) or fortran_compilers[0]
         ar = FindTool(ars, env) or ars[0]
 
+    d_compilers = ['dmd', 'gdc', 'ldc']
+    d_compiler = FindTool(d_compilers, env) or d_compilers[0]
    1. Russel Winder author

      Given the number of C, C++, and Fortran tools, I can't see these three tools adding much extra overhead. D has always been, and should, at least in my view, remain a peer to C and C++. We would have to collect benchmark data to really take this further.

        1. Gary Oberbrunner

          It's only a lot when running the tests. In real scenarios it is barely noticeable. The real answer here is to work on the new toolchain subsystem; one of the goals of that is to initialize tools more lazily. That would both speed up startup and allow more tools to be available by default. I think Russel's change here is fine.

+
     other_tools = FindAllTools(other_plat_tools + [
-                               'dmd',
                                #TODO: merge 'install' into 'filesystem' and
                                # make 'filesystem' the default
                                'filesystem',
                                ], env)
 
     tools = ([linker, c_compiler, cxx_compiler,
-              fortran_compiler, assembler, ar]
+              fortran_compiler, assembler, ar, d_compiler]
              + other_tools)
 
     return [x for x in tools if x]

src/engine/SCons/Tool/dmd.py

 Tool-specific initialization for the Digital Mars D compiler.
 (http://digitalmars.com/d)
 
-Coded by Andy Friesen (andy@ikagames.com)
+Originally coded by Andy Friesen (andy@ikagames.com)
 15 November 2003
 
-Amended by Russel Winder (russel@russel.org.uk)
-2010-02-07
+Evolved by Russel Winder (russel@winder.org.uk)
+2010-02-07 onwards
 
 There are a number of problems with this script at this point in time.
-The one that irritates me the most is the Windows linker setup.  The D
+The one that irritates the most is the Windows linker setup.  The D
 linker doesn't have a way to add lib paths on the commandline, as far
 as I can see.  You have to specify paths relative to the SConscript or
 use absolute paths.  To hack around it, add '#/blah'.  This will link
 
 Compiler variables:
     DC - The name of the D compiler to use.  Defaults to dmd or gdmd,
-    whichever is found.
+        whichever is found.
     DPATH - List of paths to search for import modules.
     DVERSIONS - List of version tags to enable when compiling.
     DDEBUG - List of debug tags to enable when compiling.
 
 Linker related variables:
     LIBS - List of library files to link in.
-    DLINK - Name of the linker to use.  Defaults to dmd or gdmd.
+    DLINK - Name of the linker to use.  Defaults to dmd or gdmd,
+        whichever is found.
     DLINKFLAGS - List of linker flags.
 
 Lib tool variables:
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import os
+import subprocess
 
 import SCons.Action
 import SCons.Builder
 import SCons.Scanner.D
 import SCons.Tool
 
-# Adapted from c++.py
-def isD(source):
-    if not source:
-        return 0
+import SCons.Tool.DCommon
 
-    for s in source:
-        if s.sources:
-            ext = os.path.splitext(str(s.sources[0]))[1]
-            if ext == '.d':
-                return 1
-    return 0
-
-smart_link = {}
-
-smart_lib = {}
 
 def generate(env):
-    global smart_link
-    global smart_lib
-
     static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
 
-    DAction = SCons.Action.Action('$DCOM', '$DCOMSTR')
-
-    static_obj.add_action('.d', DAction)
-    shared_obj.add_action('.d', DAction)
+    static_obj.add_action('.d', SCons.Defaults.DAction)
+    shared_obj.add_action('.d', SCons.Defaults.ShDAction)
     static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter)
     shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter)
 
-    dc = env.Detect(['dmd', 'gdmd'])
-    env['DC'] = dc
+    env['DC'] = env.Detect(['dmd', 'gdmd'])
     env['DCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -of$TARGET $SOURCES'
     env['_DINCFLAGS'] = '$( ${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs, TARGET, SOURCE)}  $)'
     env['_DVERFLAGS'] = '$( ${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)}  $)'
     env['_DDEBUGFLAGS'] = '$( ${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)} $)'
     env['_DFLAGS'] = '$( ${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)} $)'
 
+    env['SHDC'] = '$DC'
+    env['SHDCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -fPIC -of$TARGET $SOURCES'
+
     env['DPATH'] = ['#/']
     env['DFLAGS'] = []
     env['DVERSIONS'] = []
     env['DDEBUG'] = []
 
-    if dc:
-        # Add the path to the standard library.
-        # This is merely for the convenience of the dependency scanner.
-        dmd_path = env.WhereIs(dc)
-        if dmd_path:
-            x = dmd_path.rindex(dc)
-            phobosDir = dmd_path[:x] + '/../src/phobos'
-            if os.path.isdir(phobosDir):
-                env.Append(DPATH = [phobosDir])
+    #env['SHOBJSUFFIX'] = '.os'
+    #env['OBJSUFFIX'] = '.o'
+    env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0
+
+    if env['DC']:
+        SCons.Tool.DCommon.addDPATHToEnv(env, env['DC'])
 
     env['DINCPREFIX'] = '-I'
     env['DINCSUFFIX'] = ''
     env['DFLAGSUFFIX'] = ''
     env['DFILESUFFIX'] = '.d'
 
-    # Need to use the Digital Mars linker/lib on windows.
-    # *nix can just use GNU link.
-    if env['PLATFORM'] == 'win32':
-        env['DLINK'] = '$DC'
-        env['DLINKCOM'] = '$DLINK -of$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
-        env['DLIB'] = 'lib'
-        env['DLIBCOM'] = '$DLIB $_DLIBFLAGS -c $TARGET $SOURCES $_DLINKLIBFLAGS'
+    env['DLINK'] = '$DC'
+    env['DLINKCOM'] = '$DLINK -of$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+    env['SHDLINKCOM'] = '$DLINK -shared -defaultlib=libphobos2.so -of$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
 
-        env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
-        env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
-        env['DLINKFLAGS'] = []
-        env['DLIBLINKPREFIX'] = ''
-        env['DLIBLINKSUFFIX'] = '.lib'
-        env['DLIBFLAGPREFIX'] = '-'
-        env['DLIBFLAGSUFFIX'] = ''
-        env['DLINKFLAGPREFIX'] = '-'
-        env['DLINKFLAGSUFFIX'] = ''
+    env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr'
+    env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {} $TARGET $SOURCES $_DLINKLIBFLAGS'.format('-c' if env['PLATFORM'] == 'win32' else '')
 
-        SCons.Tool.createStaticLibBuilder(env)
+    env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+    env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
+    env['DLINKFLAGS'] = ['-L-L.']
+    env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l'
+    env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else ''
+    env['DLIBFLAGPREFIX'] = '-'
+    env['DLIBFLAGSUFFIX'] = ''
+    env['DLINKFLAGPREFIX'] = '-'
+    env['DLINKFLAGSUFFIX'] = ''
 
-        # Basically, we hijack the link and ar builders with our own.
-        # these builders check for the presence of D source, and swap out
-        # the system's defaults for the Digital Mars tools.  If there's no D
-        # source, then we silently return the previous settings.
-        linkcom = env.get('LINKCOM')
-        try:
-            env['SMART_LINKCOM'] = smart_link[linkcom]
-        except KeyError:
-            def _smartLink(source, target, env, for_signature,
-                           defaultLinker=linkcom):
-                if isD(source):
-                    # XXX I'm not sure how to add a $DLINKCOMSTR variable
-                    # so that it works with this _smartLink() logic,
-                    # and I don't have a D compiler/linker to try it out,
-                    # so we'll leave it alone for now.
-                    return '$DLINKCOM'
-                else:
-                    return defaultLinker
-            env['SMART_LINKCOM'] = smart_link[linkcom] = _smartLink
+    SCons.Tool.createStaticLibBuilder(env)
 
-        arcom = env.get('ARCOM')
-        try:
-            env['SMART_ARCOM'] = smart_lib[arcom]
-        except KeyError:
-            def _smartLib(source, target, env, for_signature,
-                         defaultLib=arcom):
-                if isD(source):
-                    # XXX I'm not sure how to add a $DLIBCOMSTR variable
-                    # so that it works with this _smartLib() logic, and
-                    # I don't have a D compiler/archiver to try it out,
-                    # so we'll leave it alone for now.
-                    return '$DLIBCOM'
-                else:
-                    return defaultLib
-            env['SMART_ARCOM'] = smart_lib[arcom] = _smartLib
-
-        # It is worth noting that the final space in these strings is
-        # absolutely pivotal.  SCons sees these as actions and not generators
-        # if it is not there. (very bad)
-        env['ARCOM'] = '$SMART_ARCOM '
-        env['LINKCOM'] = '$SMART_LINKCOM '
-    else: # assuming linux
-        linkcom = env.get('LINKCOM')
-        try:
-            env['SMART_LINKCOM'] = smart_link[linkcom]
-        except KeyError:
-            def _smartLink(source, target, env, for_signature,
-                           defaultLinker=linkcom, dc=dc):
-                if isD(source):
-                    try:
-                        libs = env['LIBS']
-                    except KeyError:
-                        libs = []
-                    if dc == 'dmd':
-                        # TODO: This assumes that the dmd executable is in the
-                        # bin directory and that the libraries are in a peer
-                        # directory lib.  This true of the Digital Mars
-                        # distribution but . . .
-                        import glob
-                        dHome = env.WhereIs(dc).replace('/dmd' , '/..')
-                        if glob.glob(dHome + '/lib/*phobos2*'):
-                            if 'phobos2' not in libs:
-                                env.Append(LIBPATH = [dHome + '/lib'])
-                                env.Append(LIBS = ['phobos2'])
-                                # TODO: Find out when there will be a
-                                # 64-bit version of D.
-                                env.Append(LINKFLAGS = ['-m32'])
-                        else:
-                            if 'phobos' not in libs:
-                                env.Append(LIBS = ['phobos'])
-                    elif dc is 'gdmd':
-                        env.Append(LIBS = ['gphobos'])
-                    if 'pthread' not in libs:
-                        env.Append(LIBS = ['pthread'])
-                    if 'm' not in libs:
-                        env.Append(LIBS = ['m'])
-                return defaultLinker
-            env['SMART_LINKCOM'] = smart_link[linkcom] = _smartLink
-
-        env['LINKCOM'] = '$SMART_LINKCOM '
 
 def exists(env):
     return env.Detect(['dmd', 'gdmd'])

src/engine/SCons/Tool/dmd.xml

 </para>
 </summary>
 <sets>
-<item><!--</item>
 <item>DC</item>
 <item>DCOM</item>
 <item>_DINCFLAGS</item>
 <item>_DVERFLAGS</item>
 <item>_DDEBUGFLAGS</item>
 <item>_DFLAGS</item>
+<item>SHDC</item>
+<item>SHDCOM</item>
 <item>DPATH</item>
 <item>DFLAGS</item>
 <item>DVERSIONS</item>
 <item>DDEBUG</item>
+<item>STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME</item>
 <item>DINCPREFIX</item>
 <item>DINCSUFFIX</item>
 <item>DVERPREFIX</item>
 <item>DFLESUFFIX</item>
 <item>DLINK</item>
 <item>DLINKCOM</item>
+<item>SHDLINKCOM</item>
 <item>DLIB</item>
 <item>DLIBCOM</item>
 <item>_DLINKLIBFLAGS</item>
 <item>DLIBFLAGSUFFIX</item>
 <item>DLINKFLAGPREFIX</item>
 <item>DLINKFLAGSUFFIX</item>
-<item>LINKCOM</item>
-<item>ARCOM</item>
-<item>LIBS</item>
-<item>--></item>
 </sets>
 <uses>
 </uses>

src/engine/SCons/Tool/gdc.py

+"""SCons.Tool.gdc
+
+Tool-specific initialization for the GDC compiler.
+(https://github.com/D-Programming-GDC/GDC)
+
+Developed by Russel Winder (russel@winder.org.uk)
+2012-05-09 onwards
+
+Compiler variables:
+    DC - The name of the D compiler to use.  Defaults to gdc.
+    DPATH - List of paths to search for import modules.
+    DVERSIONS - List of version tags to enable when compiling.
+    DDEBUG - List of debug tags to enable when compiling.
+
+Linker related variables:
+    LIBS - List of library files to link in.
+    DLINK - Name of the linker to use.  Defaults to gdc.
+    DLINKFLAGS - List of linker flags.
+
+Lib tool variables:
+    DLIB - Name of the lib tool to use.  Defaults to lib.
+    DLIBFLAGS - List of flags to pass to the lib tool.
+    LIBS - Same as for the linker. (libraries to pull into the .lib)
+"""
+
+#
+# __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 SCons.Action
+import SCons.Defaults
+import SCons.Tool
+
+import SCons.Tool.DCommon
+
+
+def generate(env):
+    static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+    static_obj.add_action('.d', SCons.Defaults.DAction)
+    shared_obj.add_action('.d', SCons.Defaults.ShDAction)
+    static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter)
+    shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter)
+
+    env['DC'] = env.Detect('gdc')
+    env['DCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -o $TARGET $SOURCES'
+    env['_DINCFLAGS'] = '$( ${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs, TARGET, SOURCE)}  $)'
+    env['_DVERFLAGS'] = '$( ${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)}  $)'
+    env['_DDEBUGFLAGS'] = '$( ${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)} $)'
+    env['_DFLAGS'] = '$( ${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)} $)'
+
+    env['SHDC'] = '$DC'
+    env['SHDCOM'] = '$SHDC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -fPIC -c -o $TARGET $SOURCES'
+
+    env['DPATH'] = ['#/']
+    env['DFLAGS'] = []
+    env['DVERSIONS'] = []
+    env['DDEBUG'] = []
+
+    env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0
+
+    if env['DC']:
+        SCons.Tool.DCommon.addDPATHToEnv(env, env['DC'])
+
+    env['DINCPREFIX'] = '-I'
+    env['DINCSUFFIX'] = ''
+    env['DVERPREFIX'] = '-version='
+    env['DVERSUFFIX'] = ''
+    env['DDEBUGPREFIX'] = '-debug='
+    env['DDEBUGSUFFIX'] = ''
+    env['DFLAGPREFIX'] = '-'
+    env['DFLAGSUFFIX'] = ''
+    env['DFILESUFFIX'] = '.d'
+
+    env['DLINK'] = '$DC'
+    env['DLINKCOM'] = '$DLINK -o $TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+    env['SHDLINKCOM'] = '$DLINK -o $TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+
+    env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr'
+    env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {} $TARGET $SOURCES $_DLINKLIBFLAGS'.format('-c' if env['PLATFORM'] == 'win32' else '')
+
+    env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+    env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
+    env['DLINKFLAGS'] = ['-L.']
+    env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-l'
+    env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else ''
+    env['DLIBFLAGPREFIX'] = '-'
+    env['DLIBFLAGSUFFIX'] = ''
+    env['DLINKFLAGPREFIX'] = '-'
+    env['DLINKFLAGSUFFIX'] = ''
+
+    SCons.Tool.createStaticLibBuilder(env)
+
+
+def exists(env):
+    return env.Detect('gdc')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

src/engine/SCons/Tool/gdc.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+__COPYRIGHT__
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+
+<!DOCTYPE sconsdoc [
+<!ENTITY % scons SYSTEM '../../../../doc/scons.mod'>
+%scons;
+<!ENTITY % builders-mod SYSTEM '../../../../doc/generated/builders.mod'>
+%builders-mod;
+<!ENTITY % functions-mod SYSTEM '../../../../doc/generated/functions.mod'>
+%functions-mod;
+<!ENTITY % tools-mod SYSTEM '../../../../doc/generated/tools.mod'>
+%tools-mod;
+<!ENTITY % variables-mod SYSTEM '../../../../doc/generated/variables.mod'>
+%variables-mod;
+]>
+
+<sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0/scons.xsd scons.xsd">
+
+<tool name="gdc">
+<summary>
+<para>
+Sets construction variables for the D language compiler GDC.
+</para>
+</summary>
+<sets>
+<item>DC</item>
+<item>DCOM</item>
+<item>_DINCFLAGS</item>
+<item>_DVERFLAGS</item>
+<item>_DDEBUGFLAGS</item>
+<item>_DFLAGS</item>
+<item>SHDC</item>
+<item>SHDCOM</item>
+<item>DPATH</item>
+<item>DFLAGS</item>
+<item>DVERSIONS</item>
+<item>DDEBUG</item>
+<item>STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME</item>
+<item>DINCPREFIX</item>
+<item>DINCSUFFIX</item>
+<item>DVERPREFIX</item>
+<item>DVERSUFFIX</item>
+<item>DDEBUGPREFIX</item>
+<item>DDEBUGSUFFIX</item>
+<item>DFLAGPREFIX</item>
+<item>DFLAGSUFFIX</item>
+<item>DFLESUFFIX</item>
+<item>DLINK</item>
+<item>DLINKCOM</item>
+<item>SHDLINKCOM</item>
+<item>DLIB</item>
+<item>DLIBCOM</item>
+<item>_DLINKLIBFLAGS</item>
+<item>_DLIBFLAGS</item>
+<item>DLINKFLAGS</item>
+<item>DLIBLINKPREFIX</item>
+<item>DLIBLINKSUFFIX</item>
+<item>DLIBFLAGPREFIX</item>
+<item>DLIBFLAGSUFFIX</item>
+<item>DLINKFLAGPREFIX</item>
+<item>DLINKFLAGSUFFIX</item>
+</sets>
+<uses>
+</uses>
+</tool>

src/engine/SCons/Tool/ldc.py

+"""SCons.Tool.ldc
+
+Tool-specific initialization for the LDC compiler.
+(http://www.dsource.org/projects/ldc)
+
+Developed by Russel Winder (russel@winder.org.uk)
+2012-05-09 onwards
+
+Compiler variables:
+    DC - The name of the D compiler to use.  Defaults to ldc2.
+    DPATH - List of paths to search for import modules.
+    DVERSIONS - List of version tags to enable when compiling.
+    DDEBUG - List of debug tags to enable when compiling.
+
+Linker related variables:
+    LIBS - List of library files to link in.
+    DLINK - Name of the linker to use.  Defaults to ldc2.
+    DLINKFLAGS - List of linker flags.
+
+Lib tool variables:
+    DLIB - Name of the lib tool to use.  Defaults to lib.
+    DLIBFLAGS - List of flags to pass to the lib tool.
+    LIBS - Same as for the linker. (libraries to pull into the .lib)
+"""
+
+#
+# __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 os
+import subprocess
+
+import SCons.Action
+import SCons.Builder
+import SCons.Defaults
+import SCons.Scanner.D
+import SCons.Tool
+
+import SCons.Tool.DCommon
+
+
+def generate(env):
+    static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+    static_obj.add_action('.d', SCons.Defaults.DAction)
+    shared_obj.add_action('.d', SCons.Defaults.ShDAction)
+    static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter)
+    shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter)
+
+    env['DC'] = env.Detect('ldc2')
+    env['DCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -of=$TARGET $SOURCES'
+    env['_DINCFLAGS'] = '$( ${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs, TARGET, SOURCE)}  $)'
+    env['_DVERFLAGS'] = '$( ${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)}  $)'
+    env['_DDEBUGFLAGS'] = '$( ${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)} $)'
+    env['_DFLAGS'] = '$( ${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)} $)'
+
+    env['SHDC'] = '$DC'
+    env['SHDCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -relocation-model=pic -of=$TARGET $SOURCES'
+
+    env['DPATH'] = ['#/']
+    env['DFLAGS'] = []
+    env['DVERSIONS'] = []
+    env['DDEBUG'] = []
+
+    env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0
+
+    if env['DC']:
+        SCons.Tool.DCommon.addDPATHToEnv(env, env['DC'])
+
+    env['DINCPREFIX'] = '-I='
+    env['DINCSUFFIX'] = ''
+    env['DVERPREFIX'] = '-version='
+    env['DVERSUFFIX'] = ''
+    env['DDEBUGPREFIX'] = '-debug='
+    env['DDEBUGSUFFIX'] = ''
+    env['DFLAGPREFIX'] = '-'
+    env['DFLAGSUFFIX'] = ''
+    env['DFILESUFFIX'] = '.d'
+
+    env['DLINK'] = '$DC'
+    env['DLINKCOM'] = '$DLINK -of=$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+    env['SHDLINKCOM'] = '$DLINK -shared -of=$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+
+    env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr'
+    env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {} $TARGET $SOURCES $_DLINKLIBFLAGS'.format('-c' if env['PLATFORM'] == 'win32' else '')
+
+    env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+    env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
+    env['DLINKFLAGS'] = ['-L-L.']
+    env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l'
+    env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else ''
+    env['DLIBFLAGPREFIX'] = '-'
+    env['DLIBFLAGSUFFIX'] = ''
+    env['DLINKFLAGPREFIX'] = '-'
+    env['DLINKFLAGSUFFIX'] = ''
+
+    SCons.Tool.createStaticLibBuilder(env)
+
+
+def exists(env):
+    return env.Detect('ldc2')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

src/engine/SCons/Tool/ldc.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+__COPYRIGHT__
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+<tool name="dmd">
+<summary>
+Sets construction variables for the D language compiler LDC2.
+</summary>
+<sets>
+<item>DC</item>
+<item>DCOM</item>
+<item>_DINCFLAGS</item>
+<item>_DVERFLAGS</item>
+<item>_DDEBUGFLAGS</item>
+<item>_DFLAGS</item>
+<item>SHDC</item>
+<item>SHDCOM</item>
+<item>DPATH</item>
+<item>DFLAGS</item>
+<item>DVERSIONS</item>
+<item>DDEBUG</item>
+<item>STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME</item>
+<item>DINCPREFIX</item>
+<item>DINCSUFFIX</item>
+<item>DVERPREFIX</item>
+<item>DVERSUFFIX</item>
+<item>DDEBUGPREFIX</item>
+<item>DDEBUGSUFFIX</item>
+<item>DFLAGPREFIX</item>
+<item>DFLAGSUFFIX</item>
+<item>DFLESUFFIX</item>
+<item>DLINK</item>
+<item>DLINKCOM</item>
+<item>SHDLINKCOM</item>
+<item>DLIB</item>
+<item>DLIBCOM</item>
+<item>_DLINKLIBFLAGS</item>
+<item>_DLIBFLAGS</item>
+<item>DLINKFLAGS</item>
+<item>DLIBLINKPREFIX</item>
+<item>DLIBLINKSUFFIX</item>
+<item>DLIBFLAGPREFIX</item>
+<item>DLIBFLAGSUFFIX</item>
+<item>DLINKFLAGPREFIX</item>
+<item>DLINKFLAGSUFFIX</item>
+</sets>
+<uses>
+</uses>
+</tool>

src/engine/SCons/Tool/link.py

 
 from SCons.Tool.FortranCommon import isfortran
 
+from SCons.Tool.DCommon import isD
+
 cplusplus = __import__('c++', globals(), locals(), [])
 
 issued_mixed_link_warning = False
 def smart_link(source, target, env, for_signature):
     has_cplusplus = cplusplus.iscplusplus(source)
     has_fortran = isfortran(env, source)
-    if has_cplusplus and has_fortran:
+    has_d = isD(env, source)
+    if has_cplusplus and has_fortran and not has_d:
         global issued_mixed_link_warning
         if not issued_mixed_link_warning:
             msg = "Using $CXX to link Fortran and C++ code together.\n\t" + \
                                 msg % env.subst('$CXX'))
             issued_mixed_link_warning = True
         return '$CXX'
+    elif has_d:
+        env['LINKCOM'] = env['DLINKCOM']
+        env['SHLINKCOM'] = env['SHDLINKCOM']
+        return '$DC'
     elif has_fortran:
         return '$FORTRAN'
     elif has_cplusplus:
                     print "shlib_emitter_names: side effect: ", name
                 # add version_name to list of names to be a Side effect
                 version_names.append(version_name)
-                
+
     except KeyError:
         version = None
     return version_names
     # don't set up the emitter, cause AppendUnique will generate a list
     # starting with None :-(
     env.Append(LDMODULEEMITTER='$SHLIBEMITTER')
-    env['LDMODULEPREFIX'] = '$SHLIBPREFIX' 
-    env['LDMODULESUFFIX'] = '$SHLIBSUFFIX' 
+    env['LDMODULEPREFIX'] = '$SHLIBPREFIX'
+    env['LDMODULESUFFIX'] = '$SHLIBSUFFIX'
     env['LDMODULEFLAGS'] = '$SHLINKFLAGS'
     env['LDMODULECOM'] = '$LDMODULE -o $TARGET $LDMODULEFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
 

test/D/CoreScanner/Common/__init__.py

Empty file added.

test/D/CoreScanner/Common/common.py

+"""
+Verify that the D scanner can return multiple modules imported by
+a single statement.
+"""
+
+#
+# __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()
+
+    _obj = TestSCons._obj
+
+    if not isExecutableOfToolAvailable(test, tool) :
+        test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool))
+
+    test.dir_fixture('Image')
+    test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool))
+
+    arguments = 'test1%(_obj)s test2%(_obj)s' % locals()
+
+    if tool == 'dmd':
+        # The gdmd executable in Debian Unstable as at 2012-05-12, version 4.6.3 puts out messages on stderr
+        # that cause inappropriate failure of the tests, so simply ignore them.
+        test.run(arguments=arguments, stderr=None)
+    else:
+        test.run(arguments=arguments)
+
+    test.up_to_date(arguments=arguments)
+
+    test.write(['module2.d'], """\
+module  module2;
+
+int something_else;
+""")
+
+    if tool == 'dmd':
+        # The gdmd executable in Debian Unstable as at 2012-05-12, version 4.6.3 puts out messages on stderr
+        # that cause inappropriate failure of the tests, so simply ignore them.
+        test.not_up_to_date(arguments=arguments, stderr=None)
+    else:
+        test.not_up_to_date(arguments=arguments)
+
+    test.up_to_date(arguments=arguments)
+
+    test.write(['p', 'submodule2.d'], """\
+module p.submodule2;
+
+int something_else;
+""")
+
+    if tool == 'dmd':
+        # The gdmd executable in Debian Unstable as at 2012-05-12, version 4.6.3 puts out messages on stderr
+        # that cause inappropriate failure of the tests, so simply ignore them.
+        test.not_up_to_date(arguments=arguments, stderr=None)
+    else:
+        test.not_up_to_date(arguments=arguments)
+
+    test.up_to_date(arguments=arguments)
+
+    test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/CoreScanner/Common/sconstest.skip

Empty file added.

test/D/CoreScanner/Image/SConstruct_template

+# -*- mode:python; coding:utf-8; -*-
+
+import os
+
+environment = Environment(
+    ENV=os.environ,
+    tools=['link', '{}'])
+environment.Program('test1.d')
+environment.Program('test2.d')

test/D/CoreScanner/Image/ignored.d

+module  ignored;
+
+int something;

test/D/CoreScanner/Image/module1.d

+module  module1;
+
+int something;

test/D/CoreScanner/Image/module2.d

+module  module2;
+
+int something;

test/D/CoreScanner/Image/module3.di

+module  module3;
+
+int something;

test/D/CoreScanner/Image/p/ignored.d

+module  p.ignored;
+
+int something;

test/D/CoreScanner/Image/p/submodule1.d

+module  p.submodule1;
+
+int something;

test/D/CoreScanner/Image/p/submodule2.d

+module p.submodule2;
+
+int something;

test/D/CoreScanner/Image/test1.d

+import module1;
+import module2;
+import module3;
+import p.submodule1;
+import p.submodule2;
+
+int main() {
+   return 0;
+}

test/D/CoreScanner/Image/test2.d

+import
+   module1,
+   module2,
+   module3;
+import
+   p.submodule1,
+   p.submodule2;
+
+int main() {
+   return 0;
+}

test/D/CoreScanner/sconstest-dmd.py

+"""
+Test compiling and executing using the dmd tool.
+"""
+
+#
+# __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:

test/D/CoreScanner/sconstest-gdc.py

+"""
+Test compiling and executing using the gdc tool.
+"""
+
+#
+# __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:

test/D/CoreScanner/sconstest-ldc.py

+"""
+Test compiling and executing using the ldc tool.
+"""
+
+#
+# __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:
+#!/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.
+#
+
+#  Amended by Russel Winder <russel@russel.org.uk> 2010-05-05
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+_exe = TestSCons._exe
+test = TestSCons.TestSCons()
+
+if not test.where_is('dmd') and not test.where_is('gdmd'):
+    test.skip_test("Could not find 'dmd' or 'gdmd', skipping test.\n")
+
+test.write('SConstruct', """\
+import os
+env = Environment(tools=['link', 'dmd'], ENV=os.environ)
+if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj'  # trick DMD
+env.Program('foo', 'foo.d')
+""")
+
+test.write('foo.d', """\
+import std.stdio;
+int main(string[] args) {
+    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:
+#!/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.
+#
+
+#  Amended by Russel Winder <russel@russel.org.uk> 2010-05-05
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+_exe = TestSCons._exe
+test = TestSCons.TestSCons()
+
+if not test.where_is('dmd') and not test.where_is('gdmd'):
+    test.skip_test("Could not find 'dmd' or 'gdmd', skipping test.\n")
+
+test.write('SConstruct', """\
+import os
+env = Environment(tools=['dmd', 'link'], ENV=os.environ)
+if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj'  # trick DMD
+env.Program('foo', 'foo.d')
+""")
+
+test.write('foo.d', """\
+import std.stdio;
+int main(string[] args) {
+    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:
+#!/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.
+#
+
+#  Amended by Russel Winder <russel@russel.org.uk> 2010-05-05
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+_exe = TestSCons._exe
+test = TestSCons.TestSCons()
+
+if not test.where_is('gdc'):
+    test.skip_test("Could not find 'gdc', skipping test.\n")
+
+test.write('SConstruct', """\
+import os
+env = Environment(tools=['link', 'gdc'], ENV=os.environ)
+if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj'  # trick DMD
+env.Program('foo', 'foo.d')
+""")
+
+test.write('foo.d', """\
+import std.stdio;
+int main(string[] args) {
+    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:
+#!/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.
+#
+
+#  Amended by Russel Winder <russel@russel.org.uk> 2010-05-05
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+_exe = TestSCons._exe
+test = TestSCons.TestSCons()
+
+if not test.where_is('gdc'):
+    test.skip_test("Could not find 'gdc', skipping test.\n")
+
+test.write('SConstruct', """\
+import os
+env = Environment(tools=['gdc', 'link'], ENV=os.environ)
+if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj'  # trick DMD
+env.Program('foo', 'foo.d')
+""")
+
+test.write('foo.d', """\
+import std.stdio;
+int main(string[] args) {
+    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:

test/D/HSTeoh/ArLibIssue/SConstruct_template

+env = Environment({})
+
+env.StaticLibrary('mylib', ['a.d', 'b.d'])

test/D/HSTeoh/ArLibIssue/a.d

Empty file added.

test/D/HSTeoh/ArLibIssue/b.d

Empty file added.

test/D/HSTeoh/Common/__init__.py

Empty file added.

test/D/HSTeoh/Common/arLibIssue.py

+"""
+These tests check a problem with the lib/ar setting.
+"""
+
+#
+# __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
+
+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 '{}' not found, skipping test.\n".format(tool))
+
+    test.dir_fixture('ArLibIssue')
+    test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{}", "ar"]'.format(tool)))
+
+    test.run()
+
+    test.must_exist(test.workpath('a.o'))
+    test.must_exist(test.workpath('b.o'))
+    test.must_exist(test.workpath('mylib.a' if Base()['PLATFORM'] == 'win32' else 'libmylib.a'))
+
+    test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/HSTeoh/Common/libCompileOptions.py

+"""
+These tests check a problem with the lib/ar setting.
+"""
+
+#
+# __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
+
+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 '{}' not found, skipping test.\n".format(tool))
+
+    test.dir_fixture('LibCompileOptions')
+    test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{}", "link", "ar"]'.format(tool)))
+
+    test.run()
+
+    test.must_exist(test.workpath('mylib.o'))
+    test.must_exist(test.workpath('mylib.a' if Base()['PLATFORM'] == 'win32' else 'libmylib.a'))
+    test.must_exist(test.workpath('prog'))
+
+    test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/HSTeoh/Common/linkingProblem.py

+"""
+These tests check an issue with the LIBS environment variable.
+"""
+
+#
+# __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 '{}' not found, skipping test.\n".format(tool))
+
+    test.dir_fixture('LinkingProblem')
+    test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool))
+
+    test.run()
+
+    test.must_exist(test.workpath('ncurs_impl.o'))
+    test.must_exist(test.workpath('cprog'))
+    test.must_exist(test.workpath('prog'))
+
+    test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/HSTeoh/Common/sconstest.skip

Empty file added.

test/D/HSTeoh/Common/singleStringCannotBeMultipleOptions.py

+"""
+These tests verify that SCons fails appropriately where the user has tried to supply multiple command line
+options via a single string rather than providing a list of strings, one string per option.
+"""
+
+#
+# __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 '{}' not found, skipping test.\n".format(tool))
+
+    test.dir_fixture('SingleStringCannotBeMultipleOptions')
+    test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool))
+
+    test.run(status=2, stdout=None, stderr=None)
+
+    result = {
+        'dmd': ".*unrecognized switch '-m64 -O'.*",
+        'gdc': ".*unrecognized command line option.*",
+        'ldc': ".*Unknown command line argument '-m64 -O'.*",
+        }[tool]
+
+    test.fail_test(not test.match_re_dotall(test.stderr(), result))
+
+    test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/HSTeoh/LibCompileOptions/SConstruct_template

+env = Environment({})
+
+env.Library('mylib', 'mylib.d')
+
+prog_env = env.Clone(
+    LIBS = ['mylib'],
+    LIBPATH = '#'
+    )
+prog_env.Program('prog', 'prog.d')

test/D/HSTeoh/LibCompileOptions/mylib.d

Empty file added.

test/D/HSTeoh/LibCompileOptions/prog.d

+int main() {
+    return 0;
+}

test/D/HSTeoh/LinkingProblem/SConstruct_template

+# -*- mode:python; coding=utf-8; -*-
+
+import os
+
+environment = Environment(
+    ENV=os.environ,
+    tools = ['cc', 'link' , '{}'],
+    LIBS = ['ncurses'])
+
+environment.Object('ncurs_impl.o', 'ncurs_impl.c')
+
+environment.Program('prog', Split("""
+	prog.d
+	ncurs_impl.o
+"""))
+
+environment.Program('cprog', Split("""
+	cprog.c
+	ncurs_impl.o
+"""))

test/D/HSTeoh/LinkingProblem/cprog.c

+extern void ncurs_init();
+extern void ncurs_cleanup();
+
+int main() {
+	ncurs_init();
+	ncurs_cleanup();
+}

test/D/HSTeoh/LinkingProblem/ncurs_impl.c

+/* Ncurses wrappers */
+#include <ncurses.h>
+
+void ncurs_init() {
+	initscr();
+	cbreak();
+	noecho();
+	keypad(stdscr, TRUE);
+}
+
+void ncurs_cleanup() {
+	endwin();
+}

test/D/HSTeoh/LinkingProblem/prog.d

+/*
+ * Simple D program that links to ncurses via a C wrapping file.
+ */
+
+extern(C) {
+	void ncurs_init();
+	void ncurs_cleanup();
+}
+
+void main() {
+	ncurs_init();
+	ncurs_cleanup();
+}

test/D/HSTeoh/README.txt

+The tests here are evolutions of test cases provided by H.S.Teoh via email.

test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template

+# -*- mode:python; coding=utf-8; -*-
+
+import os
+
+environment = Environment(
+    ENV=os.environ,
+    tools=['link', '{}'],
+    # It might be thought that a single string can contain multiple options space separated. Actually this
+    # is deemed to be a single option, so leads to an error.