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