Tolerate compiler tokens in external specs
This commit is contained in:
parent
dc12cfde75
commit
4566ad9c2b
@ -2272,13 +2272,30 @@ def external_packages(self):
|
|||||||
warnings.warn(f"cannot use the external spec {spec}: needs a concrete version")
|
warnings.warn(f"cannot use the external spec {spec}: needs a concrete version")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
def external_requirement(input_spec, requirements):
|
||||||
|
result = []
|
||||||
|
for asp_fn in requirements:
|
||||||
|
if asp_fn.args[0] == "depends_on":
|
||||||
|
continue
|
||||||
|
if asp_fn.args[1] != input_spec.name:
|
||||||
|
continue
|
||||||
|
result.append(asp_fn)
|
||||||
|
return result
|
||||||
|
|
||||||
def external_imposition(input_spec, requirements):
|
def external_imposition(input_spec, requirements):
|
||||||
return requirements + [
|
result = []
|
||||||
fn.attr("external_conditions_hold", input_spec.name, local_idx)
|
for asp_fn in requirements:
|
||||||
]
|
if asp_fn.args[0] in ("depends_on", "build_requirement"):
|
||||||
|
continue
|
||||||
|
if asp_fn.args[1] != input_spec.name:
|
||||||
|
continue
|
||||||
|
result.append(asp_fn)
|
||||||
|
result.append(fn.attr("external_conditions_hold", input_spec.name, local_idx))
|
||||||
|
return result
|
||||||
|
|
||||||
try:
|
try:
|
||||||
context = ConditionContext()
|
context = ConditionContext()
|
||||||
|
context.transform_required = external_requirement
|
||||||
context.transform_imposed = external_imposition
|
context.transform_imposed = external_imposition
|
||||||
self.condition(spec, spec, msg=msg, context=context)
|
self.condition(spec, spec, msg=msg, context=context)
|
||||||
except (spack.error.SpecError, RuntimeError) as e:
|
except (spack.error.SpecError, RuntimeError) as e:
|
||||||
|
@ -3196,3 +3196,21 @@ def test_compiler_can_depend_on_themselves_to_build(config, mock_packages):
|
|||||||
|
|
||||||
gcc_used_to_build = s.dependencies(name="gcc", virtuals=("c",))
|
gcc_used_to_build = s.dependencies(name="gcc", virtuals=("c",))
|
||||||
assert len(gcc_used_to_build) == 1 and gcc_used_to_build[0].satisfies("gcc@9.4.0")
|
assert len(gcc_used_to_build) == 1 and gcc_used_to_build[0].satisfies("gcc@9.4.0")
|
||||||
|
|
||||||
|
|
||||||
|
def test_compiler_attribute_is_tolerated_in_externals(mutable_config, mock_packages, tmp_path):
|
||||||
|
"""Tests that we don't error out if an external specifies a compiler, even though externals
|
||||||
|
don't have dependencies.
|
||||||
|
"""
|
||||||
|
packages_yaml = syaml.load_config(
|
||||||
|
f"""
|
||||||
|
packages:
|
||||||
|
cmake:
|
||||||
|
externals:
|
||||||
|
- spec: "cmake@3.27.4 %gcc@14.1.0"
|
||||||
|
prefix: {tmp_path}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
mutable_config.set("packages", packages_yaml["packages"])
|
||||||
|
s = spack.concretize.concretize_one("cmake")
|
||||||
|
assert s.external and s.external_path == str(tmp_path)
|
||||||
|
Loading…
Reference in New Issue
Block a user