summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Script
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Script')
-rw-r--r--src/engine/SCons/Script/Main.py46
-rw-r--r--src/engine/SCons/Script/SConscript.py40
2 files changed, 64 insertions, 22 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 73f96e2..2c18112 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -588,29 +588,29 @@ def _create_path(plist):
path = path + '/' + d
return path
+def version_string(label, module):
+ fmt = "\t%s: v%s.%s, %s, by %s on %s\n"
+ return fmt % (label,
+ module.__version__,
+ module.__build__,
+ module.__date__,
+ module.__developer__,
+ module.__buildsys__)
class OptParser(OptionParser):
def __init__(self):
import __main__
- import SCons
+
parts = ["SCons by Steven Knight et al.:\n"]
try:
- parts.append("\tscript: v%s.%s, %s, by %s on %s\n" % (__main__.__version__,
- __main__.__build__,
- __main__.__date__,
- __main__.__developer__,
- __main__.__buildsys__))
+ parts.append(version_string("script", __main__))
except KeyboardInterrupt:
raise
except:
# On Windows there is no scons.py, so there is no
# __main__.__version__, hence there is no script version.
pass
- parts.append("\tengine: v%s.%s, %s, by %s on %s\n" % (SCons.__version__,
- SCons.__build__,
- SCons.__date__,
- SCons.__developer__,
- SCons.__buildsys__))
+ parts.append(version_string("engine", SCons))
parts.append("__COPYRIGHT__")
OptionParser.__init__(self, version=string.join(parts, ''),
usage="usage: scons [OPTION] [TARGET] ...")
@@ -630,6 +630,10 @@ class OptParser(OptionParser):
metavar="DIR",
help="Change to DIR before doing anything.")
+ self.add_option('--cache-debug', action="store",
+ dest="cache_debug", metavar="FILE",
+ help="Print CacheDir debug info to FILE.")
+
self.add_option('--cache-disable', '--no-cache',
action="store_true", dest='cache_disable', default=0,
help="Do not retrieve built targets from CacheDir.")
@@ -1048,6 +1052,9 @@ def _main(args, parser):
display.set_mode(0)
if options.silent:
SCons.Action.print_actions = None
+
+ if options.cache_debug:
+ fs.CacheDebugEnable(options.cache_debug)
if options.cache_disable:
def disable(self): pass
fs.CacheDir = disable
@@ -1291,8 +1298,21 @@ def _exec_main():
import pdb
pdb.Pdb().runcall(_main, args, parser)
elif options.profile_file:
- import profile
- prof = profile.Profile()
+ from profile import Profile
+
+ # Some versions of Python 2.4 shipped a profiler that had the
+ # wrong 'c_exception' entry in its dispatch table. Make sure
+ # we have the right one. (This may put an unnecessary entry
+ # in the table in earlier versions of Python, but its presence
+ # shouldn't hurt anything).
+ try:
+ dispatch = Profile.dispatch
+ except AttributeError:
+ pass
+ else:
+ dispatch['c_exception'] = Profile.trace_dispatch_return
+
+ prof = Profile()
try:
prof.runcall(_main, args, parser)
except SystemExit:
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index f932d30..dc896a0 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -176,7 +176,7 @@ def _SConscript(fs, *files, **kw):
# fs match so we can open the SConscript.
fs.chdir(top, change_os_dir=1)
if f.rexists():
- _file_ = open(f.rstr(), "r")
+ _file_ = open(f.rfile().get_abspath(), "r")
elif f.has_src_builder():
# The SConscript file apparently exists in a source
# code management system. Build it, but then clear
@@ -185,7 +185,7 @@ def _SConscript(fs, *files, **kw):
f.build()
f.builder_set(None)
if f.exists():
- _file_ = open(str(f), "r")
+ _file_ = open(f.get_abspath(), "r")
if _file_:
# Chdir to the SConscript directory. Use a path
# name relative to the SConstruct file so that if
@@ -197,7 +197,18 @@ def _SConscript(fs, *files, **kw):
# where the SConstruct and SConscript files might be
# in different Repositories. For now, cross that
# bridge when someone comes to it.
- ldir = fs.Dir(f.dir.get_path(sd))
+ try:
+ src_dir = kw['src_dir']
+ except KeyError:
+ ldir = fs.Dir(f.dir.get_path(sd))
+ else:
+ ldir = fs.Dir(src_dir)
+ if not ldir.is_under(f.dir):
+ # They specified a source directory, but
+ # it's above the SConscript directory.
+ # Do the sensible thing and just use the
+ # SConcript directory.
+ ldir = fs.Dir(f.dir.get_path(sd))
try:
fs.chdir(ldir, change_os_dir=sconscript_chdir)
except OSError:
@@ -208,6 +219,7 @@ def _SConscript(fs, *files, **kw):
# interpret the stuff within the SConscript file
# relative to where we are logically.
fs.chdir(ldir, change_os_dir=0)
+ # TODO Not sure how to handle src_dir here
os.chdir(f.rfile().dir.get_abspath())
# Append the SConscript directory to the beginning
@@ -223,7 +235,16 @@ def _SConscript(fs, *files, **kw):
# SConscript can base the printed frames at this
# level and not show SCons internals as well.
call_stack[-1].globals.update({stack_bottom:1})
- exec _file_ in call_stack[-1].globals
+ old_file = call_stack[-1].globals.get('__file__')
+ try:
+ del call_stack[-1].globals['__file__']
+ except KeyError:
+ pass
+ try:
+ exec _file_ in call_stack[-1].globals
+ finally:
+ if old_file is not None:
+ call_stack[-1].globals.update({__file__:old_file})
else:
SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning,
"Ignoring missing SConscript '%s'" % f.path)
@@ -374,6 +395,7 @@ class SConsEnvironment(SCons.Environment.Base):
src_dir = kw.get('src_dir')
if not src_dir:
src_dir, fname = os.path.split(str(files[0]))
+ files = [os.path.join(str(build_dir), fname)]
else:
if not isinstance(src_dir, SCons.Node.Node):
src_dir = self.fs.Dir(src_dir)
@@ -383,11 +405,11 @@ class SConsEnvironment(SCons.Environment.Base):
if fn.is_under(src_dir):
# Get path relative to the source directory.
fname = fn.get_path(src_dir)
+ files = [os.path.join(str(build_dir), fname)]
else:
- # Fast way to only get the terminal path component of a Node.
- fname = fn.get_path(fn.dir)
+ files = [fn.abspath]
+ kw['src_dir'] = build_dir
self.fs.BuildDir(build_dir, src_dir, duplicate)
- files = [os.path.join(str(build_dir), fname)]
return (files, exports)
@@ -490,8 +512,8 @@ class SConsEnvironment(SCons.Environment.Base):
subst_kw[key] = val
files, exports = self._get_SConscript_filenames(ls, subst_kw)
-
- return apply(_SConscript, [self.fs,] + files, {'exports' : exports})
+ subst_kw['exports'] = exports
+ return apply(_SConscript, [self.fs,] + files, subst_kw)
def SConscriptChdir(self, flag):
global sconscript_chdir