summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-08-30 23:57:47 (GMT)
committerSteven Knight <knight@baldmt.com>2004-08-30 23:57:47 (GMT)
commitf09896916e7eb4fbd1d334d22e99e6b8d8a64696 (patch)
tree54428428d22e29966e91633ad19790f8ab6fb391 /src
parent96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db (diff)
downloadSCons-f09896916e7eb4fbd1d334d22e99e6b8d8a64696.zip
SCons-f09896916e7eb4fbd1d334d22e99e6b8d8a64696.tar.gz
SCons-f09896916e7eb4fbd1d334d22e99e6b8d8a64696.tar.bz2
Allow Help() to be called multiple times, appending to the text each time. (Chad Austin)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt5
-rw-r--r--src/engine/SCons/Script/SConscript.py10
-rw-r--r--src/engine/SCons/Script/__init__.py56
3 files changed, 36 insertions, 35 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index f3b5778..47514ea 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -10,6 +10,11 @@
RELEASE 0.97 - XXX
+ From Chad Austin:
+
+ - Allow Help() to be called multiple times, appending to the help
+ text each call.
+
From Gary Oberbrunner:
- Add an Environment.Dump() method to print the contents of a
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 3146a9c..c9a6108 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -57,8 +57,14 @@ import UserList
launch_dir = os.path.abspath(os.curdir)
-def do_nothing(text): pass
-HelpFunction = do_nothing
+help_text = None
+
+def HelpFunction(text):
+ global help_text
+ if help_text is None:
+ help_text = text
+ else:
+ help_text = help_text + text
Arguments = {}
ArgList = []
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 51d3e66..2325d35 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -260,10 +260,6 @@ profiling = 0
repositories = []
num_jobs = 1 # this is modifed by SConscript.SetJobs()
-# Exceptions for this module
-class PrintHelp(Exception):
- pass
-
# utility functions
def get_all_children(node): return node.all_children(None)
@@ -784,11 +780,6 @@ def _main(args, parser):
global ssoptions
ssoptions = SConscriptSettableOptions(options)
- if options.help_msg:
- def raisePrintHelp(text):
- raise PrintHelp, text
- SCons.Script.SConscript.HelpFunction = raisePrintHelp
-
_set_globals(options)
SCons.Node.implicit_cache = options.implicit_cache
SCons.Node.implicit_deps_changed = options.implicit_deps_changed
@@ -896,28 +887,23 @@ def _main(args, parser):
if not memory_stats is None: memory_stats.append(SCons.Debug.memory())
progress_display("scons: Reading SConscript files ...")
+
+ start_time = time.time()
try:
- start_time = time.time()
- try:
- for script in scripts:
- SCons.Script.SConscript._SConscript(fs, script)
- except SCons.Errors.StopError, e:
- # We had problems reading an SConscript file, such as it
- # couldn't be copied in to the BuildDir. Since we're just
- # reading SConscript files and haven't started building
- # things yet, stop regardless of whether they used -i or -k
- # or anything else, but don't say "Stop." on the message.
- global exit_status
- sys.stderr.write("scons: *** %s\n" % e)
- exit_status = 2
- sys.exit(exit_status)
- global sconscript_time
- sconscript_time = time.time() - start_time
- except PrintHelp, text:
- progress_display("scons: done reading SConscript files.")
- print text
- print "Use scons -H for help about command-line options."
- sys.exit(0)
+ for script in scripts:
+ SCons.Script.SConscript._SConscript(fs, script)
+ except SCons.Errors.StopError, e:
+ # We had problems reading an SConscript file, such as it
+ # couldn't be copied in to the BuildDir. Since we're just
+ # reading SConscript files and haven't started building
+ # things yet, stop regardless of whether they used -i or -k
+ # or anything else, but don't say "Stop." on the message.
+ global exit_status
+ sys.stderr.write("scons: *** %s\n" % e)
+ exit_status = 2
+ sys.exit(exit_status)
+ global sconscript_time
+ sconscript_time = time.time() - start_time
progress_display("scons: done reading SConscript files.")
# Tell the Node.FS subsystem that we're all done reading the
@@ -931,9 +917,13 @@ def _main(args, parser):
fs.chdir(fs.Top)
if options.help_msg:
- # They specified -h, but there was no Help() inside the
- # SConscript files. Give them the options usage.
- parser.print_help(sys.stdout)
+ if SCons.Script.SConscript.help_text is None:
+ # They specified -h, but there was no Help() inside the
+ # SConscript files. Give them the options usage.
+ parser.print_help(sys.stdout)
+ else:
+ print SCons.Script.SConscript.help_text
+ print "Use scons -H for help about command-line options."
sys.exit(0)
# Now that we've read the SConscripts we can set the options