diff options
Diffstat (limited to '3rdParty/SCons/scons-local/SCons/Script/Main.py')
-rw-r--r-- | 3rdParty/SCons/scons-local/SCons/Script/Main.py | 91 |
1 files changed, 60 insertions, 31 deletions
diff --git a/3rdParty/SCons/scons-local/SCons/Script/Main.py b/3rdParty/SCons/scons-local/SCons/Script/Main.py index 537bcf1..72ff71c 100644 --- a/3rdParty/SCons/scons-local/SCons/Script/Main.py +++ b/3rdParty/SCons/scons-local/SCons/Script/Main.py @@ -12,7 +12,7 @@ it goes here. """ # -# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation +# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -34,7 +34,7 @@ it goes here. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Script/Main.py 4043 2009/02/23 09:06:45 scons" +__revision__ = "src/engine/SCons/Script/Main.py 4761 2010/04/04 14:04:44 bdeegan" import os import os.path @@ -207,7 +207,12 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask): t = self.targets[0] if self.top and not t.has_builder() and not t.side_effect: if not t.exists(): - errstr="Do not know how to make target `%s'." % t + def classname(obj): + return string.split(str(obj.__class__), '.')[-1] + if classname(t) in ('File', 'Dir', 'Entry'): + errstr="Do not know how to make %s target `%s' (%s)." % (classname(t), t, t.abspath) + else: # Alias or Python or ... + errstr="Do not know how to make %s target `%s'." % (classname(t), t) sys.stderr.write("scons: *** " + errstr) if not self.options.keep_going: sys.stderr.write(" Stop.") @@ -426,7 +431,7 @@ def python_version_unsupported(version=sys.version_info): return version < (1, 5, 2) def python_version_deprecated(version=sys.version_info): - return version < (2, 2, 0) + return version < (2, 4, 0) # Global variables @@ -693,20 +698,41 @@ def _load_site_scons_dir(topdir, site_dir_name=None): site_tools_dir = os.path.join(site_dir, site_tools_dirname) if os.path.exists(site_init_file): import imp + # TODO(2.4): turn this into try:-except:-finally: try: - fp, pathname, description = imp.find_module(site_init_modname, - [site_dir]) try: - imp.load_module(site_init_modname, fp, pathname, description) - finally: - if fp: - fp.close() - except ImportError, e: - sys.stderr.write("Can't import site init file '%s': %s\n"%(site_init_file, e)) - raise - except Exception, e: - sys.stderr.write("Site init file '%s' raised exception: %s\n"%(site_init_file, e)) - raise + fp, pathname, description = imp.find_module(site_init_modname, + [site_dir]) + # Load the file into SCons.Script namespace. This is + # opaque and clever; m is the module object for the + # SCons.Script module, and the exec ... in call executes a + # file (or string containing code) in the context of the + # module's dictionary, so anything that code defines ends + # up adding to that module. This is really short, but all + # the error checking makes it longer. + try: + m = sys.modules['SCons.Script'] + except Exception, e: + fmt = 'cannot import site_init.py: missing SCons.Script module %s' + raise SCons.Errors.InternalError, fmt % repr(e) + try: + # This is the magic. + exec fp in m.__dict__ + except KeyboardInterrupt: + raise + except Exception, e: + fmt = '*** Error loading site_init file %s:\n' + sys.stderr.write(fmt % repr(site_init_file)) + raise + except KeyboardInterrupt: + raise + except ImportError, e: + fmt = '*** cannot import site init file %s:\n' + sys.stderr.write(fmt % repr(site_init_file)) + raise + finally: + if fp: + fp.close() if os.path.exists(site_tools_dir): SCons.Tool.DefaultToolpath.append(os.path.abspath(site_tools_dir)) @@ -750,6 +776,8 @@ def _main(parser): SCons.Warnings.MisleadingKeywordsWarning, SCons.Warnings.ReservedVariableWarning, SCons.Warnings.StackSizeWarning, + SCons.Warnings.VisualVersionMismatch, + SCons.Warnings.VisualCMissingWarning, ] for warning in default_warnings: @@ -778,16 +806,13 @@ def _main(parser): # want to start everything, which means first handling any relevant # options that might cause us to chdir somewhere (-C, -D, -U, -u). if options.directory: - cdir = _create_path(options.directory) - try: - os.chdir(cdir) - except OSError: - sys.stderr.write("Could not change directory to %s\n" % cdir) + script_dir = os.path.abspath(_create_path(options.directory)) + else: + script_dir = os.getcwd() target_top = None if options.climb_up: target_top = '.' # directory to prepend to targets - script_dir = os.getcwd() # location of script while script_dir and not _SConstruct_exists(script_dir, options.repository, options.file): @@ -796,9 +821,13 @@ def _main(parser): target_top = os.path.join(last_part, target_top) else: script_dir = '' - if script_dir and script_dir != os.getcwd(): - display("scons: Entering directory `%s'" % script_dir) + + if script_dir and script_dir != os.getcwd(): + display("scons: Entering directory `%s'" % script_dir) + try: os.chdir(script_dir) + except OSError: + sys.stderr.write("Could not change directory to %s\n" % script_dir) # Now that we're in the top-level SConstruct directory, go ahead # and initialize the FS object that represents the file system, @@ -868,7 +897,7 @@ def _main(parser): targets = [] xmit_args = [] for a in parser.largs: - if a[0] == '-': + if a[:1] == '-': continue if '=' in a: xmit_args.append(a) @@ -885,9 +914,9 @@ def _main(parser): # module will no longer work. This affects the behavior during # --interactive mode. --interactive should only be used when stdin and # stdout refer to a tty. - if not sys.stdout.isatty(): + if not hasattr(sys.stdout, 'isatty') or not sys.stdout.isatty(): sys.stdout = SCons.Util.Unbuffered(sys.stdout) - if not sys.stderr.isatty(): + if not hasattr(sys.stderr, 'isatty') or not sys.stderr.isatty(): sys.stderr = SCons.Util.Unbuffered(sys.stderr) memory_stats.append('before reading SConscript files:') @@ -933,7 +962,7 @@ def _main(parser): # warning about deprecated Python versions--delayed until here # in case they disabled the warning in the SConscript files. if python_version_deprecated(): - msg = "Support for pre-2.2 Python (%s) is deprecated.\n" + \ + msg = "Support for pre-2.4 Python (%s) is deprecated.\n" + \ " If this will cause hardship, contact dev@scons.tigris.org." SCons.Warnings.warn(SCons.Warnings.PythonVersionWarning, msg % python_version_string()) @@ -1075,14 +1104,14 @@ def _build_targets(fs, options, targets, target_top): else: node = None # Why would ltop be None? Unfortunately this happens. - if ltop == None: ltop = '' + if ltop is None: ltop = '' # Curdir becomes important when SCons is called with -u, -C, # or similar option that changes directory, and so the paths # of targets given on the command line need to be adjusted. curdir = os.path.join(os.getcwd(), str(ltop)) for lookup in SCons.Node.arg2nodes_lookups: node = lookup(x, curdir=curdir) - if node != None: + if node is not None: break if node is None: node = fs.Entry(x, directory=ltop, create=1) @@ -1255,7 +1284,7 @@ def main(): # __main__.__version__, hence there is no script version. pass parts.append(version_string("engine", SCons)) - parts.append("Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation") + parts.append("Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation") version = string.join(parts, '') import SConsOptions |