Cleanup and proper flag satisfaction for partial specs
This commit is contained in:
parent
528f9cd583
commit
5e3c883f2c
4 changed files with 17 additions and 13 deletions
|
@ -105,7 +105,7 @@ def set_compiler_environment_variables(pkg):
|
||||||
os.environ['SPACK_FC'] = compiler.fc
|
os.environ['SPACK_FC'] = compiler.fc
|
||||||
|
|
||||||
# Add every valid compiler flag to the environment, prefaced by "SPACK_"
|
# Add every valid compiler flag to the environment, prefaced by "SPACK_"
|
||||||
for flag in Compiler.valid_compiler_flags():
|
for flag in spack.spec.FlagMap.valid_compiler_flags():
|
||||||
# Concreteness guarantees key safety here
|
# Concreteness guarantees key safety here
|
||||||
if flags[flag] != '':
|
if flags[flag] != '':
|
||||||
os.environ['SPACK_'+flag.upper()] = ' '.join(f for f in flags[flag])
|
os.environ['SPACK_'+flag.upper()] = ' '.join(f for f in flags[flag])
|
||||||
|
|
|
@ -63,10 +63,6 @@ def dumpversion(compiler_path):
|
||||||
"""Simple default dumpversion method -- this is what gcc does."""
|
"""Simple default dumpversion method -- this is what gcc does."""
|
||||||
return get_compiler_version(compiler_path, '-dumpversion')
|
return get_compiler_version(compiler_path, '-dumpversion')
|
||||||
|
|
||||||
_valid_compiler_flags = ['cflags', 'cxxflags', 'fflags', 'ldflags', 'cppflags']
|
|
||||||
def valid_compiler_flags():
|
|
||||||
return _valid_compiler_flags
|
|
||||||
|
|
||||||
|
|
||||||
class Compiler(object):
|
class Compiler(object):
|
||||||
"""This class encapsulates a Spack "compiler", which includes C,
|
"""This class encapsulates a Spack "compiler", which includes C,
|
||||||
|
@ -118,10 +114,10 @@ def check(exe):
|
||||||
# in the same order they are returned by sorted(flags)
|
# in the same order they are returned by sorted(flags)
|
||||||
# in compilers/__init__.py
|
# in compilers/__init__.py
|
||||||
self.flags = {}
|
self.flags = {}
|
||||||
for flag in _valid_compiler_flags:
|
for flag in spack.spec.FlagMap.valid_compiler_flags():
|
||||||
value = kwargs.get(flag, None)
|
value = kwargs.get(flag, None)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
self.flags[flag] = value
|
self.flags[flag] = value.split()
|
||||||
|
|
||||||
self.spec = cspec
|
self.spec = cspec
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ def get_compiler(cspec):
|
||||||
compiler_paths.append(None)
|
compiler_paths.append(None)
|
||||||
|
|
||||||
flags = {}
|
flags = {}
|
||||||
for f in Comp.valid_compiler_flags():
|
for f in spack.spec.FlagMap.valid_compiler_flags():
|
||||||
if f in items:
|
if f in items:
|
||||||
flags[f] = items[f]
|
flags[f] = items[f]
|
||||||
return cls(cspec, *compiler_paths, **flags)
|
return cls(cspec, *compiler_paths, **flags)
|
||||||
|
|
|
@ -372,6 +372,7 @@ def __str__(self):
|
||||||
return ''.join(str(self[key]) for key in sorted_keys)
|
return ''.join(str(self[key]) for key in sorted_keys)
|
||||||
|
|
||||||
|
|
||||||
|
_valid_compiler_flags = ['cflags', 'cxxflags', 'fflags', 'ldflags', 'cppflags']
|
||||||
class FlagMap(HashableMap):
|
class FlagMap(HashableMap):
|
||||||
def __init__(self, spec):
|
def __init__(self, spec):
|
||||||
super(FlagMap, self).__init__()
|
super(FlagMap, self).__init__()
|
||||||
|
@ -383,6 +384,10 @@ def satisfies(self, other, strict=False):
|
||||||
if strict:
|
if strict:
|
||||||
return all(f in self and set(self[f]) == set(other[f])
|
return all(f in self and set(self[f]) == set(other[f])
|
||||||
for f in other if other[f] != [])
|
for f in other if other[f] != [])
|
||||||
|
else:
|
||||||
|
if other.spec and other.spec.concrete:
|
||||||
|
return all(f in self and set(self[f]) == set(other[f])
|
||||||
|
for f in other)
|
||||||
else:
|
else:
|
||||||
return all(f in self and set(self[f]) >= set(other[f])
|
return all(f in self and set(self[f]) >= set(other[f])
|
||||||
for f in other)
|
for f in other)
|
||||||
|
@ -406,10 +411,13 @@ def constrain(self, other):
|
||||||
changed = True
|
changed = True
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def valid_compiler_flags():
|
||||||
|
return _valid_compiler_flags
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def concrete(self):
|
def concrete(self):
|
||||||
return self.spec._concrete
|
return all(flag in self for flag in _valid_compiler_flags)
|
||||||
|
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
|
@ -509,7 +517,7 @@ def _add_flag(self, name, value):
|
||||||
"""Called by the parser to add a known flag.
|
"""Called by the parser to add a known flag.
|
||||||
Known flags currently include "arch"
|
Known flags currently include "arch"
|
||||||
"""
|
"""
|
||||||
valid_flags = Compiler.valid_compiler_flags()
|
valid_flags = FlagMap.valid_compiler_flags()
|
||||||
if name == 'arch':
|
if name == 'arch':
|
||||||
self._set_architecture(value)
|
self._set_architecture(value)
|
||||||
elif name in valid_flags:
|
elif name in valid_flags:
|
||||||
|
@ -596,7 +604,7 @@ def concrete(self):
|
||||||
and self.variants.concrete
|
and self.variants.concrete
|
||||||
and self.architecture
|
and self.architecture
|
||||||
and self.compiler and self.compiler.concrete
|
and self.compiler and self.compiler.concrete
|
||||||
# and self.compiler_flags.concrete
|
and self.compiler_flags.concrete
|
||||||
and self.dependencies.concrete)
|
and self.dependencies.concrete)
|
||||||
return self._concrete
|
return self._concrete
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue