Spec.long_spec: update for conditional deps
Signed-off-by: Gregory Becker <becker33@llnl.gov>
This commit is contained in:
parent
02513eae7e
commit
e66ae3959d
@ -1639,20 +1639,26 @@ def edge_attributes(self) -> str:
|
|||||||
|
|
||||||
union = DependencySpec(parent=Spec(), spec=self, depflag=0, virtuals=())
|
union = DependencySpec(parent=Spec(), spec=self, depflag=0, virtuals=())
|
||||||
all_direct_edges = all(x.direct for x in edges)
|
all_direct_edges = all(x.direct for x in edges)
|
||||||
|
dep_conditions = []
|
||||||
|
|
||||||
for edge in edges:
|
for edge in edges:
|
||||||
union.update_deptypes(edge.depflag)
|
union.update_deptypes(edge.depflag)
|
||||||
union.update_virtuals(edge.virtuals)
|
union.update_virtuals(edge.virtuals)
|
||||||
|
dep_conditions.append(edge.when)
|
||||||
|
|
||||||
deptypes_str = ""
|
deptypes_str = ""
|
||||||
if not all_direct_edges and union.depflag:
|
if not all_direct_edges and union.depflag:
|
||||||
deptypes_str = f"deptypes={','.join(dt.flag_to_tuple(union.depflag))}"
|
deptypes_str = f"deptypes={','.join(dt.flag_to_tuple(union.depflag))}"
|
||||||
|
|
||||||
virtuals_str = f"virtuals={','.join(union.virtuals)}" if union.virtuals else ""
|
virtuals_str = f"virtuals={','.join(union.virtuals)}" if union.virtuals else ""
|
||||||
if not deptypes_str and not virtuals_str:
|
|
||||||
return ""
|
conditions = [str(c) for c in dep_conditions if c != Spec()]
|
||||||
result = f"{deptypes_str} {virtuals_str}".strip()
|
when_str = f"when={','.join(conditions)}" if conditions else ""
|
||||||
return f"[{result}]"
|
|
||||||
|
result = f"{when_str} {deptypes_str} {virtuals_str}".strip()
|
||||||
|
if result:
|
||||||
|
result = f"[{result}]"
|
||||||
|
return result
|
||||||
|
|
||||||
def dependencies(
|
def dependencies(
|
||||||
self,
|
self,
|
||||||
@ -2109,15 +2115,15 @@ def long_spec(self):
|
|||||||
new_name = spack.aliases.BUILTIN_TO_LEGACY_COMPILER.get(current_name, current_name)
|
new_name = spack.aliases.BUILTIN_TO_LEGACY_COMPILER.get(current_name, current_name)
|
||||||
# note: depflag not allowed, currently, on "direct" edges
|
# note: depflag not allowed, currently, on "direct" edges
|
||||||
edge_attributes = ""
|
edge_attributes = ""
|
||||||
if item.virtuals:
|
if item.virtuals or item.when:
|
||||||
edge_attributes = item.spec.format("{edge_attributes}") + " "
|
edge_attributes = item.spec.format("{edge_attributes}") + ""
|
||||||
|
|
||||||
parts.append(f"%{edge_attributes}{item.spec.format()}".replace(current_name, new_name))
|
parts.append(f"%{edge_attributes}{item.spec.format()}".replace(current_name, new_name))
|
||||||
for item in sorted(transitive, key=lambda x: x.spec.name):
|
for item in sorted(transitive, key=lambda x: x.spec.name):
|
||||||
# Recurse to attach build deps in order
|
# Recurse to attach build deps in order
|
||||||
edge_attributes = ""
|
edge_attributes = ""
|
||||||
if item.virtuals or item.depflag:
|
if item.virtuals or item.depflag or item.when:
|
||||||
edge_attributes = item.spec.format("{edge_attributes}") + " "
|
edge_attributes = item.spec.format("{edge_attributes}") + ""
|
||||||
parts.append(f"^{edge_attributes}{str(item.spec)}")
|
parts.append(f"^{edge_attributes}{str(item.spec)}")
|
||||||
return " ".join(parts).strip()
|
return " ".join(parts).strip()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user