From: stevenknight Date: Wed, 25 Feb 2009 15:15:43 +0000 (+0000) Subject: Issue 1059: Fix the -n option when VariantDir(duplicate=1) is used X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;ds=sidebyside;h=e50caafc1c74654a4687c650319914883a96f080;p=scons.git Issue 1059: Fix the -n option when VariantDir(duplicate=1) is used and the variant directory doesn't already exist. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4052 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 161a2ef5..0defff82 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -8,6 +8,15 @@ +RELEASE X.X.X - XXX + + From Steven Knight: + + - Fix the -n option when used with VariantDir(duplicate=1) + and the variant directory doesn't already exist. + + + RELEASE 1.2.0.d20090223 - Mon, 23 Feb 2009 08:41:06 -0800 From Stanislav Baranov: diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 6569c95e..9a67e676 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -189,7 +189,11 @@ def _SConscript(fs, *files, **kw): # fs match so we can open the SConscript. fs.chdir(top, change_os_dir=1) if f.rexists(): - _file_ = open(f.rfile().get_abspath(), "r") + actual = f.rfile() + _file_ = open(actual.get_abspath(), "r") + elif f.srcnode().rexists(): + actual = f.srcnode().rfile() + _file_ = open(actual.get_abspath(), "r") elif f.has_src_builder(): # The SConscript file apparently exists in a source # code management system. Build it, but then clear @@ -233,8 +237,7 @@ def _SConscript(fs, *files, **kw): # interpret the stuff within the SConscript file # relative to where we are logically. fs.chdir(ldir, change_os_dir=0) - # TODO Not sure how to handle src_dir here - os.chdir(f.rfile().dir.get_abspath()) + os.chdir(actual.dir.get_abspath()) # Append the SConscript directory to the beginning # of sys.path so Python modules in the SConscript diff --git a/test/VariantDir/no-execute.py b/test/VariantDir/no-execute.py index 94bd5cbe..022bf7ea 100644 --- a/test/VariantDir/no-execute.py +++ b/test/VariantDir/no-execute.py @@ -27,7 +27,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Verify that use of a VariantDir works when the -n option is used (and -the VariantDir, therefore, isn't actually created). +the VariantDir, therefore, isn't actually created) when both duplicate=0 +and duplicate=1 are used. """ import os @@ -36,12 +37,24 @@ import TestSCons test = TestSCons.TestSCons() +a_file_in = os.path.join('a', 'file.in') +build0_a_file_out = os.path.join('build0', 'a', 'file.out') +build1_file_out = os.path.join('build1', 'file.out') +build1_file_in = os.path.join('build1', 'file.in') + test.subdir('a') test.write('SConstruct', """\ env = Environment() Export('env') -env.SConscript('SConscript', exported=['env'], variant_dir='build', duplicate=0) +env.SConscript('SConscript', + exported=['env'], + variant_dir='build0', + duplicate=0) +env.SConscript('a/SConscript', + exported=['env'], + variant_dir='build1', + duplicate=1) """) test.write('SConscript', """\ @@ -57,13 +70,24 @@ env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) test.write(['a', 'file.in'], "a/file.in\n") expect = """\ -scons: building associated VariantDir targets: build -Copy("%s", "%s") -""" % (os.path.join('build', 'a', 'file.out'), - os.path.join('a', 'file.in')) +scons: building associated VariantDir targets: build0 +Copy("%(build0_a_file_out)s", "%(a_file_in)s") +Copy("%(build1_file_out)s", "%(build1_file_in)s") +""" % locals() test.run(arguments = '-Q -n', stdout=expect) +test.must_not_exist('build0') +test.must_not_exist('build1') + +# Sanity check that the right thing happens when we *do* build it, just +# to make sure that the expected -n behavior above isn't a side effect +# of doing something wrong without -n. +test.run() + +test.must_match(['build0', 'a', 'file.out'], "a/file.in\n") +test.must_match(['build1', 'file.out'], "a/file.in\n") + test.pass_test() # Local Variables: