Commits

Russel Winder committed e0c43e9

Add a first cut at GDC support.

Comments (0)

Files changed (2)

src/engine/SCons/Tool/gdc.py

+"""SCons.Tool.gdc
+
+Tool-specific initialization for the GDC compiler.
+(https://github.com/D-Programming-GDC/GDC)
+
+Coded by Russel Winder (russel@winder.org.uk)
+2012-05-09
+
+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 gcc.
+    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
+
+def generate(env):
+
+    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_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['DPATH'] = ['#/']
+    env['DFLAGS'] = []
+    env['DVERSIONS'] = []
+    env['DDEBUG'] = []
+
+    env['DINCPREFIX'] = '-I'
+    env['DINCSUFFIX'] = ''
+    env['DVERPREFIX'] = '-version='
+    env['DVERSUFFIX'] = ''
+    env['DDEBUGPREFIX'] = '-debug='
+    env['DDEBUGSUFFIX'] = ''
+    env['DFLAGPREFIX'] = '-'
+    env['DFLAGSUFFIX'] = ''
+    env['DFILESUFFIX'] = '.d'
+
+    env['LINK'] = '$DC'
+
+def exists(env):
+    return env.Detect('gdc')
+
+# 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:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.