diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2014-07-20 19:49:33 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2014-07-20 19:49:33 (GMT) |
commit | 53e30bebc2a633fc95589b9dfe663483775138a5 (patch) | |
tree | 3f718990ef6cce8fbe87d0c200e61d5818530f0c /src | |
parent | a3b104e286e7d7bb3ab73e2943fe4faa5f0d43b7 (diff) | |
parent | f7384a54a0d60838d10130f70790b4a16584c746 (diff) | |
download | SCons-53e30bebc2a633fc95589b9dfe663483775138a5.zip SCons-53e30bebc2a633fc95589b9dfe663483775138a5.tar.gz SCons-53e30bebc2a633fc95589b9dfe663483775138a5.tar.bz2 |
Merged in williamblevins/scons (pull request #156, symlink copying)
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 1 | ||||
-rw-r--r-- | src/engine/SCons/Defaults.py | 27 |
2 files changed, 23 insertions, 5 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 8ff593d..1081d6f 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -8,6 +8,7 @@ RELEASE 2.3.2.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE From William Blevins: - Added test for Java derived-source dependency tree generation. + - Added Copy Action symlink soft-copy support (#2395). RELEASE 2.3.2 diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 563e5a8..3f60bc0 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -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) |