summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussel Winder <russel@winder.org.uk>2012-09-06 04:32:39 (GMT)
committerRussel Winder <russel@winder.org.uk>2012-09-06 04:32:39 (GMT)
commitce7d47c6f0d98d017b53387615b87d131a7861db (patch)
tree7dd8465a3509dc8471f7a747e284e714e0d060c2
parent39199ef7146837361c0a340459bf6125f3a0a8b3 (diff)
downloadSCons-ce7d47c6f0d98d017b53387615b87d131a7861db.zip
SCons-ce7d47c6f0d98d017b53387615b87d131a7861db.tar.gz
SCons-ce7d47c6f0d98d017b53387615b87d131a7861db.tar.bz2
Rearrange, refactor, rework, rewrite, fix.
-rw-r--r--src/engine/SCons/Tool/DCommon.py56
-rw-r--r--src/engine/SCons/Tool/dmd.py53
-rw-r--r--src/engine/SCons/Tool/gdc.py41
-rw-r--r--src/engine/SCons/Tool/ldc.py63
-rw-r--r--test/D/CoreScanner/Image/SConstruct_template6
-rw-r--r--test/D/CoreScanner/common.py14
-rw-r--r--test/D/HSTeoh/LinkingProblem/SConstruct_template6
-rw-r--r--test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template6
-rw-r--r--test/D/HSTeoh/linkingProblem_common.py14
-rw-r--r--test/D/HSTeoh/sconstest-linkingProblem_ldc.py2
-rw-r--r--test/D/HSTeoh/singleStringCannotBeMultipleOptions_common.py23
-rw-r--r--test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template6
-rw-r--r--test/D/HelloWorld/CompileAndLinkOneStep/common.py14
-rw-r--r--test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template6
-rw-r--r--test/D/HelloWorld/CompileThenLinkTwoSteps/common.py14
-rw-r--r--test/D/LDC.py9
-rw-r--r--test/D/MixedDAndC/Image/SConstruct12
-rw-r--r--test/D/Support/executablesSearch.py37
-rw-r--r--test/D/Support/sconstest.skip0
19 files changed, 255 insertions, 127 deletions
diff --git a/src/engine/SCons/Tool/DCommon.py b/src/engine/SCons/Tool/DCommon.py
new file mode 100644
index 0000000..b00d9fb
--- /dev/null
+++ b/src/engine/SCons/Tool/DCommon.py
@@ -0,0 +1,56 @@
+"""
+Common code for the various D tools.
+
+Coded by Russel Winder (russel@winder.org.uk)
+2012-09-06
+"""
+import os.path
+
+def isD(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])
+
+def setSmartLink(env, smart_link, smart_lib):
+ 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):
+ # TODO: 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
+
+ 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):
+ # TODO: 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
+
diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py
index bc9e0ce..1f6ec1c 100644
--- a/src/engine/SCons/Tool/dmd.py
+++ b/src/engine/SCons/Tool/dmd.py
@@ -68,24 +68,12 @@ import SCons.Defaults
import SCons.Scanner.D
import SCons.Tool
-def isD(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
+import DCommon
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')
@@ -109,14 +97,7 @@ def generate(env):
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])
+ DCommon.addDPATHToEnv(env, dc)
env['DINCPREFIX'] = '-I'
env['DINCSUFFIX'] = ''
@@ -149,35 +130,7 @@ def generate(env):
# 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):
- # TODO: 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
-
- 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):
- # TODO: 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
+ DCommon.setSmartLink(env, smart_link, smart_lib)
# It is worth noting that the final space in these strings is
# absolutely pivotal. SCons sees these as actions and not generators
diff --git a/src/engine/SCons/Tool/gdc.py b/src/engine/SCons/Tool/gdc.py
index dfba9b3..17c0f52 100644
--- a/src/engine/SCons/Tool/gdc.py
+++ b/src/engine/SCons/Tool/gdc.py
@@ -52,8 +52,12 @@ import SCons.Action
import SCons.Defaults
import SCons.Tool
-def generate(env):
+import DCommon
+
+smart_link = {}
+smart_lib = {}
+def generate(env):
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
DAction = SCons.Action.Action('$DCOM', '$DCOMSTR')
@@ -63,7 +67,8 @@ def generate(env):
static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter)
shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter)
- env['DC'] = env.Detect('gdc')
+ dc = env.Detect('gdc')
+ env['DC'] = dc
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__)} $)'
@@ -75,6 +80,9 @@ def generate(env):
env['DVERSIONS'] = []
env['DDEBUG'] = []
+ if dc:
+ DCommon.addDPATHToEnv(env, dc)
+
env['DINCPREFIX'] = '-I'
env['DINCSUFFIX'] = ''
env['DVERPREFIX'] = '-version='
@@ -85,7 +93,34 @@ def generate(env):
env['DFLAGSUFFIX'] = ''
env['DFILESUFFIX'] = '.d'
- env['LINK'] = '$DC'
+ env['DLINK'] = '$DC'
+ env['DLINKCOM'] = '$DLINK -o $TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+ env['DLIB'] = 'lib'
+ env['DLIBCOM'] = '$DLIB $_DLIBFLAGS -c $TARGET $SOURCES $_DLINKLIBFLAGS'
+
+ env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+ env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
+ env['DLINKFLAGS'] = []
+ 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)
+
+ # 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.
+ DCommon.setSmartLink(env, smart_link, smart_lib)
+
+ # 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 '
def exists(env):
return env.Detect('gdc')
diff --git a/src/engine/SCons/Tool/ldc.py b/src/engine/SCons/Tool/ldc.py
index c8f8ad2..ad1a64d 100644
--- a/src/engine/SCons/Tool/ldc.py
+++ b/src/engine/SCons/Tool/ldc.py
@@ -4,10 +4,10 @@ Tool-specific initialization for the LDC compiler.
(http://www.dsource.org/projects/ldc)
Coded by Russel Winder (russel@winder.org.uk)
-2012-05-09
+2012-05-09, 2012-09-06
Compiler variables:
- DC - The name of the D compiler to use. Defaults to ldc.
+ 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.
@@ -57,20 +57,12 @@ import SCons.Defaults
import SCons.Scanner.D
import SCons.Tool
-# Adapted from c++.py
-def isD(source):
- if not source:
- return 0
+import 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):
-
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
DAction = SCons.Action.Action('$DCOM', '$DCOMSTR')
@@ -80,7 +72,7 @@ def generate(env):
static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter)
shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter)
- dc = env.Detect('ldc')
+ dc = env.Detect('ldc2')
env['DC'] = dc
env['DCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -of=$TARGET $SOURCES'
env['_DINCFLAGS'] = '$( ${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
@@ -94,14 +86,7 @@ def generate(env):
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])
+ DCommon.addDPATHToEnv(env, dc)
env['DINCPREFIX'] = '-I='
env['DINCSUFFIX'] = ''
@@ -113,14 +98,38 @@ def generate(env):
env['DFLAGSUFFIX'] = ''
env['DFILESUFFIX'] = '.d'
- try :
- env['LIBS'].append ( [ '-lgphobos2' ] )
- except KeyError :
- env['LIBS'] = [ '-lgphobos2' , '-lpthread' , '-lrt' , '-lm' ]
+ env['DLINK'] = '$DC'
+ env['DLINKCOM'] = '$DLINK -of$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+ env['DLIB'] = 'lib'
+ env['DLIBCOM'] = '$DLIB $_DLIBFLAGS -c $TARGET $SOURCES $_DLINKLIBFLAGS'
+
+ env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+ env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
+ env['DLINKFLAGS'] = []
+ 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)
+
+ # 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.
+ DCommon.setSmartLink(env, smart_link, smart_lib)
+
+ # 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 '
def exists(env):
- return env.Detect('ldc')
+ return env.Detect('ldc2')
# Local Variables:
# tab-width:4
diff --git a/test/D/CoreScanner/Image/SConstruct_template b/test/D/CoreScanner/Image/SConstruct_template
index 23cc7af..a128c67 100644
--- a/test/D/CoreScanner/Image/SConstruct_template
+++ b/test/D/CoreScanner/Image/SConstruct_template
@@ -1,5 +1,9 @@
# -*- mode:python; coding:utf-8; -*-
-environment = Environment(tools=['link', '{}'])
+import os
+
+environment = Environment(
+ ENV=os.environ,
+ tools=['link', '{}'])
environment.Program('test1.d')
environment.Program('test2.d')
diff --git a/test/D/CoreScanner/common.py b/test/D/CoreScanner/common.py
index fbc584d..821e4df 100644
--- a/test/D/CoreScanner/common.py
+++ b/test/D/CoreScanner/common.py
@@ -30,7 +30,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import TestSCons
-from os.path import isfile
+from os.path import abspath, dirname
+
+import sys
+sys.path.insert(1, abspath(dirname(__file__) + '/../Support'))
+
+from executablesSearch import isExecutableOfToolAvailable
def testForTool(tool):
@@ -38,11 +43,8 @@ def testForTool(tool):
_obj = TestSCons._obj
- toolPath = '../../../{}.py'.format(tool)
- if isfile(toolPath):
- test.file_fixture(toolPath)
- if not test.where_is(tool) :
- test.skip_test("Could not find '{}'; skipping test.\n".format(tool))
+ 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))
diff --git a/test/D/HSTeoh/LinkingProblem/SConstruct_template b/test/D/HSTeoh/LinkingProblem/SConstruct_template
index 2acfd04..6815cdf 100644
--- a/test/D/HSTeoh/LinkingProblem/SConstruct_template
+++ b/test/D/HSTeoh/LinkingProblem/SConstruct_template
@@ -1,9 +1,11 @@
# -*- mode:python; coding=utf-8; -*-
+import os
+
environment = Environment(
+ ENV=os.environ,
tools = ['cc', 'link' , '{}'],
- LIBS = ['ncurses']
-)
+ LIBS = ['ncurses'])
environment.Object('ncurs_impl.o', 'ncurs_impl.c')
diff --git a/test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template b/test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template
index 1638c30..89c603b 100644
--- a/test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template
+++ b/test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template
@@ -1,11 +1,13 @@
# -*- 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.
- DFLAGS = '-m64 -O'
- )
+ DFLAGS = '-m64 -O')
environment.Program('proj', Split("""
proj.d
diff --git a/test/D/HSTeoh/linkingProblem_common.py b/test/D/HSTeoh/linkingProblem_common.py
index 1fcbfc0..cb012ac 100644
--- a/test/D/HSTeoh/linkingProblem_common.py
+++ b/test/D/HSTeoh/linkingProblem_common.py
@@ -29,17 +29,19 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import TestSCons
-from os.path import isfile
+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()
- toolPath = '../../{}.py'.format(tool)
- if isfile(toolPath):
- test.file_fixture(toolPath)
- if not test.where_is(tool) :
- test.skip_test("Could not find '{}'; skipping test.\n".format(tool))
+ 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))
diff --git a/test/D/HSTeoh/sconstest-linkingProblem_ldc.py b/test/D/HSTeoh/sconstest-linkingProblem_ldc.py
index f3f7af2..28ee64d 100644
--- a/test/D/HSTeoh/sconstest-linkingProblem_ldc.py
+++ b/test/D/HSTeoh/sconstest-linkingProblem_ldc.py
@@ -1,5 +1,5 @@
"""
-Test compiling and executing using the gdc tool.
+Test compiling and executing using the ldc tool.
"""
#
diff --git a/test/D/HSTeoh/singleStringCannotBeMultipleOptions_common.py b/test/D/HSTeoh/singleStringCannotBeMultipleOptions_common.py
index a4bfba0..e01e2d6 100644
--- a/test/D/HSTeoh/singleStringCannotBeMultipleOptions_common.py
+++ b/test/D/HSTeoh/singleStringCannotBeMultipleOptions_common.py
@@ -30,27 +30,30 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import TestSCons
-from os.path import isfile
+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()
- toolPath = '../../../{}.py'.format(tool)
- if isfile(toolPath):
- test.file_fixture(toolPath)
- if not test.where_is(tool) :
- test.skip_test("Could not find '{}', skipping test.\n".format(tool))
+ 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)
- if tool == 'gdc':
- result = ".*unrecognized command line option '-m64 -O'.*"
- else:
- result = ".*unrecognized switch '-m64 -O'.*"
+ 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))
diff --git a/test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template b/test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template
index 985ff0f..c688ab7 100644
--- a/test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template
+++ b/test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template
@@ -1,5 +1,9 @@
# -*- mode:python; coding:utf-8; -*-
-environment = Environment(tools=['link', '{}'])
+import os
+
+environment = Environment(
+ ENV=os.environ,
+ tools=['link', '{}'])
environment.Program('helloWorld.d')
diff --git a/test/D/HelloWorld/CompileAndLinkOneStep/common.py b/test/D/HelloWorld/CompileAndLinkOneStep/common.py
index f3ea916..9694ebb 100644
--- a/test/D/HelloWorld/CompileAndLinkOneStep/common.py
+++ b/test/D/HelloWorld/CompileAndLinkOneStep/common.py
@@ -29,17 +29,19 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import TestSCons
-from os.path import isfile
+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()
- toolPath = '../../../{}.py'.format(tool)
- if isfile(toolPath):
- test.file_fixture(toolPath)
- if not test.where_is(tool):
- test.skip_test("Could not find '{}', skipping test.\n".format(tool))
+ 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))
diff --git a/test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template b/test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template
index 057b7d6..425970a 100644
--- a/test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template
+++ b/test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template
@@ -1,6 +1,10 @@
# -*- mode:python; coding:utf-8; -*-
-environment = Environment(tools=['link', '{}'])
+import os
+
+environment = Environment(
+ ENV=os.environ,
+ tools=['link', '{}'])
objects = environment.Object('helloWorld.d')
diff --git a/test/D/HelloWorld/CompileThenLinkTwoSteps/common.py b/test/D/HelloWorld/CompileThenLinkTwoSteps/common.py
index 70262e0..9694ebb 100644
--- a/test/D/HelloWorld/CompileThenLinkTwoSteps/common.py
+++ b/test/D/HelloWorld/CompileThenLinkTwoSteps/common.py
@@ -29,17 +29,19 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import TestSCons
-from os.path import isfile
+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()
- toolPath = '../../../{}.py'.format(tool)
- if isfile(toolPath):
- test.file_fixture(toolPath)
- if not test.where_is(tool) :
- test.skip_test("Could not find '{}'; skipping test.\n".format(tool))
+ 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))
diff --git a/test/D/LDC.py b/test/D/LDC.py
index 02d5919..94acf1c 100644
--- a/test/D/LDC.py
+++ b/test/D/LDC.py
@@ -28,10 +28,17 @@ __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
+
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-if not test.where_is('ldc'):
+if not isExecutableOfToolAvailable(test, 'ldc'):
test.skip_test("Could not find 'ldc', skipping test.\n")
test.write('SConstruct', """\
diff --git a/test/D/MixedDAndC/Image/SConstruct b/test/D/MixedDAndC/Image/SConstruct
index f83a11d..47870d7 100644
--- a/test/D/MixedDAndC/Image/SConstruct
+++ b/test/D/MixedDAndC/Image/SConstruct
@@ -1,8 +1,12 @@
-env = Environment(
- DFLAGS=['-m64', '-O'],
- )
+# -*- codig:utf-8; -*-
-env.Program('proj', [
+import os
+
+environment = Environment(
+ ENV=os.environ,
+ DFLAGS=['-m64', '-O'])
+
+environment.Program('proj', [
'proj.d',
'dmod.d',
'cmod.c',
diff --git a/test/D/Support/executablesSearch.py b/test/D/Support/executablesSearch.py
new file mode 100644
index 0000000..ccb9fa5
--- /dev/null
+++ b/test/D/Support/executablesSearch.py
@@ -0,0 +1,37 @@
+"""
+Support functions for all the tests.
+"""
+
+#
+# __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__"
+
+def isExecutableOfToolAvailable(test, tool):
+ for executable in {
+ 'dmd': ['dmd', 'gdmd'],
+ 'gdc': ['gdc'],
+ 'ldc': ['ldc2', 'ldc']}[tool]:
+ if test.where_is(executable):
+ return True
+ return False
diff --git a/test/D/Support/sconstest.skip b/test/D/Support/sconstest.skip
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/D/Support/sconstest.skip