summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Becker <becker33@llnl.gov>2015-10-30 14:08:09 -0700
committerGregory Becker <becker33@llnl.gov>2015-11-10 15:45:22 -0800
commit6fa0bb991a16bf468e3ad88226b22faa5c290d00 (patch)
treee4c1da63c58e40a87658e5466493e927c6f62772
parent5a9394c65ff505562fe83c2d944ebfdbb68cd5df (diff)
downloadspack-6fa0bb991a16bf468e3ad88226b22faa5c290d00.tar.gz
spack-6fa0bb991a16bf468e3ad88226b22faa5c290d00.tar.bz2
spack-6fa0bb991a16bf468e3ad88226b22faa5c290d00.tar.xz
spack-6fa0bb991a16bf468e3ad88226b22faa5c290d00.zip
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
-rw-r--r--lib/spack/spack/cmd/find.py40
-rw-r--r--lib/spack/spack/spec.py14
2 files changed, 39 insertions, 15 deletions
diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py
index 0b0dd6ef6f..0728f3f1b2 100644
--- a/lib/spack/spack/cmd/find.py
+++ b/lib/spack/spack/cmd/find.py
@@ -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,20 +121,28 @@ 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':
- def fmt(s):
- string = ""
- if hashes:
- string += gray_hash(s, hlen) + ' '
- string += s.format('$-_$@$+', color=True)
-
- return string
- colify(fmt(s) for s in specs)
+ # Print columns of output if not printing flags
+ if not flags:
+ def fmt(s):
+ string = ""
+ if hashes:
+ string += gray_hash(s, hlen) + ' '
+ string += s.format('$-_$@$+', color=True)
+
+ 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)
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 40a257489e..b9dcd91e99 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1630,7 +1630,9 @@ class Spec(object):
$@ 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 @@ class Spec(object):
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,11 +1702,17 @@ class Spec(object):
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
+ compiler = False
+
elif c == '$':
escape = True