Eliminate the need to import distutils.fancy_getopt.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 25 Jun 2003 16:32:43 +0000 (16:32 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 25 Jun 2003 16:32:43 +0000 (16:32 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@721 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Optik/option_parser.py

index aadcc93ed7b4aa52a96039d805d9ee97d06d2f9c..43dd939e2048b7952f3b7880e0bcc76218e2be08 100644 (file)
 
 RELEASE 0.15 - XXX
 
-  From Chad Austin:
-
-  - Fix the _concat() documentation, and add a test for it.
-
-  - Portability fixes for non-GNU versions of lex and yacc.
-
-  From Matt Balvin:
-
-  - Fix handling of library prefixes when the subdirectory matches
-    the prefix.
-
-  From Timothee Bessett:
-
-  - Add an M4 Builder.
-
-  From Charles Crain:
-
-  - Use '.lnk' as the suffix on the temporary file for linking long
-    command lines (necessary for the Phar Lap linkloc linker).
-
-  - Save non-string Options values as their actual type.
-
-  - Save Options string values that contain a single quote correctly.
-
-  - Save any Options values that are changed from the default
-    Environment values, not just ones changed on the command line or in
-    an Options file.
-
-  - Make closing the Options file descriptor exception-safe.
-
   From Steven Knight:
 
   - SCons now enforces (with an error) that construction variables
     must have the same form as valid Python identifiers.
 
   - Fix man page bugs: remove duplicate AddPostAction() description;
-    document no_import_lib; mention that CPPFLAGS does not contain
-    $_CPPINCFLAGS; mention that F77FLAGS does not contain $_F77INCFLAGS;
-    mention that LINKFLAGS and SHLINKFLAGS contains neither $_LIBFLAGS
-    nor $_LIBDIRFLAGS.
+    document no_import_lib.
 
   - Eliminate a dependency on the distutils.fancy_getopt module by
     copying and pasting its wrap_text() function directly.
 
-  - Make the Script.Options() subclass match the underlying base class
-    implementation.
-
-  - When reporting a target is up to date, quote the target like make
-    (backquote-quote) instead of with double quotes.
-
-  From Steve Leblanc:
-
-  - Don't update the .sconsign files when run with -n.
-
-  From Gary Oberbrunner:
-
-  - Add support for the Intel C Compiler (icl.exe).
-
-  From Anthony Roach
-
-  - Fix Import('*').
-
-  From David Snopek
-
-  - Fix use of SConf in paths with white space in them.
-
-  - Add CheckFunc and CheckType functionality to SConf.
-
-  - Fix use of SConf with Builders that return a list of nodes.
-
-  From David Snopek and Christoph Wiedemann
-
-  - Fix use of the SConf subsystem with SConscriptChdir().
-
-  From Greg Spencer
-
-  - Check for the existence of MS Visual Studio on disk before using it,
-    to avoid getting fooled by leftover junk in the registry.
-
-  - Add support for MSVC++ .NET.
-
-  - Add support for MS Visual Studio project files (DSP, DSW,
-    SLN and VCPROJ files).
-
 
 
 RELEASE 0.14 - Wed, 21 May 2003 05:16:32 -0500
index ebe8336d209b2689f08463db1592adacd73eb0ce..94375d0023a6e4bb163458391e7a466a85843ac5 100644 (file)
@@ -556,7 +556,10 @@ class OptionParser:
         Print an extended help message, listing all options and any
         help text provided with them, to 'file' (default stdout).
         """
-        from distutils.fancy_getopt import wrap_text
+        # SCons:  don't import wrap_text from distutils, use the
+        # copy we've included below, so we can avoid being dependent
+        # on having the right version of distutils installed.
+        #from distutils.fancy_getopt import wrap_text
         
         if file is None:
             file = sys.stdout
@@ -659,3 +662,69 @@ def _match_abbrev (s, wordmap):
             # More than one possible completion: ambiguous prefix.
             raise BadOptionError("ambiguous option: %s (%s?)"
                                  % (s, string.join(possibilities,", ")))
+
+# SCons:  Include a snarfed copy of wrap_text(), so we're not dependent
+# on the right version of distutils being installed.
+import re
+
+WS_TRANS = string.maketrans(string.whitespace, ' ' * len(string.whitespace))
+
+def wrap_text (text, width):
+    """wrap_text(text : string, width : int) -> [string]
+
+    Split 'text' into multiple lines of no more than 'width' characters
+    each, and return the list of strings that results.
+    """
+
+    if text is None:
+        return []
+    if len(text) <= width:
+        return [text]
+
+    text = string.expandtabs(text)
+    text = string.translate(text, WS_TRANS)
+    chunks = re.split(r'( +|-+)', text)
+    chunks = filter(None, chunks)      # ' - ' results in empty strings
+    lines = []
+
+    while chunks:
+
+        cur_line = []                   # list of chunks (to-be-joined)
+        cur_len = 0                     # length of current line
+
+        while chunks:
+            l = len(chunks[0])
+            if cur_len + l <= width:    # can squeeze (at least) this chunk in
+                cur_line.append(chunks[0])
+                del chunks[0]
+                cur_len = cur_len + l
+            else:                       # this line is full
+                # drop last chunk if all space
+                if cur_line and cur_line[-1][0] == ' ':
+                    del cur_line[-1]
+                break
+
+        if chunks:                      # any chunks left to process?
+
+            # if the current line is still empty, then we had a single
+            # chunk that's too big too fit on a line -- so we break
+            # down and break it up at the line width
+            if cur_len == 0:
+                cur_line.append(chunks[0][0:width])
+                chunks[0] = chunks[0][width:]
+
+            # all-whitespace chunks at the end of a line can be discarded
+            # (and we know from the re.split above that if a chunk has
+            # *any* whitespace, it is *all* whitespace)
+            if chunks[0][0] == ' ':
+                del chunks[0]
+
+        # and store this line in the list-of-all-lines -- as a single
+        # string, of course!
+        lines.append(string.join(cur_line, ''))
+
+    # while chunks
+
+    return lines
+
+# wrap_text ()