diff --git a/SCons/Tool/DCommon.py b/SCons/Tool/DCommon.py index 35f8f3d6e9..f8bdffa93f 100644 --- a/SCons/Tool/DCommon.py +++ b/SCons/Tool/DCommon.py @@ -65,7 +65,7 @@ def DObjectEmitter(target,source,env): di_file_suffix = env.subst('$DI_FILE_SUFFIX', target=target, source=source) file_base = Path(target[0].get_path()).stem # print(f'DObjectEmitter: {di_file_dir}/*{file_base}*{di_file_suffix}') - target.append(env.fs.File(f"{file_base}{di_file_suffix}", di_file_dir)) + target.append(env.fs.File(Path(di_file_dir,f"{file_base}{di_file_suffix}"))) # print("New Target:%s"%" ".join([str(t) for t in target])) return (target,source) diff --git a/SCons/Tool/dmd.py b/SCons/Tool/dmd.py index c3ac0ca6f0..d88fa3e265 100644 --- a/SCons/Tool/dmd.py +++ b/SCons/Tool/dmd.py @@ -96,7 +96,7 @@ def generate(env) -> None: env['_DVERFLAGS'] = '${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)}' env['_DDEBUGFLAGS'] = '${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)}' - env['_DI_FLAGS'] = "${DI_FILE_DIR and DI_FILE_DIR_PREFIX+DI_FILE_DIR+DI_FILE_DIR_SUFFFIX}" + env['_DI_FLAGS'] = "${DI_FILE_DIR and DI_FILE_DIR_PREFIX+VARIANT_DIR+DI_FILE_DIR+DI_FILE_DIR_SUFFFIX}" env['_DFLAGS'] = '${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)}' @@ -121,9 +121,9 @@ def generate(env) -> None: env['DFLAGSUFFIX'] = '' env['DFILESUFFIX'] = '.d' + env['VARIANT_DIR'] = '' env['DI_FILE_DIR'] = '' env['DI_FILE_SUFFIX'] = '.di' - env['DI_FILE_DIR_PREFIX'] = '-Hd=' env['DI_FILE_DIR_SUFFFIX'] = '' diff --git a/SCons/Tool/gdc.py b/SCons/Tool/gdc.py index 9f29d72e29..44da26b527 100644 --- a/SCons/Tool/gdc.py +++ b/SCons/Tool/gdc.py @@ -67,7 +67,7 @@ def generate(env) -> None: 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['_DI_FLAGS'] = "${DI_FILE_DIR and DI_FILE_DIR_PREFIX+DI_FILE_DIR+DI_FILE_DIR_SUFFFIX}" + env['_DI_FLAGS'] = "${DI_FILE_DIR and DI_FILE_DIR_PREFIX+VARIANT_DIR+DI_FILE_DIR+DI_FILE_DIR_SUFFFIX}" env['_DFLAGS'] = '${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)}' env['SHDC'] = '$DC' @@ -91,6 +91,7 @@ def generate(env) -> None: env['DFLAGSUFFIX'] = '' env['DFILESUFFIX'] = '.d' + env['VARIANT_DIR'] = '' env['DI_FILE_DIR'] = '' env['DI_FILE_SUFFIX'] = '.di' env['DI_FILE_DIR_PREFIX'] = '-Hd' diff --git a/SCons/Tool/ldc.py b/SCons/Tool/ldc.py index 5fb60705a2..4d31745dd0 100644 --- a/SCons/Tool/ldc.py +++ b/SCons/Tool/ldc.py @@ -72,7 +72,7 @@ def generate(env) -> None: env['_DVERFLAGS'] = '${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)}' env['_DDEBUGFLAGS'] = '${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)}' - env['_DI_FLAGS'] = "${DI_FILE_DIR and DI_FILE_DIR_PREFIX+DI_FILE_DIR+DI_FILE_DIR_SUFFFIX}" + env['_DI_FLAGS'] = "${DI_FILE_DIR and DI_FILE_DIR_PREFIX+VARIANT_DIR+DI_FILE_DIR+DI_FILE_DIR_SUFFFIX}" env['_DFLAGS'] = '${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)}' @@ -97,9 +97,9 @@ def generate(env) -> None: env['DFLAGSUFFIX'] = '' env['DFILESUFFIX'] = '.d' + env['VARIANT_DIR'] = '' env['DI_FILE_DIR'] = '' env['DI_FILE_SUFFIX'] = '.di' - env['DI_FILE_DIR_PREFIX'] = '-Hd=' env['DI_FILE_DIR_SUFFFIX'] = '' diff --git a/test/D/di/Common/common.py b/test/D/di/Common/common.py index 6ca40f91c9..866ace75e9 100644 --- a/test/D/di/Common/common.py +++ b/test/D/di/Common/common.py @@ -43,38 +43,47 @@ def testForTool(tool): if not isExecutableOfToolAvailable(test, tool) : test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) - test.dir_fixture('Image') - with open('SConstruct_template', 'r') as f: - config = f.read().format(tool) - test.write('SConstruct', config) - - test.run(options="--debug=explain") - - test.must_exist('source/helloWorld.o') - test.must_exist('helloWorldMain.o') - test.must_exist('include/helloWorld.di') - test.must_exist('hw') - - test.run(program=test.workpath('hw'+TestSCons._exe)) - test.fail_test(test.stdout() != 'Hello World.\n') - - #add a comment and test that this doesn't result in a complete rebuild of all the files that include helloWorld.d because the comment doesn't change helloWorld.di - test.write("source/helloWorld.d",'''import std.stdio; + for img in ["VariantDirImage","Image"]: + + if img == "VariantDirImage": + buildPrefix = "build/" + sourcePrefix = "hws/" + else: + sourcePrefix = "" + buildPrefix = "" + test.dir_fixture(img) + with open('SConstruct_template', 'r') as f: + config = f.read().format(tool) + test.write('SConstruct', config) + + test.run(options="--debug=explain") + + test.must_exist(buildPrefix + 'parts/part.o') + test.must_exist(buildPrefix + 'main.o') + test.must_exist(buildPrefix + 'include/part.di') + test.must_exist(buildPrefix + 'hw') + + test.run(program=test.workpath(buildPrefix + 'hw'+TestSCons._exe)) + test.fail_test(test.stdout() != 'Hello World.\n') + + #add a comment and test that this doesn't result in a complete rebuild of all the files that include helloWorld.d because the comment doesn't change helloWorld.di + test.write(sourcePrefix + "parts/part.d",'''import std.stdio; void go() { - //comment - writeln("Hello World."); + //comment + writeln("Hello World."); }''') - test.not_up_to_date("source/helloWorld.o") - test.up_to_date("helloWorldMain.o hw") + test.not_up_to_date(buildPrefix + "parts/part.o") + test.up_to_date(buildPrefix + "main.o",options='--debug=explain') + test.up_to_date(buildPrefix + "hw") - test.run("-c") - - test.must_not_exist('source/helloWorld.o') - test.must_not_exist('helloWorldMain.o') - test.must_not_exist('include/helloWorld.di') - test.must_not_exist('hw') + test.run("-c") + + test.must_not_exist(buildPrefix + 'parts/part.o') + test.must_not_exist(buildPrefix + 'main.o') + test.must_not_exist(buildPrefix + 'include/part.di') + test.must_not_exist(buildPrefix + 'hw') test.pass_test() # Local Variables: diff --git a/test/D/di/Image/SConstruct_template b/test/D/di/Image/SConstruct_template index d73432904f..1153d30b82 100644 --- a/test/D/di/Image/SConstruct_template +++ b/test/D/di/Image/SConstruct_template @@ -10,10 +10,4 @@ env = Environment( DI_FILE_DIR='include' ) - -# o1 = env.Object('source/helloWorld.d') -# o2 = env.Object('helloWorldMain.d') -# env.Program('hw', [o1[0], o2[0]]) - -# Alternatively -env.Program('hw', ['helloWorldMain.d','source/helloWorld.d']) +env.Program('hw', ['main.d','parts/part.d']) diff --git a/test/D/di/Image/helloWorldMain.d b/test/D/di/Image/main.d similarity index 55% rename from test/D/di/Image/helloWorldMain.d rename to test/D/di/Image/main.d index 419205d9b0..b9804752d9 100644 --- a/test/D/di/Image/helloWorldMain.d +++ b/test/D/di/Image/main.d @@ -1,4 +1,4 @@ -import helloWorld; +import part; void main() { diff --git a/test/D/di/Image/source/helloWorld.d b/test/D/di/Image/parts/part.d similarity index 100% rename from test/D/di/Image/source/helloWorld.d rename to test/D/di/Image/parts/part.d diff --git a/test/D/di/VariantDirImage/SConstruct_template b/test/D/di/VariantDirImage/SConstruct_template new file mode 100644 index 0000000000..05b753e107 --- /dev/null +++ b/test/D/di/VariantDirImage/SConstruct_template @@ -0,0 +1,13 @@ +# -*- mode:python; coding:utf-8; -*- + +import os + +DefaultEnvironment(tools=[]) + +env = Environment( + tools=['link','ar' ,'{}'], + VARIANT_DIR='build/' +) + +SConscript('hws/SConscript',exports=['env'],variant_dir="build",duplicate=False) + diff --git a/test/D/di/VariantDirImage/hws/SConscript b/test/D/di/VariantDirImage/hws/SConscript new file mode 100644 index 0000000000..a3401fb5b2 --- /dev/null +++ b/test/D/di/VariantDirImage/hws/SConscript @@ -0,0 +1,5 @@ +Import('env') + + +o = env.Object('parts/part.d',DI_FILE_DIR='include')[0] +env.Program('hw', ['main.d',o],DPATH='include') diff --git a/test/D/di/VariantDirImage/hws/main.d b/test/D/di/VariantDirImage/hws/main.d new file mode 100644 index 0000000000..b9804752d9 --- /dev/null +++ b/test/D/di/VariantDirImage/hws/main.d @@ -0,0 +1,6 @@ +import part; + +void main() +{ + go(); +} diff --git a/test/D/di/VariantDirImage/hws/parts/part.d b/test/D/di/VariantDirImage/hws/parts/part.d new file mode 100644 index 0000000000..9912ec0fd8 --- /dev/null +++ b/test/D/di/VariantDirImage/hws/parts/part.d @@ -0,0 +1,5 @@ +import std.stdio; +void go() +{ + writeln("Hello World."); +}