Added init_config parameter so we don't initialize the config when user runs spack compiler add. Should ONLY add what user specifies. Find compilers takes in paths parameter.
This commit is contained in:
parent
005827ab23
commit
df84fe0b58
2 changed files with 28 additions and 22 deletions
|
@ -77,10 +77,12 @@ def compiler_add(args):
|
||||||
paths = get_path('PATH')
|
paths = get_path('PATH')
|
||||||
|
|
||||||
compilers = [c for c in spack.compilers.find_compilers(*args.add_paths)
|
compilers = [c for c in spack.compilers.find_compilers(*args.add_paths)
|
||||||
if c.spec not in spack.compilers.all_compilers(scope=args.scope)]
|
if c.spec not in spack.compilers.all_compilers(scope=args.scope,
|
||||||
|
init_config=False)]
|
||||||
|
|
||||||
if compilers:
|
if compilers:
|
||||||
spack.compilers.add_compilers_to_config(compilers, scope=args.scope)
|
spack.compilers.add_compilers_to_config(compilers, scope=args.scope,
|
||||||
|
init_config=False)
|
||||||
n = len(compilers)
|
n = len(compilers)
|
||||||
s = 's' if n > 1 else ''
|
s = 's' if n > 1 else ''
|
||||||
filename = spack.config.get_config_filename(args.scope, 'compilers')
|
filename = spack.config.get_config_filename(args.scope, 'compilers')
|
||||||
|
|
|
@ -79,12 +79,10 @@ def _to_dict(compiler):
|
||||||
if compiler.alias:
|
if compiler.alias:
|
||||||
d['alias'] = compiler.alias
|
d['alias'] = compiler.alias
|
||||||
|
|
||||||
return {
|
return {'compiler': d}
|
||||||
'compiler': d
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def get_compiler_config(scope=None):
|
def get_compiler_config(scope=None, init_config=True):
|
||||||
"""Return the compiler configuration for the specified architecture.
|
"""Return the compiler configuration for the specified architecture.
|
||||||
"""
|
"""
|
||||||
def init_compiler_config():
|
def init_compiler_config():
|
||||||
|
@ -100,7 +98,8 @@ def init_compiler_config():
|
||||||
# configured. Avoid updating automatically if there ARE site
|
# configured. Avoid updating automatically if there ARE site
|
||||||
# compilers configured but no user ones.
|
# compilers configured but no user ones.
|
||||||
# if (isinstance(arch, basestring) or arch == my_arch) and arch not in config:
|
# if (isinstance(arch, basestring) or arch == my_arch) and arch not in config:
|
||||||
if not config:
|
empty_config = []
|
||||||
|
if not config and init_config:
|
||||||
if scope is None:
|
if scope is None:
|
||||||
# We know no compilers were configured in any scope.
|
# We know no compilers were configured in any scope.
|
||||||
init_compiler_config()
|
init_compiler_config()
|
||||||
|
@ -112,18 +111,20 @@ def init_compiler_config():
|
||||||
if not site_config:
|
if not site_config:
|
||||||
init_compiler_config()
|
init_compiler_config()
|
||||||
config = spack.config.get_config('compilers', scope=scope)
|
config = spack.config.get_config('compilers', scope=scope)
|
||||||
|
return config
|
||||||
return config
|
else:
|
||||||
|
return empty_config
|
||||||
|
|
||||||
|
|
||||||
def add_compilers_to_config(compilers, scope=None):
|
def add_compilers_to_config(compilers, scope=None, init_config=True):
|
||||||
"""Add compilers to the config for the specified architecture.
|
"""Add compilers to the config for the specified architecture.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- compilers: a list of Compiler objects.
|
- compilers: a list of Compiler objects.
|
||||||
- scope: configuration scope to modify.
|
- scope: configuration scope to modify.
|
||||||
"""
|
"""
|
||||||
compiler_config = get_compiler_config(scope)
|
compiler_config = get_compiler_config(scope, init_config)
|
||||||
|
print compiler_config
|
||||||
for compiler in compilers:
|
for compiler in compilers:
|
||||||
compiler_config.append(_to_dict(compiler))
|
compiler_config.append(_to_dict(compiler))
|
||||||
|
|
||||||
|
@ -148,25 +149,23 @@ def remove_compiler_from_config(compiler_spec, scope=None):
|
||||||
spack.config.update_config('compilers', compiler_config, scope)
|
spack.config.update_config('compilers', compiler_config, scope)
|
||||||
|
|
||||||
_cache_config_file = {}
|
_cache_config_file = {}
|
||||||
|
def all_compilers_config(scope=None, init_config=True):
|
||||||
def all_compilers_config(scope=None):
|
|
||||||
"""Return a set of specs for all the compiler versions currently
|
"""Return a set of specs for all the compiler versions currently
|
||||||
available to build with. These are instances of CompilerSpec.
|
available to build with. These are instances of CompilerSpec.
|
||||||
"""
|
"""
|
||||||
# Get compilers for this architecture.
|
# Get compilers for this architecture.
|
||||||
global _cache_config_file #Create a cache of the config file so we don't load all the time.
|
global _cache_config_file #Create a cache of the config file so we don't load all the time.
|
||||||
|
|
||||||
if not _cache_config_file:
|
if not _cache_config_file:
|
||||||
_cache_config_file = get_compiler_config(scope)
|
_cache_config_file = get_compiler_config(scope, init_config)
|
||||||
return _cache_config_file
|
return _cache_config_file
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return _cache_config_file
|
return _cache_config_file
|
||||||
|
|
||||||
def all_compilers(scope=None):
|
|
||||||
|
def all_compilers(scope=None, init_config=True):
|
||||||
# Return compiler specs from the merged config.
|
# Return compiler specs from the merged config.
|
||||||
return [spack.spec.CompilerSpec(s['compiler']['spec'])
|
return [spack.spec.CompilerSpec(s['compiler']['spec'])
|
||||||
for s in all_compilers_config(scope)]
|
for s in all_compilers_config(scope, init_config)]
|
||||||
|
|
||||||
|
|
||||||
def default_compiler():
|
def default_compiler():
|
||||||
|
@ -181,7 +180,13 @@ def default_compiler():
|
||||||
return sorted(versions)[-1]
|
return sorted(versions)[-1]
|
||||||
|
|
||||||
|
|
||||||
def find_compilers():
|
def find_compilers(*paths):
|
||||||
|
""" Call find compilers help and return the list it finds using
|
||||||
|
the operating system method (PATHS, MODULES) """
|
||||||
|
return _find_compilers(*paths)
|
||||||
|
|
||||||
|
|
||||||
|
def _find_compilers(*paths):
|
||||||
"""Return a list of compilers found in the suppied paths.
|
"""Return a list of compilers found in the suppied paths.
|
||||||
This invokes the find_compilers() method for each operating
|
This invokes the find_compilers() method for each operating
|
||||||
system associated with the host platform, and appends
|
system associated with the host platform, and appends
|
||||||
|
@ -190,9 +195,8 @@ def find_compilers():
|
||||||
# Find compilers for each operating system class
|
# Find compilers for each operating system class
|
||||||
oss = all_os_classes()
|
oss = all_os_classes()
|
||||||
compiler_lists = []
|
compiler_lists = []
|
||||||
for os in oss:
|
for o in oss:
|
||||||
compiler_lists.extend(os.find_compilers())
|
compiler_lists.extend(o.find_compilers(*paths))
|
||||||
|
|
||||||
return compiler_lists
|
return compiler_lists
|
||||||
|
|
||||||
def supported_compilers():
|
def supported_compilers():
|
||||||
|
|
Loading…
Reference in a new issue