diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2022-04-05 02:37:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-04 17:37:57 -0700 |
commit | f2fc4ee9afcb1a159853b4037a8747949d65f7d9 (patch) | |
tree | f11fea6e5c5ec845c9cfe85ef416d5cbae150c38 /var | |
parent | d64de54ebe83853694e30e562b7f9edc996ccd2d (diff) | |
download | spack-f2fc4ee9afcb1a159853b4037a8747949d65f7d9.tar.gz spack-f2fc4ee9afcb1a159853b4037a8747949d65f7d9.tar.bz2 spack-f2fc4ee9afcb1a159853b4037a8747949d65f7d9.tar.xz spack-f2fc4ee9afcb1a159853b4037a8747949d65f7d9.zip |
Allow conditional possible values in variants (#29530)
Allow declaring possible values for variants with an associated condition. If the variant takes one of those values, the condition is imposed as a further constraint.
The idea of this PR is to implement part of the mechanisms needed for modeling [packages with multiple build-systems]( https://github.com/spack/seps/pull/3). After this PR the build-system directive can be implemented as:
```python
variant(
'build-system',
default='cmake',
values=(
'autotools',
conditional('cmake', when='@X.Y:')
),
description='...',
)
```
Modifications:
- [x] Allow conditional possible values in variants
- [x] Add a unit-test for the feature
- [x] Add documentation
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin.mock/packages/conditional-values-in-variant/package.py | 34 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/boost/package.py | 14 |
2 files changed, 41 insertions, 7 deletions
diff --git a/var/spack/repos/builtin.mock/packages/conditional-values-in-variant/package.py b/var/spack/repos/builtin.mock/packages/conditional-values-in-variant/package.py new file mode 100644 index 0000000000..74895cb7c0 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/conditional-values-in-variant/package.py @@ -0,0 +1,34 @@ +# Copyright 2013-2022 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) +class ConditionalValuesInVariant(Package): + """Package with conditional possible values in a variant""" + homepage = "https://dev.null" + + version('1.73.0') + version('1.72.0') + version('1.62.0') + version('1.60.0') + version('1.50.0') + + variant( + 'cxxstd', default='98', + values=( + '98', '11', '14', + # C++17 is not supported by Boost < 1.63.0. + conditional('17', when='@1.63.0:'), + # C++20/2a is not support by Boost < 1.73.0 + conditional('2a', when='@1.73.0:') + ), + multi=False, + description='Use the specified C++ standard when building.', + when='@1.60.0:' + ) + + variant( + 'staging', values=any_combination_of( + conditional('flexpath', 'dataspaces', when='@1.73.0:') + ), + description='Enable dataspaces and/or flexpath staging transports' + ) diff --git a/var/spack/repos/builtin/packages/boost/package.py b/var/spack/repos/builtin/packages/boost/package.py index 3b5e83813a..9ac8584288 100644 --- a/var/spack/repos/builtin/packages/boost/package.py +++ b/var/spack/repos/builtin/packages/boost/package.py @@ -140,7 +140,13 @@ class Boost(Package): variant('cxxstd', default='98', - values=('98', '11', '14', '17', '2a'), + values=( + '98', '11', '14', + # C++17 is not supported by Boost < 1.63.0. + conditional('17', when='@1.63.0:'), + # C++20/2a is not support by Boost < 1.73.0 + conditional('2a', when='@1.73.0:') + ), multi=False, description='Use the specified C++ standard when building.') variant('debug', default=False, @@ -193,12 +199,6 @@ class Boost(Package): conflicts('cxxstd=98', when='+fiber') # Fiber requires >=C++11. conflicts('~context', when='+fiber') # Fiber requires Context. - # C++20/2a is not support by Boost < 1.73.0 - conflicts('cxxstd=2a', when='@:1.72') - - # C++17 is not supported by Boost<1.63.0. - conflicts('cxxstd=17', when='@:1.62') - conflicts('+taggedlayout', when='+versionedlayout') conflicts('+numpy', when='~python') |