Issue 1059: Fix the -n option when VariantDir(duplicate=1) is used
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 25 Feb 2009 15:15:43 +0000 (15:15 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 25 Feb 2009 15:15:43 +0000 (15:15 +0000)
and the variant directory doesn't already exist.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@4052 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Script/SConscript.py
test/VariantDir/no-execute.py

index 161a2ef5e5f38cea51d2f9b296476092fbdf2031..0defff827325716e7e61d54265d434a3af573fc0 100644 (file)
@@ -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:
index 6569c95e5075c5ad37853fcd223b8e13e1a2a62e..9a67e676e46441d175fc955d2d0ee2aacaa34ae2 100644 (file)
@@ -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
index 94bd5cbee6ca8067be92dd142e71b4e71bf8fb4a..022bf7ea510c24306b63678ae59cc31c9041a5a1 100644 (file)
@@ -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: