From 2cb623776807e1e401ac82e2b6b09e1db6b66b3f Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 6 Dec 2003 14:22:09 +0000 Subject: [PATCH] Preserve the ability to call BuildDir() multiple times with the same source and target dirs. (Charles Crain) git-svn-id: http://scons.tigris.org/svn/scons/trunk@857 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 +++ src/engine/SCons/Node/FS.py | 2 ++ src/engine/SCons/Node/FSTests.py | 15 +++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b95cfc03..9baeba33 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -46,6 +46,9 @@ RELEASE 0.95 - XXX - Make sure side-effect nodes are prepare()d before building their corresponding target. + - Preserve the ability to call BuildDir() multiple times with the + same target and source directory arguments. + From Scott Lystig Fritchie: - Fix the ability to use a custom _concat() function in the diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 9a4fb976..45809f90 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -793,6 +793,8 @@ class FS: if src_dir.is_under(build_dir): raise SCons.Errors.UserError, "Source directory cannot be under build directory." if build_dir.srcdir: + if build_dir.srcdir == src_dir: + return # We already did this. raise SCons.Errors.UserError, "'%s' already has a source directory: '%s'."%(build_dir, build_dir.srcdir) build_dir.link(src_dir, duplicate) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index cbda7583..fcd605b4 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -384,6 +384,21 @@ class BuildDirTestCase(unittest.TestCase): test.unlink( "src/foo" ) test.unlink( "build/foo" ) + fs = SCons.Node.FS.FS() + fs.BuildDir('build', 'src1') + + # Calling the same BuildDir twice should work fine. + fs.BuildDir('build', 'src1') + + # Trying to move a build dir to a second source dir + # should blow up + try: + fs.BuildDir('build', 'src2') + except SCons.Errors.UserError: + pass + else: + assert 0, "Should have caught a UserError." + # Test against a former bug. Make sure we can get a repository # path for the build directory itself! fs=SCons.Node.FS.FS(test.workpath('work')) -- 2.26.2