diff options
Diffstat (limited to 'src/engine/SCons/Environment.py')
-rw-r--r-- | src/engine/SCons/Environment.py | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 9f78a65..ad92dfd 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -30,7 +30,7 @@ XXX __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - +import os import copy import os.path import re @@ -40,12 +40,32 @@ import SCons.Builder import SCons.Defaults from SCons.Errors import UserError from UserList import UserList - -def Command(): - pass # XXX - -def Install(): - pass # XXX +import SCons.Node.FS +import sys +import shutil + +def installFunc(env, target, source): + try: + os.unlink(target) + except OSError: + pass + + try: + SCons.Node.FS.file_link(source[0], target) + print 'Install file: "%s" as "%s"' % \ + (source[0], target) + return 0 + except IOError, e: + sys.stderr.write('Unable to install "%s" as "%s"\n%s\n' % \ + (source[0], target, str(e))) + return -1 + except OSError, e: + sys.stderr.write('Unable to install "%s" as "%s"\n%s\n' % \ + (source[0], target, str(e))) + return -1 + +InstallBuilder = SCons.Builder.Builder(name='Install', + action=installFunc) def InstallAs(): pass # XXX @@ -171,6 +191,20 @@ class Environment: bld = SCons.Builder.Builder(name="Command", action=action) return bld(self, target, source) + def Install(self, dir, source): + """Install specified files in the given directory.""" + sources = SCons.Util.scons_str2nodes(source) + dnodes = SCons.Util.scons_str2nodes(dir, + SCons.Node.FS.default_fs.Dir) + tgt = [] + for dnode in dnodes: + for src in sources: + target = SCons.Node.FS.default_fs.File(src.name, dnode) + tgt.append(InstallBuilder(self, target, src)) + if len(tgt) == 1: + tgt = tgt[0] + return tgt + def subst(self, string): """Recursively interpolates construction variables from the Environment into the specified string, returning the expanded |