X Tutup
Skip to content

Commit 19dca26

Browse files
scheibelptgamblin
authored andcommitted
Improve output for compiler commands (spack#3480)
* Order listed compiler sections "spack compiler list" output compiler sections in an arbitrary order. With this commit compiler sections are ordered primarily by compiler name and then by operating system and target. * Compiler search lists config files with compilers If a compiler entry is already defined in a configuration file that the user does not know about, they may be confused when that compiler is not added by "spack compiler find". This commit adds a message at the end of "spack compiler find" to inform the user of the locations of all config files where compilers are defined.
1 parent 5ac6421 commit 19dca26

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/spack/spack/cmd/compiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def compiler_find(args):
112112
colify(reversed(sorted(c.spec for c in new_compilers)), indent=4)
113113
else:
114114
tty.msg("Found no new compilers")
115+
tty.msg("Compilers are defined in the following files:")
116+
colify(spack.compilers.compiler_config_files(), indent=4)
115117

116118

117119
def compiler_remove(args):
@@ -166,7 +168,8 @@ def compiler_list(args):
166168
tty.msg("Available compilers")
167169
index = index_by(spack.compilers.all_compilers(scope=args.scope),
168170
lambda c: (c.spec.name, c.operating_system, c.target))
169-
for i, (key, compilers) in enumerate(index.items()):
171+
ordered_sections = sorted(index.items(), key=lambda (k, v): k)
172+
for i, (key, compilers) in enumerate(ordered_sections):
170173
if i >= 1:
171174
print
172175
name, os, target = key

lib/spack/spack/compilers/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ def init_compiler_config():
110110
return [] # Return empty list which we will later append to.
111111

112112

113+
def compiler_config_files():
114+
config_files = list()
115+
for scope in spack.config.config_scopes:
116+
config = spack.config.get_config('compilers', scope=scope)
117+
if config:
118+
config_files.append(spack.config.config_scopes[scope]
119+
.get_section_filename('compilers'))
120+
return config_files
121+
122+
113123
def add_compilers_to_config(compilers, scope=None, init_config=True):
114124
"""Add compilers to the config for the specified architecture.
115125

0 commit comments

Comments
 (0)
X Tutup