diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2023-05-08 19:12:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-08 10:12:26 -0700 |
commit | 0139288ced598cb45c4d947473f1d886b603607b (patch) | |
tree | f1f565b7e77b496b09f3429493e0affd9160d9b4 /var/spack/repos/builtin.mock | |
parent | d0cba2bf35f347a5ca09163f8b93ba9788f46ba1 (diff) | |
download | spack-0139288ced598cb45c4d947473f1d886b603607b.tar.gz spack-0139288ced598cb45c4d947473f1d886b603607b.tar.bz2 spack-0139288ced598cb45c4d947473f1d886b603607b.tar.xz spack-0139288ced598cb45c4d947473f1d886b603607b.zip |
Add a "requires" directive, extend functionality of package requirements (#36286)
Add a "require" directive to packages, which functions exactly like
requirements specified in packages.yaml (uses the same fact-generation
logic); update both to allow making the requirement conditional.
* Packages may now use "require" to add constraints. This can be useful
for something like "require(%gcc)" (where before we had to add a
conflict for every compiler except gcc).
* Requirements (in packages.yaml or in a "require" directive) can be
conditional on a spec, e.g. "require(%gcc, when=@1.0.0)" (version
1.0.0 can only build with gcc).
* Requirements may include a message which clarifies why they are needed.
The concretizer assigns a high priority to errors which generate these
messages (in particular over errors for unsatisfied requirements that
do not produce messages, but also over a number of more-generic
errors).
Diffstat (limited to 'var/spack/repos/builtin.mock')
-rw-r--r-- | var/spack/repos/builtin.mock/packages/requires_clang/package.py | 18 | ||||
-rw-r--r-- | var/spack/repos/builtin.mock/packages/requires_clang_or_gcc/package.py | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/var/spack/repos/builtin.mock/packages/requires_clang/package.py b/var/spack/repos/builtin.mock/packages/requires_clang/package.py new file mode 100644 index 0000000000..9f1c2d0ba4 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/requires_clang/package.py @@ -0,0 +1,18 @@ +# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import * + + +class RequiresClang(Package): + """Simple package with no dependencies""" + + homepage = "http://www.example.com" + url = "http://www.example.com/b-1.0.tar.gz" + + version("1.0", md5="0123456789abcdef0123456789abcdef") + version("0.9", md5="abcd456789abcdef0123456789abcdef") + + requires("%clang", msg="can only be compiled with Clang") diff --git a/var/spack/repos/builtin.mock/packages/requires_clang_or_gcc/package.py b/var/spack/repos/builtin.mock/packages/requires_clang_or_gcc/package.py new file mode 100644 index 0000000000..18f924e92f --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/requires_clang_or_gcc/package.py @@ -0,0 +1,18 @@ +# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack.package import * + + +class RequiresClangOrGcc(Package): + """Simple package with no dependencies""" + + homepage = "http://www.example.com" + url = "http://www.example.com/b-1.0.tar.gz" + + version("1.0", md5="0123456789abcdef0123456789abcdef") + version("0.9", md5="abcd456789abcdef0123456789abcdef") + + requires("%gcc", "%clang", policy="one_of") |