summaryrefslogtreecommitdiffstats
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
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)
-rw-r--r--doc/man/scons.18
-rw-r--r--src/CHANGES.txt5
-rw-r--r--src/engine/SCons/Script/SConscript.py10
-rw-r--r--src/engine/SCons/Script/__init__.py56
-rw-r--r--test/Help.py22
-rw-r--r--test/Options.py14
-rw-r--r--test/OptionsTypes.py5
7 files changed, 79 insertions, 41 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index a08b151..6b94453 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -2929,8 +2929,12 @@ This specifies help text to be printed if the
.B -h
argument is given to
.BR scons .
-.B scons
-will exit after printing out the help text.
+If
+.BR Help
+is called multiple times, the text is appended together in the order
+that
+.BR Help
+is called.
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
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
diff --git a/test/Help.py b/test/Help.py
index ea356ba..d6e71ea 100644
--- a/test/Help.py
+++ b/test/Help.py
@@ -60,4 +60,26 @@ Use scons -H for help about command-line options.
test.run(arguments = '-h', stdout = expect)
+test.write('SConstruct', r"""
+Help('\nMulti')
+Help('line\n')
+Help('''\
+help
+text!
+''')
+""")
+
+expect = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+
+Multiline
+help
+text!
+
+Use scons -H for help about command-line options.
+"""
+
+test.run(arguments = '-h', stdout = expect)
+
test.pass_test()
diff --git a/test/Options.py b/test/Options.py
index c98ffc6..d9bfd17 100644
--- a/test/Options.py
+++ b/test/Options.py
@@ -141,7 +141,14 @@ test.run(arguments='"DEBUG_BUILD=1"')
check(['1', '1', cc, string.strip(ccflags + ' -O -g'), 'v', 'v'])
test.run(arguments='-h',
- stdout = """scons: Reading SConscript files ...
+ stdout = """\
+scons: Reading SConscript files ...
+1
+0
+%s
+%s
+v
+v
scons: done reading SConscript files.
Variables settable in custom.py or on the command line:
@@ -166,7 +173,7 @@ UNSPECIFIED: An option with no value
actual: None
Use scons -H for help about command-line options.
-"""%cc)
+"""%(cc, ccflags and ccflags + ' -O' or '-O', cc))
# Test saving of options and multi loading
#
@@ -288,7 +295,8 @@ Help('Variables settable in custom.py or on the command line:\\n' + opts.Generat
""")
test.run(arguments='-h',
- stdout = """scons: Reading SConscript files ...
+ stdout = """\
+scons: Reading SConscript files ...
scons: done reading SConscript files.
Variables settable in custom.py or on the command line:
diff --git a/test/OptionsTypes.py b/test/OptionsTypes.py
index 55cf035..5fef257 100644
--- a/test/OptionsTypes.py
+++ b/test/OptionsTypes.py
@@ -346,7 +346,10 @@ Default(env.Alias('dummy', None))
test.run(arguments='-h',
- stdout = """scons: Reading SConscript files ...
+ stdout = """\
+scons: Reading SConscript files ...
+1
+0
scons: done reading SConscript files.
warnings: compilation with -Wall and similiar (yes|no)