Removed cflags from default format string and made them an option within the compiler string. Added -f option to find command; with -f, find prints flags

This commit is contained in:
Gregory Becker 2015-10-30 14:08:09 -07:00
parent 5a9394c65f
commit 6fa0bb991a
2 changed files with 38 additions and 14 deletions

View file

@ -53,6 +53,9 @@ def setup_parser(subparser):
subparser.add_argument(
'-L', '--very-long', action='store_true', dest='very_long',
help='Show dependency hashes as well as versions.')
subparser.add_argument(
'-f', '--show-flags', action='store_true', dest='show_flags',
help='Show spec compiler flags.')
subparser.add_argument(
'-u', '--unknown', action='store_true', dest='unknown',
@ -76,12 +79,18 @@ def gray_hash(spec, length):
def display_specs(specs, **kwargs):
mode = kwargs.get('mode', 'short')
hashes = kwargs.get('long', False)
print hashes
hlen = 7
if kwargs.get('very_long', False):
hashes = True
hlen = None
format_string = '$_$@$+'
flags = kwargs.get('show_flags', False)
if flags:
format_string = '$_$@$%+$+'
# Make a dict with specs keyed by architecture and compiler.
index = index_by(specs, ('architecture', 'compiler'))
@ -97,7 +106,7 @@ def display_specs(specs, **kwargs):
specs = index[(architecture,compiler)]
specs.sort()
abbreviated = [s.format('$_$@$+', color=True) for s in specs]
abbreviated = [s.format(format_string, color=True) for s in specs]
if mode == 'paths':
# Print one spec per line along with prefix path
width = max(len(s) for s in abbreviated)
@ -112,12 +121,14 @@ def display_specs(specs, **kwargs):
elif mode == 'deps':
for spec in specs:
print spec.tree(
format='$_$@$+',
format=format_string,
color=True,
indent=4,
prefix=(lambda s: gray_hash(s, hlen)) if hashes else None)
elif mode == 'short':
# Print columns of output if not printing flags
if not flags:
def fmt(s):
string = ""
if hashes:
@ -126,6 +137,12 @@ def fmt(s):
return string
colify(fmt(s) for s in specs)
# Print one entry per line if including flags
else:
for spec in specs:
# Print the hash if necessary
hsh = gray_hash(spec, hlen) + ' ' if hashes else ''
print hsh + spec.format(format_string, color=True) + '\n'
else:
raise ValueError(
@ -171,4 +188,5 @@ def find(parser, args):
tty.msg("%d installed packages." % len(specs))
display_specs(specs, mode=args.mode,
long=args.long,
very_long=args.very_long)
very_long=args.very_long,
show_flags=args.show_flags)

View file

@ -1630,7 +1630,9 @@ def format(self, format_string='$_$@$%@$+$=', **kwargs):
$@ Version
$% Compiler
$%@ Compiler & compiler version
$+ Options & compiler flags
$%+ Compiler and compiler flags
$%@+ Compiler, compiler version, and compiler flags
$+ Options
$= Architecture
$# 7-char prefix of DAG hash
$$ $
@ -1684,8 +1686,6 @@ def write(s, c):
elif c == '+':
if self.variants:
write(fmt % str(self.variants), c)
if self.compiler_flags:
write(fmt % str(self.compiler_flags), '%')
elif c == '=':
if self.architecture:
write(fmt % ('+arch' + c + str(self.architecture)), c)
@ -1702,12 +1702,18 @@ def write(s, c):
if (self.compiler and self.compiler.versions and
self.compiler.versions != _any_version):
write(c + str(self.compiler.versions), '%')
elif c == '+':
if self.compiler_flags:
write(fmt % str(self.compiler_flags), '%')
compiler = False
elif c == '$':
escape = True
compiler = False
else:
out.write(c)
compiler = False
elif c == '$':
escape = True
if i == length - 1: