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( subparser.add_argument(
'-L', '--very-long', action='store_true', dest='very_long', '-L', '--very-long', action='store_true', dest='very_long',
help='Show dependency hashes as well as versions.') 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( subparser.add_argument(
'-u', '--unknown', action='store_true', dest='unknown', '-u', '--unknown', action='store_true', dest='unknown',
@ -76,12 +79,18 @@ def gray_hash(spec, length):
def display_specs(specs, **kwargs): def display_specs(specs, **kwargs):
mode = kwargs.get('mode', 'short') mode = kwargs.get('mode', 'short')
hashes = kwargs.get('long', False) hashes = kwargs.get('long', False)
print hashes
hlen = 7 hlen = 7
if kwargs.get('very_long', False): if kwargs.get('very_long', False):
hashes = True hashes = True
hlen = None hlen = None
format_string = '$_$@$+'
flags = kwargs.get('show_flags', False)
if flags:
format_string = '$_$@$%+$+'
# Make a dict with specs keyed by architecture and compiler. # Make a dict with specs keyed by architecture and compiler.
index = index_by(specs, ('architecture', 'compiler')) index = index_by(specs, ('architecture', 'compiler'))
@ -97,7 +106,7 @@ def display_specs(specs, **kwargs):
specs = index[(architecture,compiler)] specs = index[(architecture,compiler)]
specs.sort() 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': if mode == 'paths':
# Print one spec per line along with prefix path # Print one spec per line along with prefix path
width = max(len(s) for s in abbreviated) width = max(len(s) for s in abbreviated)
@ -112,12 +121,14 @@ def display_specs(specs, **kwargs):
elif mode == 'deps': elif mode == 'deps':
for spec in specs: for spec in specs:
print spec.tree( print spec.tree(
format='$_$@$+', format=format_string,
color=True, color=True,
indent=4, indent=4,
prefix=(lambda s: gray_hash(s, hlen)) if hashes else None) prefix=(lambda s: gray_hash(s, hlen)) if hashes else None)
elif mode == 'short': elif mode == 'short':
# Print columns of output if not printing flags
if not flags:
def fmt(s): def fmt(s):
string = "" string = ""
if hashes: if hashes:
@ -126,6 +137,12 @@ def fmt(s):
return string return string
colify(fmt(s) for s in specs) 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: else:
raise ValueError( raise ValueError(
@ -171,4 +188,5 @@ def find(parser, args):
tty.msg("%d installed packages." % len(specs)) tty.msg("%d installed packages." % len(specs))
display_specs(specs, mode=args.mode, display_specs(specs, mode=args.mode,
long=args.long, 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 $@ Version
$% Compiler $% Compiler
$%@ Compiler & compiler version $%@ Compiler & compiler version
$+ Options & compiler flags $%+ Compiler and compiler flags
$%@+ Compiler, compiler version, and compiler flags
$+ Options
$= Architecture $= Architecture
$# 7-char prefix of DAG hash $# 7-char prefix of DAG hash
$$ $ $$ $
@ -1684,8 +1686,6 @@ def write(s, c):
elif c == '+': elif c == '+':
if self.variants: if self.variants:
write(fmt % str(self.variants), c) write(fmt % str(self.variants), c)
if self.compiler_flags:
write(fmt % str(self.compiler_flags), '%')
elif c == '=': elif c == '=':
if self.architecture: if self.architecture:
write(fmt % ('+arch' + c + str(self.architecture)), c) write(fmt % ('+arch' + c + str(self.architecture)), c)
@ -1702,12 +1702,18 @@ def write(s, c):
if (self.compiler and self.compiler.versions and if (self.compiler and self.compiler.versions and
self.compiler.versions != _any_version): self.compiler.versions != _any_version):
write(c + str(self.compiler.versions), '%') write(c + str(self.compiler.versions), '%')
elif c == '+':
if self.compiler_flags:
write(fmt % str(self.compiler_flags), '%')
compiler = False
elif c == '$': elif c == '$':
escape = True escape = True
compiler = False
else: else:
out.write(c) out.write(c)
compiler = False compiler = False
elif c == '$': elif c == '$':
escape = True escape = True
if i == length - 1: if i == length - 1: