diff options
author | William Deegan <bill@baddogconsulting.com> | 2017-05-01 15:47:12 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2017-05-01 15:47:12 (GMT) |
commit | fa879a1ea3230176d3bfa64212883dd29d6358b3 (patch) | |
tree | 2c7e8d73515441c7685b3e69c29426b77f13413e | |
parent | c03e43ea38fc2fe24fc40bbf4b45d4d19997c22d (diff) | |
parent | 334c534cb365ff206a2ddef5e09c9e8f728b9eb0 (diff) | |
download | SCons-fa879a1ea3230176d3bfa64212883dd29d6358b3.zip SCons-fa879a1ea3230176d3bfa64212883dd29d6358b3.tar.gz SCons-fa879a1ea3230176d3bfa64212883dd29d6358b3.tar.bz2 |
Merged in russel/scons (pull request #448)
Add an 'all at once' builder to the D tools.
-rw-r--r-- | src/CHANGES.txt | 1 | ||||
-rw-r--r-- | src/engine/SCons/Tool/DCommon.py | 12 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dmd.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dmd.xml | 168 | ||||
-rw-r--r-- | src/engine/SCons/Tool/gdc.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Tool/gdc.xml | 262 | ||||
-rw-r--r-- | src/engine/SCons/Tool/ldc.py | 15 | ||||
-rw-r--r-- | src/engine/SCons/Tool/ldc.xml | 166 | ||||
-rw-r--r-- | test/D/AllAtOnce/Common/__init__.py | 0 | ||||
-rw-r--r-- | test/D/AllAtOnce/Common/common.py | 79 | ||||
-rw-r--r-- | test/D/AllAtOnce/Common/sconstest.skip | 0 | ||||
-rw-r--r-- | test/D/AllAtOnce/Image/SConstruct_template | 13 | ||||
-rw-r--r-- | test/D/AllAtOnce/Image/amod.d | 5 | ||||
-rw-r--r-- | test/D/AllAtOnce/Image/bmod.d | 3 | ||||
-rw-r--r-- | test/D/AllAtOnce/Image/main.d | 8 | ||||
-rw-r--r-- | test/D/AllAtOnce/sconstest-dmd.py | 37 | ||||
-rw-r--r-- | test/D/AllAtOnce/sconstest-gdc.py | 37 | ||||
-rw-r--r-- | test/D/AllAtOnce/sconstest-ldc.py | 37 | ||||
-rw-r--r-- | test/D/Issues/2994/image/SConstruct | 2 | ||||
-rw-r--r-- | test/D/MixedDAndC/Image/SConstruct | 2 |
20 files changed, 633 insertions, 233 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 9e6151a..6894135 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -30,6 +30,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) diff --git a/src/engine/SCons/Tool/DCommon.py b/src/engine/SCons/Tool/DCommon.py index 02a5e73..c08f040 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', target[0]) + env.Clean(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 3722936..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'] = '' @@ -152,10 +153,16 @@ 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', + 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/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. <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> @@ -59,21 +55,177 @@ Sets construction variables for D language compiler DMD. <item>SHDLINKCOM</item> <item>DLIBLINKPREFIX</item> <item>DLIBLINKSUFFIX</item> -<item>_DLIBFLAGS</item> <item>DLIBDIRPREFIX</item> <item>DLIBDIRSUFFIX</item> -<item>_DLIBDIRFLAGS</item> <item>DLIB</item> <item>DLIBCOM</item> -<item>_DLIBFLAGS</item> <item>DLIBFLAGPREFIX</item> <item>DLIBFLAGSUFFIX</item> +<item>DLINKFLAGPREFIX</item> +<item>DLINKFLAGSUFFIX</item> <item>RPATHPREFIX</item> <item>RPATHSUFFIX</item> -<item>_RPATH</item> </sets> <uses> </uses> </tool> +<cvar name="DC"> +<summary> +<para> +The D compiler to use. +</para> +</summary> +</cvar> + +<cvar name="DCOM"> +<summary> +<para> + 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. +</para> +</summary> +</cvar> + +<cvar name="DDEBUG"> +<summary> +<para> + List of debug tags to enable when compiling. +</para> +</summary> +</cvar> + +<cvar name="DFLAGS"> +<summary> +<para> + General options that are passed to the D compiler. +</para> +</summary> +</cvar> + +<cvar name="DLIB"> +<summary> +<para> + Name of the lib tool to use for D codes. +</para> +</summary> +</cvar> + +<cvar name="DLIBCOM"> +<summary> +<para> + The command line to use when creating libraries. +</para> +</summary> +</cvar> + +<cvar name="DLINK"> +<summary> +<para> + Name of the linker to use for linking systems including D sources. +</para> +</summary> +</cvar> + +<cvar name="DLINKCOM"> +<summary> +<para> + The command line to use when linking systems including D sources. +</para> +</summary> +</cvar> + +<cvar name="DLINKFLAGS"> +<summary> +<para> +List of linker flags. +</para> +</summary> +</cvar> + +<cvar name="DPATH"> +<summary> +<para> + List of paths to search for import modules. +</para> +</summary> +</cvar> + +<cvar name="DVERSIONS"> +<summary> +<para> + List of version tags to enable when compiling. +</para> +</summary> +</cvar> + +<cvar name="SHDC"> +<summary> +<para> + The name of the compiler to use when compiling D source + destined to be in a shared objects. +</para> +</summary> +</cvar> + +<cvar name="SHDCOM"> +<summary> +<para> + The command line to use when compiling code to be part of shared objects. +</para> +</summary> +</cvar> + +<cvar name="SHDLINK"> +<summary> +<para> + The linker to use when creating shared objects for code bases + include D sources. +</para> +</summary> +</cvar> + +<cvar name="SHDLINKCOM"> +<summary> +<para> + The command line to use when generating shared objects. +</para> +</summary> +</cvar> + +<cvar name="SHDLINKFLAGS"> +<summary> +<para> + The list of flags to use when generating a shared object. +</para> +</summary> +</cvar> + +<builder name="ProgramAllAtOnce"> + <summary> + <para> + Builds an executable from D sources without first creating individual + objects for each file. + </para> + <para> + 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. + </para> + <example_commands> + env.ProgramAllAtOnce('executable', ['mod_a.d, mod_b.d', 'mod_c.d']) + </example_commands> + <para> + 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. + </para> + </summary> +</builder> + </sconsdoc> diff --git a/src/engine/SCons/Tool/gdc.py b/src/engine/SCons/Tool/gdc.py index 32199b3..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. @@ -128,10 +130,16 @@ 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', + 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/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. <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> @@ -57,16 +53,18 @@ Sets construction variables for the D language compiler GDC. <item>SHDLINK</item> <item>SHDLINKFLAGS</item> <item>SHDLINKCOM</item> +<item>DLIBLINKPREFIX</item> +<item>DLIBLINKSUFFIX</item> +<item>DLIBDIRPREFIX</item> +<item>DLIBDIRSUFFIX</item> <item>DLIB</item> <item>DLIBCOM</item> -<item>_DLIBFLAGS</item> <item>DLIBFLAGPREFIX</item> <item>DLIBFLAGSUFFIX</item> <item>DLINKFLAGPREFIX</item> <item>DLINKFLAGSUFFIX</item> <item>RPATHPREFIX</item> <item>RPATHSUFFIX</item> -<item>_RPATH</item> </sets> <uses> </uses> @@ -75,7 +73,7 @@ Sets construction variables for the D language compiler GDC. <cvar name="DC"> <summary> <para> -DC. +The D compiler to use. </para> </summary> </cvar> @@ -83,7 +81,9 @@ DC. <cvar name="DCOM"> <summary> <para> -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. </para> </summary> </cvar> @@ -91,39 +91,7 @@ DCOM. <cvar name="DDEBUG"> <summary> <para> -DDEBUG. -</para> -</summary> -</cvar> - -<cvar name="DDEBUGPREFIX"> -<summary> -<para> -DDEBUGPREFIX. -</para> -</summary> -</cvar> - -<cvar name="DDEBUGSUFFIX"> -<summary> -<para> -DDEBUGSUFFIX. -</para> -</summary> -</cvar> - -<cvar name="DFILESUFFIX"> -<summary> -<para> -DFILESUFFIX. -</para> -</summary> -</cvar> - -<cvar name="DFLAGPREFIX"> -<summary> -<para> -DFLAGPREFIX. + List of debug tags to enable when compiling. </para> </summary> </cvar> @@ -131,31 +99,7 @@ DFLAGPREFIX. <cvar name="DFLAGS"> <summary> <para> -DFLAGS. -</para> -</summary> -</cvar> - -<cvar name="DFLAGSUFFIX"> -<summary> -<para> -DFLAGSUFFIX. -</para> -</summary> -</cvar> - -<cvar name="DINCPREFIX"> -<summary> -<para> -DINCPREFIX. -</para> -</summary> -</cvar> - -<cvar name="DINCSUFFIX"> -<summary> -<para> -DINCSUFFIX. + General options that are passed to the D compiler. </para> </summary> </cvar> @@ -163,7 +107,7 @@ DINCSUFFIX. <cvar name="DLIB"> <summary> <para> -DLIB. + Name of the lib tool to use for D codes. </para> </summary> </cvar> @@ -171,55 +115,7 @@ DLIB. <cvar name="DLIBCOM"> <summary> <para> -DLIBCOM. -</para> -</summary> -</cvar> - -<cvar name="DLIBDIRPREFIX"> -<summary> -<para> -DLIBDIRPREFIX. -</para> -</summary> -</cvar> - -<cvar name="DLIBDIRSUFFIX"> -<summary> -<para> -DLIBDIRSUFFIX. -</para> -</summary> -</cvar> - -<cvar name="DLIBFLAGPREFIX"> -<summary> -<para> -DLIBFLAGPREFIX. -</para> -</summary> -</cvar> - -<cvar name="DLIBFLAGSUFFIX"> -<summary> -<para> -DLIBFLAGSUFFIX. -</para> -</summary> -</cvar> - -<cvar name="DLIBLINKPREFIX"> -<summary> -<para> -DLIBLINKPREFIX. -</para> -</summary> -</cvar> - -<cvar name="DLIBLINKSUFFIX"> -<summary> -<para> -DLIBLINKSUFFIX. + The command line to use when creating libraries. </para> </summary> </cvar> @@ -227,7 +123,7 @@ DLIBLINKSUFFIX. <cvar name="DLINK"> <summary> <para> -DLINK. + Name of the linker to use for linking systems including D sources. </para> </summary> </cvar> @@ -235,15 +131,7 @@ DLINK. <cvar name="DLINKCOM"> <summary> <para> -DLINKCOM. -</para> -</summary> -</cvar> - -<cvar name="DLINKFLAGPREFIX"> -<summary> -<para> -DLINKFLAGPREFIX. + The command line to use when linking systems including D sources. </para> </summary> </cvar> @@ -251,15 +139,7 @@ DLINKFLAGPREFIX. <cvar name="DLINKFLAGS"> <summary> <para> -DLINKFLAGS. -</para> -</summary> -</cvar> - -<cvar name="DLINKFLAGSUFFIX"> -<summary> -<para> -DLINKFLAGSUFFIX. +List of linker flags. </para> </summary> </cvar> @@ -267,15 +147,7 @@ DLINKFLAGSUFFIX. <cvar name="DPATH"> <summary> <para> -DPATH. -</para> -</summary> -</cvar> - -<cvar name="DVERPREFIX"> -<summary> -<para> -DVERPREFIX. + List of paths to search for import modules. </para> </summary> </cvar> @@ -283,15 +155,7 @@ DVERPREFIX. <cvar name="DVERSIONS"> <summary> <para> -DVERSIONS. -</para> -</summary> -</cvar> - -<cvar name="DVERSUFFIX"> -<summary> -<para> -DVERSUFFIX. + List of version tags to enable when compiling. </para> </summary> </cvar> @@ -299,7 +163,8 @@ DVERSUFFIX. <cvar name="SHDC"> <summary> <para> -SHDC. + The name of the compiler to use when compiling D source + destined to be in a shared objects. </para> </summary> </cvar> @@ -307,7 +172,7 @@ SHDC. <cvar name="SHDCOM"> <summary> <para> -SHDCOM. + The command line to use when compiling code to be part of shared objects. </para> </summary> </cvar> @@ -315,7 +180,8 @@ SHDCOM. <cvar name="SHDLINK"> <summary> <para> -SHDLINK. + The linker to use when creating shared objects for code bases + include D sources. </para> </summary> </cvar> @@ -323,7 +189,7 @@ SHDLINK. <cvar name="SHDLINKCOM"> <summary> <para> -SHDLINKCOM. + The command line to use when generating shared objects. </para> </summary> </cvar> @@ -331,57 +197,35 @@ SHDLINKCOM. <cvar name="SHDLINKFLAGS"> <summary> <para> -SHDLINKFLAGS. -</para> -</summary> -</cvar> - -<cvar name="_DDEBUGFLAGS"> -<summary> -<para> -_DDEBUGFLAGS. -</para> -</summary> -</cvar> - -<cvar name="_DFLAGS"> -<summary> -<para> -_DFLAGS. -</para> -</summary> -</cvar> - -<cvar name="_DINCFLAGS"> -<summary> -<para> -_DINCFLAGS. -</para> -</summary> -</cvar> - -<cvar name="_DLIBDIRFLAGS"> -<summary> -<para> -_DLIBDIRFLAGS. -</para> -</summary> -</cvar> - -<cvar name="_DLIBFLAGS"> -<summary> -<para> -_DLIBFLAGS. -</para> -</summary> -</cvar> - -<cvar name="_DVERFLAGS"> -<summary> -<para> -_DVERFLAGS. -</para> -</summary> -</cvar> + The list of flags to use when generating a shared object. +</para> +</summary> +</cvar> + +<builder name="ProgramAllAtOnce"> + <summary> + <para> + Builds an executable from D sources without first creating individual + objects for each file. + </para> + <para> + 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. + </para> + <example_commands> + env.ProgramAllAtOnce('executable', ['mod_a.d, mod_b.d', 'mod_c.d']) + </example_commands> + <para> + 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. + </para> + </summary> +</builder> </sconsdoc> diff --git a/src/engine/SCons/Tool/ldc.py b/src/engine/SCons/Tool/ldc.py index ade95db..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'] = '' @@ -144,10 +145,16 @@ 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', + emitter=SCons.Tool.DCommon.allAtOnceEmitter, + ) + def exists(env): return env.Detect('ldc2') + # Local Variables: # tab-width:4 # indent-tabs-mode:nil 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. <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> @@ -59,23 +55,177 @@ Sets construction variables for the D language compiler LDC2. <item>SHDLINKCOM</item> <item>DLIBLINKPREFIX</item> <item>DLIBLINKSUFFIX</item> -<item>_DLIBFLAGS</item> <item>DLIBDIRPREFIX</item> <item>DLIBDIRSUFFIX</item> -<item>_DLIBDIRFLAGS</item> <item>DLIB</item> <item>DLIBCOM</item> -<item>_DLIBFLAGS</item> <item>DLIBFLAGPREFIX</item> <item>DLIBFLAGSUFFIX</item> <item>DLINKFLAGPREFIX</item> <item>DLINKFLAGSUFFIX</item> <item>RPATHPREFIX</item> <item>RPATHSUFFIX</item> -<item>_RPATH</item> </sets> <uses> </uses> </tool> +<cvar name="DC"> +<summary> +<para> +The D compiler to use. +</para> +</summary> +</cvar> + +<cvar name="DCOM"> +<summary> +<para> + 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. +</para> +</summary> +</cvar> + +<cvar name="DDEBUG"> +<summary> +<para> + List of debug tags to enable when compiling. +</para> +</summary> +</cvar> + +<cvar name="DFLAGS"> +<summary> +<para> + General options that are passed to the D compiler. +</para> +</summary> +</cvar> + +<cvar name="DLIB"> +<summary> +<para> + Name of the lib tool to use for D codes. +</para> +</summary> +</cvar> + +<cvar name="DLIBCOM"> +<summary> +<para> + The command line to use when creating libraries. +</para> +</summary> +</cvar> + +<cvar name="DLINK"> +<summary> +<para> + Name of the linker to use for linking systems including D sources. +</para> +</summary> +</cvar> + +<cvar name="DLINKCOM"> +<summary> +<para> + The command line to use when linking systems including D sources. +</para> +</summary> +</cvar> + +<cvar name="DLINKFLAGS"> +<summary> +<para> +List of linker flags. +</para> +</summary> +</cvar> + +<cvar name="DPATH"> +<summary> +<para> + List of paths to search for import modules. +</para> +</summary> +</cvar> + +<cvar name="DVERSIONS"> +<summary> +<para> + List of version tags to enable when compiling. +</para> +</summary> +</cvar> + +<cvar name="SHDC"> +<summary> +<para> + The name of the compiler to use when compiling D source + destined to be in a shared objects. +</para> +</summary> +</cvar> + +<cvar name="SHDCOM"> +<summary> +<para> + The command line to use when compiling code to be part of shared objects. +</para> +</summary> +</cvar> + +<cvar name="SHDLINK"> +<summary> +<para> + The linker to use when creating shared objects for code bases + include D sources. +</para> +</summary> +</cvar> + +<cvar name="SHDLINKCOM"> +<summary> +<para> + The command line to use when generating shared objects. +</para> +</summary> +</cvar> + +<cvar name="SHDLINKFLAGS"> +<summary> +<para> + The list of flags to use when generating a shared object. +</para> +</summary> +</cvar> + +<builder name="ProgramAllAtOnce"> + <summary> + <para> + Builds an executable from D sources without first creating individual + objects for each file. + </para> + <para> + 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. + </para> + <example_commands> + env.ProgramAllAtOnce('executable', ['mod_a.d, mod_b.d', 'mod_c.d']) + </example_commands> + <para> + 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. + </para> + </summary> +</builder> + </sconsdoc> diff --git a/test/D/AllAtOnce/Common/__init__.py b/test/D/AllAtOnce/Common/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/D/AllAtOnce/Common/__init__.py diff --git a/test/D/AllAtOnce/Common/common.py b/test/D/AllAtOnce/Common/common.py new file mode 100644 index 0000000..1713028 --- /dev/null +++ b/test/D/AllAtOnce/Common/common.py @@ -0,0 +1,79 @@ +""" +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.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: +# 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 --- /dev/null +++ b/test/D/AllAtOnce/Common/sconstest.skip 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 |