summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-06-25 16:32:43 (GMT)
committerSteven Knight <knight@baldmt.com>2003-06-25 16:32:43 (GMT)
commit35828d429f289360d9baaac22bd779633d1ef538 (patch)
treef75465c08a6eac0c08895be282d9a63f4a1d2f9a
parent89cbcdab1aa03c28d7f9e55bc5c67ac4fece1693 (diff)
downloadSCons-35828d429f289360d9baaac22bd779633d1ef538.zip
SCons-35828d429f289360d9baaac22bd779633d1ef538.tar.gz
SCons-35828d429f289360d9baaac22bd779633d1ef538.tar.bz2
Eliminate the need to import distutils.fancy_getopt.
-rw-r--r--src/CHANGES.txt75
-rw-r--r--src/engine/SCons/Optik/option_parser.py71
2 files changed, 71 insertions, 75 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index aadcc93..43dd939 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -10,90 +10,17 @@
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
diff --git a/src/engine/SCons/Optik/option_parser.py b/src/engine/SCons/Optik/option_parser.py
index ebe8336..94375d0 100644
--- a/src/engine/SCons/Optik/option_parser.py
+++ b/src/engine/SCons/Optik/option_parser.py
@@ -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 ()