summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Defaults.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Defaults.py')
-rw-r--r--src/engine/SCons/Defaults.py39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index cb628b8..7513c0d 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -173,14 +173,34 @@ Touch = ActionFactory(touch_func,
lambda file: 'Touch("%s")' % file)
# Internal utility functions
-def copyFunc(dest, source, env):
- """Install a source file into a destination by copying it (and its
- permission/mode bits)."""
- shutil.copy2(source, dest)
- st = os.stat(source)
- os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
+def installFunc(dest, source, env):
+ """Install a source file or directory into a destination by copying,
+ (including copying permission/mode bits)."""
+
+ if os.path.isdir(source):
+ if os.path.exists(dest):
+ if not os.path.isdir(dest):
+ raise SCons.Errors.UserError, "cannot overwrite non-directory `%s' with a directory `%s'" % (str(dest), str(source))
+ else:
+ parent = os.path.split(dest)[0]
+ if not os.path.exists(parent):
+ os.makedirs(parent)
+ shutil.copytree(source, dest)
+ else:
+ shutil.copy2(source, dest)
+ st = os.stat(source)
+ os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
+
return 0
+def installStr(dest, source, env):
+ source = str(source)
+ if os.path.isdir(source):
+ type = 'directory'
+ else:
+ type = 'file'
+ return 'Install %s: "%s" as "%s"' % (type, source, dest)
+
def _concat(prefix, list, suffix, env, f=lambda x: x, target=None, source=None):
"""Creates a new list from 'list' by first interpolating each
element in the list using the 'env' dictionary and then calling f
@@ -334,13 +354,14 @@ ConstructionEnvironment = {
'SCANNERS' : [],
'CONFIGUREDIR' : '#/.sconf_temp',
'CONFIGURELOG' : '#/config.log',
- 'INSTALLSTR' : 'Install file: "$SOURCE" as "$TARGET"',
'CPPSUFFIXES' : SCons.Tool.CSuffixes,
'DSUFFIXES' : SCons.Tool.DSuffixes,
+ 'ENV' : {},
'IDLSUFFIXES' : SCons.Tool.IDLSuffixes,
+ 'INSTALL' : installFunc,
+ 'INSTALLSTR' : installStr,
+ '_installStr' : installStr,
'LATEXSUFFIXES' : SCons.Tool.LaTeXSuffixes,
- 'ENV' : {},
- 'INSTALL' : copyFunc,
'_concat' : _concat,
'_defines' : _defines,
'_stripixes' : _stripixes,