diff options
Diffstat (limited to 'engine/SCons/Defaults.py')
-rw-r--r-- | engine/SCons/Defaults.py | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/engine/SCons/Defaults.py b/engine/SCons/Defaults.py index 9e33bfa..4d36e95 100644 --- a/engine/SCons/Defaults.py +++ b/engine/SCons/Defaults.py @@ -33,7 +33,7 @@ from distutils.msvccompiler. # from __future__ import division -__revision__ = "src/engine/SCons/Defaults.py 2014/07/05 09:42:21 garyo" +__revision__ = "src/engine/SCons/Defaults.py 2014/08/24 12:12:31 garyo" import os @@ -181,20 +181,37 @@ def chmod_strfunc(dest, mode): Chmod = ActionFactory(chmod_func, chmod_strfunc) -def copy_func(dest, src): +def copy_func(dest, src, symlinks=True): + """ + If symlinks (is true), then a symbolic link will be + shallow copied and recreated as a symbolic link; otherwise, copying + a symbolic link will be equivalent to copying the symbolic link's + final target regardless of symbolic link depth. + """ + + dest = str(dest) + src = str(src) + SCons.Node.FS.invalidate_node_memos(dest) if SCons.Util.is_List(src) and os.path.isdir(dest): for file in src: shutil.copy2(file, dest) return 0 + elif os.path.islink(src): + linkto = os.readlink(src) + if symlinks: + return os.symlink(linkto, dest) + else: + return copy_func(dest, linkto, symlinks) elif os.path.isfile(src): return shutil.copy2(src, dest) else: - return shutil.copytree(src, dest, 1) + return shutil.copytree(src, dest, symlinks) -Copy = ActionFactory(copy_func, - lambda dest, src: 'Copy("%s", "%s")' % (dest, src), - convert=str) +Copy = ActionFactory( + copy_func, + lambda dest, src, symlinks=True: 'Copy("%s", "%s")' % (dest, src) +) def delete_func(dest, must_exist=0): SCons.Node.FS.invalidate_node_memos(dest) |