Added a few points of customization during compiler detection
This commit is contained in:
parent
54313bbcc6
commit
36cb494c8c
@ -537,18 +537,20 @@ def detect_version(detect_version_args):
|
|||||||
of the tuple will contain it. Otherwise ``error`` is a string
|
of the tuple will contain it. Otherwise ``error`` is a string
|
||||||
containing an explanation on why the version couldn't be computed.
|
containing an explanation on why the version couldn't be computed.
|
||||||
"""
|
"""
|
||||||
compiler_id = detect_version_args.id
|
def _default(fn_args):
|
||||||
language = detect_version_args.language
|
compiler_id = fn_args.id
|
||||||
|
language = fn_args.language
|
||||||
compiler_cls = class_for_compiler_name(compiler_id.compiler_name)
|
compiler_cls = class_for_compiler_name(compiler_id.compiler_name)
|
||||||
path = detect_version_args.path
|
path = fn_args.path
|
||||||
|
|
||||||
# Get compiler names and the callback to detect their versions
|
# Get compiler names and the callback to detect their versions
|
||||||
callback = getattr(compiler_cls, '{0}_version'.format(language))
|
callback = getattr(compiler_cls, '{0}_version'.format(language))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
version = callback(path)
|
version = callback(path)
|
||||||
if version and six.text_type(version).strip() and version != 'unknown':
|
if version and six.text_type(version).strip() \
|
||||||
value = detect_version_args._replace(
|
and version != 'unknown':
|
||||||
|
value = fn_args._replace(
|
||||||
id=compiler_id._replace(version=version)
|
id=compiler_id._replace(version=version)
|
||||||
)
|
)
|
||||||
return value, None
|
return value, None
|
||||||
@ -565,6 +567,10 @@ def detect_version(detect_version_args):
|
|||||||
six.text_type(e))
|
six.text_type(e))
|
||||||
return None, error
|
return None, error
|
||||||
|
|
||||||
|
operating_system = detect_version_args.id.os
|
||||||
|
fn = getattr(operating_system, 'detect_version', _default)
|
||||||
|
return fn(detect_version_args)
|
||||||
|
|
||||||
|
|
||||||
def make_compiler_list(detected_versions):
|
def make_compiler_list(detected_versions):
|
||||||
"""Process a list of detected versions and turn them into a list of
|
"""Process a list of detected versions and turn them into a list of
|
||||||
@ -592,6 +598,17 @@ def make_compiler_list(detected_versions):
|
|||||||
# For each unique compiler id select the name variation with most entries
|
# For each unique compiler id select the name variation with most entries
|
||||||
# i.e. the one that supports most languages
|
# i.e. the one that supports most languages
|
||||||
compilers = []
|
compilers = []
|
||||||
|
|
||||||
|
def _default(cmp_id, paths):
|
||||||
|
operating_system, compiler_name, version = cmp_id
|
||||||
|
compiler_cls = spack.compilers.class_for_compiler_name(compiler_name)
|
||||||
|
spec = spack.spec.CompilerSpec(compiler_cls.name, version)
|
||||||
|
paths = [paths.get(l, None) for l in ('cc', 'cxx', 'f77', 'fc')]
|
||||||
|
compiler = compiler_cls(
|
||||||
|
spec, operating_system, py_platform.machine(), paths
|
||||||
|
)
|
||||||
|
return compiler
|
||||||
|
|
||||||
for compiler_id, by_compiler_id in compilers_d.items():
|
for compiler_id, by_compiler_id in compilers_d.items():
|
||||||
_, selected_name_variation = max(
|
_, selected_name_variation = max(
|
||||||
(len(by_compiler_id[variation]), variation)
|
(len(by_compiler_id[variation]), variation)
|
||||||
@ -599,14 +616,11 @@ def make_compiler_list(detected_versions):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Add it to the list of compilers
|
# Add it to the list of compilers
|
||||||
operating_system, compiler_name, version = compiler_id
|
selected = by_compiler_id[selected_name_variation]
|
||||||
compiler_cls = spack.compilers.class_for_compiler_name(compiler_name)
|
operating_system, _, _ = compiler_id
|
||||||
spec = spack.spec.CompilerSpec(compiler_cls.name, version)
|
make_compiler = getattr(operating_system, 'make_compiler', _default)
|
||||||
paths = [by_compiler_id[selected_name_variation].get(l, None)
|
compiler_instance = make_compiler(compiler_id, selected)
|
||||||
for l in ('cc', 'cxx', 'f77', 'fc')]
|
compilers.append(compiler_instance)
|
||||||
compilers.append(
|
|
||||||
compiler_cls(spec, operating_system, py_platform.machine(), paths)
|
|
||||||
)
|
|
||||||
|
|
||||||
return compilers
|
return compilers
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user