Skip to content

Commit 1082bd3

Browse files
authored
document conanfile.context attribute (#4321)
1 parent 1ce982d commit 1082bd3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

reference/conanfile/attributes/binary_model.inc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,24 @@ The 4 different attributes are:
430430
.. seealso::
431431

432432
Read the :ref:`binary model reference<reference_binary_model>` for a full view of the Conan binary model.
433+
434+
435+
context
436+
-------
437+
438+
.. include:: ../../common/experimental_warning.inc
439+
440+
441+
The ``conanfile.py`` recipe attribute ``context`` will contain either the "build" or "host" value to represent the context where
442+
the current package instance is being evaluated. Recall that it is possible that some recipes might exist both in the "build" and "host"
443+
contexts, depending on the usage.
444+
445+
This attribute shouldn't be necessary for the vast majority of cases, so it is recommended to avoid using it.
446+
One potential exception for this recommendation would be to break otherwise infinite dependency cycles, defining
447+
some conditional dependency as:
448+
449+
.. code-block:: python
450+
451+
def requirements(self):
452+
if self.context == "host":
453+
self.tool_requires("mytool/1.0")

0 commit comments

Comments
 (0)