Make _enable_or_disable(...) return an empty array for conditional variants whose condition is not met (#27504)

This commit is contained in:
Harmen Stoppels
2021-11-22 10:47:09 +01:00
committed by GitHub
parent cda9d6d981
commit 0024e5cc9b
4 changed files with 43 additions and 0 deletions

View File

@@ -420,6 +420,24 @@ Or when one variant controls multiple flags:
config_args += self.with_or_without('memchecker', variant='debug_tools')
config_args += self.with_or_without('profiler', variant='debug_tools')
""""""""""""""""""""
Conditional variants
""""""""""""""""""""
When a variant is conditional and its condition is not met on the concrete spec, the
``with_or_without`` and ``enable_or_disable`` methods will simply return an empty list.
For example:
.. code-block:: python
variant('profiler', when='@2.0:')
config_args += self.with_or_without('profiler)
will neither add ``--with-profiler`` nor ``--without-profiler`` when the version is
below ``2.0``.
""""""""""""""""""""
Activation overrides
""""""""""""""""""""