From 19dca26f3ac3d5ded5ccfc7e561d997cfc4cdd2c Mon Sep 17 00:00:00 2001 From: scheibelp Date: Mon, 20 Mar 2017 12:36:44 -0700 Subject: Improve output for compiler commands (#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. --- lib/spack/spack/cmd/compiler.py | 5 ++++- lib/spack/spack/compilers/__init__.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/compiler.py b/lib/spack/spack/cmd/compiler.py index 9601c5ba65..22f3b3f26a 100644 --- a/lib/spack/spack/cmd/compiler.py +++ b/lib/spack/spack/cmd/compiler.py @@ -112,6 +112,8 @@ def compiler_find(args): colify(reversed(sorted(c.spec for c in new_compilers)), indent=4) else: tty.msg("Found no new compilers") + tty.msg("Compilers are defined in the following files:") + colify(spack.compilers.compiler_config_files(), indent=4) def compiler_remove(args): @@ -166,7 +168,8 @@ def compiler_list(args): tty.msg("Available compilers") index = index_by(spack.compilers.all_compilers(scope=args.scope), lambda c: (c.spec.name, c.operating_system, c.target)) - for i, (key, compilers) in enumerate(index.items()): + ordered_sections = sorted(index.items(), key=lambda (k, v): k) + for i, (key, compilers) in enumerate(ordered_sections): if i >= 1: print name, os, target = key diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index cb3aab9b97..a16caa3a6c 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -110,6 +110,16 @@ def get_compiler_config(scope=None, init_config=True): return [] # Return empty list which we will later append to. +def compiler_config_files(): + config_files = list() + for scope in spack.config.config_scopes: + config = spack.config.get_config('compilers', scope=scope) + if config: + config_files.append(spack.config.config_scopes[scope] + .get_section_filename('compilers')) + return config_files + + def add_compilers_to_config(compilers, scope=None, init_config=True): """Add compilers to the config for the specified architecture. -- cgit v1.2.3-70-g09d2