summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2018-12-29 19:22:44 (GMT)
committerMats Wichmann <mats@linux.com>2019-04-05 22:42:50 (GMT)
commit75f738bda9cae575342cab2d843f71aea0007aef (patch)
tree561cbdbcb64e54efbfa915927e4142704af84325
parent4b2c0674a783c6d2d1f66d2588223bd5d99acda7 (diff)
downloadSCons-75f738bda9cae575342cab2d843f71aea0007aef.zip
SCons-75f738bda9cae575342cab2d843f71aea0007aef.tar.gz
SCons-75f738bda9cae575342cab2d843f71aea0007aef.tar.bz2
Give sconsign a default filename.
sconsign required filename(s) or directory name(s) to do anything, in their absence it just quits silently. Change so if filename argument omitted, use the same default as scons - .sconsign.dblite. print something in case of bad options. add an extra info line in case the sconsign cannot be read due to pickle protocol (when py2 used in a place where scons previously run with py3) Tweak the manpage a bit. Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r--doc/man/sconsign.xml56
-rwxr-xr-xsrc/CHANGES.txt2
-rw-r--r--src/script/sconsign.py89
3 files changed, 88 insertions, 59 deletions
diff --git a/doc/man/sconsign.xml b/doc/man/sconsign.xml
index aad2cd9..03b6351 100644
--- a/doc/man/sconsign.xml
+++ b/doc/man/sconsign.xml
@@ -37,15 +37,14 @@
</refmeta>
<refnamediv id='name'>
<refname>sconsign</refname>
-<refpurpose>print SCons .sconsign file information</refpurpose>
+<refpurpose>print SCons signature file information</refpurpose>
</refnamediv>
<!-- body begins here -->
<refsynopsisdiv id='synopsis'>
<cmdsynopsis>
<command>sconsign</command>
<arg choice='opt' rep='repeat'><replaceable>options</replaceable></arg>
- <arg choice='plain'><replaceable>file</replaceable></arg>
- <arg choice='opt'><replaceable>...</replaceable></arg>
+ <arg choice='opt' rep='repeat'><replaceable>file</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -54,30 +53,38 @@
<para>The
<command>sconsign</command>
command
-displays the contents of one or more
-<markup>.sconsign</markup>
+displays the contents of one or more signature
+("<markup>sconsign</markup>")
files specified by the user.</para>
<para>By default,
<command>sconsign</command>
dumps the entire contents of the
specified file(s).
-Each entry is printed in the following format:</para>
+Without the verbose option,
+each entry is printed in the following format:</para>
-<para> file: signature timestamp length
- implicit_dependency_1: signature timestamp length
- implicit_dependency_2: signature timestamp length
- action_signature [action string]</para>
+<literallayout class="monospaced">
+file: signature timestamp length
+ implicit_dependency_1: signature timestamp length
+ implicit_dependency_2: signature timestamp length
+ ...
+ action_signature [action string]
+</literallayout>
<para><emphasis role="bold">None</emphasis>
is printed
-in place of any missing timestamp, bsig, or csig
+in place of any missing timestamp, build signature ("bsig"),
+or content signature ("csig")
values for
any entry
or any of its dependencies.
If the entry has no implicit dependencies,
or no build action,
-the lines are simply omitted.</para>
+the lines are simply omitted.
+The verbose option expands the display into a more human
+readable format.
+</para>
<para>By default,
<command>sconsign</command>
@@ -90,7 +97,7 @@ signature entries for
more than one directory
(that is,
was specified by the
-<emphasis role="bold">SConsignFile ()</emphasis>
+<emphasis role="bold">SConsignFile</emphasis>
function).
Any
<emphasis>file</emphasis>
@@ -103,13 +110,21 @@ for a single directory.
If neither of those is true,
<command>sconsign</command>
attempts to guess the format.
-If that does not work,
+If that does not work,
an explicit format
may be specified using the
<option>-f</option>
or
<option>--format=</option>
-options.</para>
+options.
+</para>
+<para>
+If there are no
+<emphasis>file</emphasis>
+arguments, the name
+<filename>.sconsign.dblite</filename>
+is assumed.
+</para>
</refsect1>
@@ -175,7 +190,7 @@ Legal values are
<emphasis role="bold">dbm</emphasis>
(the DBM format used
when the
-<emphasis role="bold">SConsignFile</emphasis>()
+<emphasis role="bold">SConsignFile</emphasis>
function is used)
or
<command>sconsign</command>
@@ -197,7 +212,7 @@ file in each directory).</para>
<term>-i, --implicit</term>
<listitem>
<para>Prints the list of cached implicit dependencies
-for all entries or the the specified entries.</para>
+for all entries or for the specified entries.</para>
</listitem>
</varlistentry>
@@ -206,8 +221,8 @@ for all entries or the the specified entries.</para>
<listitem>
<para>Prints a pretty-printed representation
of the raw Python dictionary that holds
-build information about individual entry
-(both the entry itself or its implicit dependencies).
+build information about individual entries
+(both the entry itself and its implicit dependencies).
An entry's build action is still printed in its usual format.</para>
</listitem>
@@ -244,7 +259,8 @@ for all entries or the specified entries.</para>
<term>SCONS_LIB_DIR</term>
<listitem>
<para>Specifies the directory that contains the SCons Python module directory
-(e.g. /home/aroach/scons-src-0.01/src/engine).
+(e.g.
+<filename class='directory'>/home/aroach/scons-src-0.01/src/engine</filename>).
on the command line.</para>
</listitem>
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 15e8b5f..84a8056 100755
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -11,6 +11,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- scons-time takes more care closing files and uses safer mkdtemp to avoid
possible races on multi-job runs.
- Use importlib to dynamically load tool and platform modules instead of imp module
+ - sconsign: default to .sconsign.dblite if no filename is specified.
+ Be more informative in case of unsupported pickle protocol (py2 only).
From John Doe:
diff --git a/src/script/sconsign.py b/src/script/sconsign.py
index cb2b5c6..6ba0a7c 100644
--- a/src/script/sconsign.py
+++ b/src/script/sconsign.py
@@ -185,6 +185,7 @@ import SCons.compat
try:
import whichdb
+
whichdb = whichdb.whichdb
except ImportError as e:
from dbm import whichdb
@@ -199,9 +200,8 @@ def my_whichdb(filename):
if filename[-7:] == ".dblite":
return "SCons.dblite"
try:
- f = open(filename + ".dblite", "rb")
- f.close()
- return "SCons.dblite"
+ with open(filename + ".dblite", "rb"):
+ return "SCons.dblite"
except IOError:
pass
return _orig_whichdb(filename)
@@ -248,9 +248,8 @@ Readable = 0
Warns = 0
-
def default_mapper(entry, name):
- '''
+ """
Stringify an entry that doesn't have an explicit mapping.
Args:
@@ -259,7 +258,7 @@ def default_mapper(entry, name):
Returns: str
- '''
+ """
try:
val = eval("entry." + name)
except:
@@ -273,7 +272,7 @@ def default_mapper(entry, name):
def map_action(entry, _):
- '''
+ """
Stringify an action entry and signature.
Args:
@@ -282,7 +281,7 @@ def map_action(entry, _):
Returns: str
- '''
+ """
try:
bact = entry.bact
bactsig = entry.bactsig
@@ -290,8 +289,9 @@ def map_action(entry, _):
return None
return '%s [%s]' % (bactsig, bact)
+
def map_timestamp(entry, _):
- '''
+ """
Stringify a timestamp entry.
Args:
@@ -300,7 +300,7 @@ def map_timestamp(entry, _):
Returns: str
- '''
+ """
try:
timestamp = entry.timestamp
except AttributeError:
@@ -310,8 +310,9 @@ def map_timestamp(entry, _):
else:
return str(timestamp)
+
def map_bkids(entry, _):
- '''
+ """
Stringify an implicit entry.
Args:
@@ -320,7 +321,7 @@ def map_bkids(entry, _):
Returns: str
- '''
+ """
try:
bkids = entry.bsources + entry.bdepends + entry.bimplicit
bkidsigs = entry.bsourcesigs + entry.bdependsigs + entry.bimplicitsigs
@@ -449,8 +450,8 @@ class Do_SConsignDB(object):
def __call__(self, fname):
# The *dbm modules stick their own file suffixes on the names
- # that are passed in. This is causes us to jump through some
- # hoops here to be able to allow the user
+ # that are passed in. This causes us to jump through some
+ # hoops here.
try:
# Try opening the specified file name. Example:
# SPECIFIED OPENED BY self.dbm.open()
@@ -462,16 +463,17 @@ class Do_SConsignDB(object):
print_e = e
try:
# That didn't work, so try opening the base name,
- # so that if the actually passed in 'sconsign.dblite'
+ # so that if they actually passed in 'sconsign.dblite'
# (for example), the dbm module will put the suffix back
# on for us and open it anyway.
db = self.dbm.open(os.path.splitext(fname)[0], "r")
except (IOError, OSError):
# That didn't work either. See if the file name
- # they specified just exists (independent of the dbm
+ # they specified even exists (independent of the dbm
# suffix-mangling).
try:
- open(fname, "r")
+ with open(fname, "rb"):
+ pass # this is a touch only, we don't use it here.
except (IOError, OSError) as e:
# Nope, that file doesn't even exist, so report that
# fact back.
@@ -487,6 +489,9 @@ class Do_SConsignDB(object):
except Exception as e:
sys.stderr.write("sconsign: ignoring invalid `%s' file `%s': %s\n"
% (self.dbm_name, fname, e))
+ exc_type, _, _ = sys.exc_info()
+ if exc_type.__name__ == "ValueError" and sys.version_info < (3,0,0):
+ sys.stderr.write("Python 2 only supports pickle protocols 0-2.\n")
return
if Print_Directories:
@@ -513,23 +518,23 @@ class Do_SConsignDB(object):
def Do_SConsignDir(name):
try:
- fp = open(name, 'rb')
+ with open(name, 'rb') as fp:
+ try:
+ sconsign = SCons.SConsign.Dir(fp)
+ except KeyboardInterrupt:
+ raise
+ except pickle.UnpicklingError:
+ err = "sconsign: ignoring invalid .sconsign file `%s'\n" % (name)
+ sys.stderr.write(err)
+ return
+ except Exception as e:
+ err = "sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e)
+ sys.stderr.write(err)
+ return
+ printentries(sconsign.entries, args[0])
except (IOError, OSError) as e:
sys.stderr.write("sconsign: %s\n" % e)
return
- try:
- sconsign = SCons.SConsign.Dir(fp)
- except KeyboardInterrupt:
- raise
- except pickle.UnpicklingError:
- err = "sconsign: ignoring invalid .sconsign file `%s'\n" % (name)
- sys.stderr.write(err)
- return
- except Exception as e:
- err = "sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e)
- sys.stderr.write(err)
- return
- printentries(sconsign.entries, args[0])
##############################################################################
@@ -537,7 +542,7 @@ def Do_SConsignDir(name):
import getopt
helpstr = """\
-Usage: sconsign [OPTIONS] FILE [...]
+Usage: sconsign [OPTIONS] [FILE ...]
Options:
-a, --act, --action Print build action information.
-c, --csig Print content signature information.
@@ -553,13 +558,17 @@ Options:
-v, --verbose Verbose, describe each field.
"""
-opts, args = getopt.getopt(sys.argv[1:], "acd:e:f:hirstv",
- ['act', 'action',
- 'csig', 'dir=', 'entry=',
- 'format=', 'help', 'implicit',
- 'raw', 'readable',
- 'size', 'timestamp', 'verbose'])
-
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "acd:e:f:hirstv",
+ ['act', 'action',
+ 'csig', 'dir=', 'entry=',
+ 'format=', 'help', 'implicit',
+ 'raw', 'readable',
+ 'size', 'timestamp', 'verbose'])
+except getopt.GetoptError as err:
+ sys.stderr.write(str(err) + '\n')
+ print(helpstr)
+ sys.exit(2)
for o, a in opts:
if o in ('-a', '--act', '--action'):
@@ -614,6 +623,8 @@ if Do_Call:
for a in args:
Do_Call(a)
else:
+ if not args:
+ args = [".sconsign.dblite"]
for a in args:
dbm_name = whichdb(a)
if dbm_name: