summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2009-02-25 15:15:43 (GMT)
committerSteven Knight <knight@baldmt.com>2009-02-25 15:15:43 (GMT)
commit3cc05563a7780fe442be945478c9db180e5b4ba8 (patch)
tree7452f9a4ffb7b8467fc4fc8bd6269c3950c32ce6
parent200c09f32daeffbecf33bc08f4a6807ab395b8bd (diff)
downloadSCons-3cc05563a7780fe442be945478c9db180e5b4ba8.zip
SCons-3cc05563a7780fe442be945478c9db180e5b4ba8.tar.gz
SCons-3cc05563a7780fe442be945478c9db180e5b4ba8.tar.bz2
Issue 1059: Fix the -n option when VariantDir(duplicate=1) is used
and the variant directory doesn't already exist.
-rw-r--r--src/CHANGES.txt9
-rw-r--r--src/engine/SCons/Script/SConscript.py9
-rw-r--r--test/VariantDir/no-execute.py36
3 files changed, 45 insertions, 9 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 161a2ef..0defff8 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 6569c95..9a67e67 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 94bd5cb..022bf7e 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: