Removed "any-pkg-name" and replaced it with empty string. Also changed cflag concretizer to concretize each flag individually, allowing us to have unconcretized FlagMap objects for find and uninstall. Now empty flags in find match any, whereas specifying +cflags=\'\' matches only those with empty strings for flags
This commit is contained in:
parent
6fa0bb991a
commit
6f339939c4
@ -38,7 +38,7 @@
|
||||
import spack.architecture
|
||||
import spack.error
|
||||
from spack.version import *
|
||||
|
||||
import spack.compiler as Compiler
|
||||
|
||||
|
||||
class DefaultConcretizer(object):
|
||||
@ -181,20 +181,27 @@ def concretize_compiler_flags(self, spec):
|
||||
compiler is used, defaulting to no compiler flags in the spec.
|
||||
Default specs set at the compiler level will still be added later.
|
||||
"""
|
||||
try:
|
||||
nearest = next(p for p in spec.traverse(direction='parents')
|
||||
if p.compiler == spec.compiler and p is not spec)
|
||||
if spec.compiler_flags == nearest.compiler_flags:
|
||||
return False
|
||||
spec.compiler_flags = nearest.compiler_flags.copy()
|
||||
ret = False
|
||||
for flag in Compiler.valid_compiler_flags():
|
||||
print flag
|
||||
try:
|
||||
nearest = next(p for p in spec.traverse(direction='parents')
|
||||
if p.compiler == spec.compiler and p is not spec
|
||||
and flag in p.compiler_flags)
|
||||
if ((not flag in spec.compiler_flags) or
|
||||
spec.compiler_flags[flag] != p.compiler_flags[flag]):
|
||||
spec.compiler_flags[flag] = p.compiler_flags[flag]
|
||||
ret = True
|
||||
|
||||
except StopIteration:
|
||||
if spec.compiler_flags == spec.root.compiler_flags:
|
||||
return False
|
||||
spec.compiler_flags = spec.root.compiler_flags
|
||||
|
||||
return True # things changed.
|
||||
except StopIteration:
|
||||
if (flag in spec.root.compiler_flags and ((not flag in spec.compiler_flags) or
|
||||
spec.compiler_flags[flag] != spec.root.compiler_flags[flag])):
|
||||
spec.compiler_flags[flag] = spec.root.compiler_flags[flag]
|
||||
ret = True
|
||||
else:
|
||||
spec.compiler_flags[flag] = ''
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def choose_provider(self, spec, providers):
|
||||
|
@ -153,7 +153,7 @@ def all_packages(self):
|
||||
@memoized
|
||||
def exists(self, pkg_name):
|
||||
"""Whether a package with the supplied name exists ."""
|
||||
if pkg_name == "any-pkg-name":
|
||||
if pkg_name == "":
|
||||
return True
|
||||
return os.path.exists(self.filename_for_package_name(pkg_name))
|
||||
|
||||
|
@ -376,8 +376,6 @@ class FlagMap(HashableMap):
|
||||
def __init__(self, spec):
|
||||
super(FlagMap, self).__init__()
|
||||
self.spec = spec
|
||||
for flag in Compiler.valid_compiler_flags():
|
||||
self[flag] = ""
|
||||
|
||||
|
||||
def satisfies(self, other, strict=False):
|
||||
@ -386,7 +384,9 @@ def satisfies(self, other, strict=False):
|
||||
return all(k in self and self[k] == other[k]
|
||||
for k in other if other[k] != "")
|
||||
else:
|
||||
return self == other
|
||||
return all(k in self and self[k] == other[k]
|
||||
for k in other)
|
||||
|
||||
|
||||
def constrain(self, other):
|
||||
"""Add all flags in other that aren't in self to self.
|
||||
@ -581,7 +581,7 @@ def virtual(self):
|
||||
@staticmethod
|
||||
def is_virtual(name):
|
||||
"""Test if a name is virtual without requiring a Spec."""
|
||||
return name != "any-pkg-name" and not spack.db.exists(name)
|
||||
return name != "" and not spack.db.exists(name)
|
||||
|
||||
|
||||
@property
|
||||
@ -904,7 +904,7 @@ def concretize(self):
|
||||
with requirements of its pacakges. See flatten() and normalize() for
|
||||
more details on this.
|
||||
"""
|
||||
if self.name == "any-pkg-name":
|
||||
if self.name == "":
|
||||
raise SpecError("Attempting to concretize anonymous spec")
|
||||
|
||||
if self._concrete:
|
||||
@ -1239,7 +1239,7 @@ def constrain(self, other, deps=True):
|
||||
"""
|
||||
other = self._autospec(other)
|
||||
|
||||
if not (self.name == other.name or self.name == "any-pkg-name" or other.name == "any-pkg-name"):
|
||||
if not (self.name == other.name or self.name == "" or other.name == ""):
|
||||
raise UnsatisfiableSpecNameError(self.name, other.name)
|
||||
|
||||
if not self.versions.overlaps(other.versions):
|
||||
@ -1332,7 +1332,7 @@ def _autospec(self, spec_like):
|
||||
|
||||
try:
|
||||
spec = spack.spec.Spec(spec_like)
|
||||
if spec.name == "any-pkg-name":
|
||||
if spec.name == "":
|
||||
raise SpecError("anonymous package -- this will always be handled")
|
||||
return spec
|
||||
except SpecError:
|
||||
@ -1365,7 +1365,7 @@ def satisfies(self, other, deps=True, strict=False):
|
||||
return False
|
||||
|
||||
# Otherwise, first thing we care about is whether the name matches
|
||||
if self.name != other.name and self.name != "any-pkg-name" and other.name != "any-pkg-name":
|
||||
if self.name != other.name and self.name != "" and other.name != "":
|
||||
return False
|
||||
|
||||
if self.versions and other.versions:
|
||||
@ -1382,7 +1382,7 @@ def satisfies(self, other, deps=True, strict=False):
|
||||
return False
|
||||
|
||||
var_strict = strict
|
||||
if self.name == "any-pkg-name" or other.name == "any-pkg-name":
|
||||
if self.name == "" or other.name == "":
|
||||
var_strict = True
|
||||
if not self.variants.satisfies(other.variants, strict=var_strict):
|
||||
return False
|
||||
@ -1401,7 +1401,7 @@ def satisfies(self, other, deps=True, strict=False):
|
||||
# If we need to descend into dependencies, do it, otherwise we're done.
|
||||
if deps:
|
||||
deps_strict = strict
|
||||
if self.name == "any-pkg-name" or other.name == "any-pkg-name":
|
||||
if self.name == "" or other.name == "":
|
||||
deps_strict=True
|
||||
return self.satisfies_dependencies(other, strict=deps_strict)
|
||||
else:
|
||||
@ -1888,7 +1888,7 @@ def spec_by_hash(self):
|
||||
def empty_spec(self):
|
||||
"""Create a Null spec from which dependency constraints can be hung"""
|
||||
spec = Spec.__new__(Spec)
|
||||
spec.name = "any-pkg-name"
|
||||
spec.name = ""
|
||||
spec.versions = VersionList(':')
|
||||
spec.variants = VariantMap(spec)
|
||||
spec.architecture = None
|
||||
|
@ -67,8 +67,8 @@ def update(self, spec):
|
||||
if type(spec) != spack.spec.Spec:
|
||||
spec = spack.spec.Spec(spec)
|
||||
|
||||
if spec.name == "any-pkg-name":
|
||||
#The "any" name does not have a package
|
||||
if spec.name == "":
|
||||
# Empty specs do not have a package
|
||||
return
|
||||
|
||||
assert(not spec.virtual)
|
||||
|
Loading…
Reference in New Issue
Block a user