summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Defaults.py
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2014-08-23 20:28:44 (GMT)
committerGary Oberbrunner <garyo@oberbrunner.com>2014-08-23 20:28:44 (GMT)
commita7d764ed831fa3243aa0bd3307f641e1e1f9f8a8 (patch)
tree0193d9406107790a66098254869e4b070aa6cacc /src/engine/SCons/Defaults.py
parenta6ea2d760464092ea91a0dd01ba6260288aa3587 (diff)
parent6db60dbe1c3dc28f24bfca48135bcb4bc9bd66d6 (diff)
downloadSCons-a7d764ed831fa3243aa0bd3307f641e1e1f9f8a8.zip
SCons-a7d764ed831fa3243aa0bd3307f641e1e1f9f8a8.tar.gz
SCons-a7d764ed831fa3243aa0bd3307f641e1e1f9f8a8.tar.bz2
Merged default branch into python3-port to keep it up to date.
Hand-updated a few things to keep them python3-safe, and handled several merge conflicts.
Diffstat (limited to 'src/engine/SCons/Defaults.py')
-rw-r--r--src/engine/SCons/Defaults.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index 92f2344..2eb9c86 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -144,6 +144,9 @@ ShCAction = SCons.Action.Action("$SHCCCOM", "$SHCCCOMSTR")
CXXAction = SCons.Action.Action("$CXXCOM", "$CXXCOMSTR")
ShCXXAction = SCons.Action.Action("$SHCXXCOM", "$SHCXXCOMSTR")
+DAction = SCons.Action.Action("$DCOM", "$DCOMSTR")
+ShDAction = SCons.Action.Action("$SHDCOM", "$SHDCOMSTR")
+
ASAction = SCons.Action.Action("$ASCOM", "$ASCOMSTR")
ASPPAction = SCons.Action.Action("$ASPPCOM", "$ASPPCOMSTR")
@@ -178,20 +181,38 @@ 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):
shutil.copy2(src, dest)
+ return 0
else:
- shutil.copytree(src, dest, 1)
- return 0
+ 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)
@@ -321,7 +342,7 @@ def _stripixes(prefix, itms, suffix, stripprefixes, stripsuffixes, env, c=None):
where it finds them. This is used by tools (like the GNU linker)
that need to turn something like 'libfoo.a' into '-lfoo'.
"""
-
+
if not itms:
return itms
@@ -335,7 +356,7 @@ def _stripixes(prefix, itms, suffix, stripprefixes, stripsuffixes, env, c=None):
c = env_c
else:
c = _concat_ixes
-
+
stripprefixes = list(map(env.subst, SCons.Util.flatten(stripprefixes)))
stripsuffixes = list(map(env.subst, SCons.Util.flatten(stripsuffixes)))
@@ -413,7 +434,7 @@ def _defines(prefix, defs, suffix, env, c=_concat_ixes):
"""
return c(prefix, env.subst_path(processDefines(defs)), suffix, env)
-
+
class NullCmdGenerator(object):
"""This is a callable class that can be used in place of other
command generators if you don't want them to do anything.
@@ -449,7 +470,7 @@ class Variable_Method_Caller(object):
self.method = method
def __call__(self, *args, **kw):
try: 1//0
- except ZeroDivisionError:
+ except ZeroDivisionError:
# Don't start iterating with the current stack-frame to
# prevent creating reference cycles (f_back is safe).
frame = sys.exc_info()[2].tb_frame.f_back