You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, the ``workspace_packages.items()`` iteration will be able to call every package in the workspace ``configure_toolchain()`` and
187
+
collect all their behavior in the current super-build ``CMakeToolchain``. The resulting toolchain will contain the definitions for
188
+
``SOME_PKGB_DEFINE=2.3.4`` and ``PKGA_SOME_DEFINITION=1.2.3``.
189
+
190
+
.. warning::
191
+
192
+
**Important**
193
+
194
+
The access of ``workspace_packages`` to the workspace packages ``ConanFiles`` must be **read-only** and **pure**. It cannot modify
195
+
the workspace ``pkga`` and ``pkgb`` packages data, and it cannot have any side effect. For example it is forbidden to call any method such as ``.build()``
196
+
or even the ``.generate()`` method.
197
+
If there is logic to be reused, it is the responsibility of the developer to define some convention, such as the ``configure_toolchain()``
198
+
method that if called from the ``conanws.py`` will not modify at all (pure) the ``pkga`` or ``pkgb`` data.
199
+
82
200
83
201
conanws.py super-build options
84
202
++++++++++++++++++++++++++++++
85
203
204
+
A particular case of the above ``workspace_packages`` access could be reading the individual workspace packages options.
86
205
A ``conanws.py`` used for a super-build workspaces file can manage options in two different ways:
87
206
88
207
- It can define its own ``options`` with the normal ``conanfile.py`` syntax, so the generated ``conan_toolchain.cmake`` for the super-project uses those inputs.
89
-
- It can collect the options of the workspace's packages with the ``workspace_packages_options`` and process them in any user-custom way.
208
+
- It can collect the options of the workspace's packages with the ``workspace_packages`` and process them in any user-custom way.
90
209
91
210
92
211
**super-project options**
@@ -117,9 +236,10 @@ Then, options can be provided with the usual syntax, via profiles or command lin
117
236
118
237
Note there can be overlap with the ``options`` defined in the workspace packages, as for super-projects those options are simply ignored, and only the options of the super-project are taken into account to generate the ``conan_toolchain.cmake``. For example, the ``conanws.py`` can define a ``shared`` option if it is desired that the ``conan_toolchain.cmake`` will correctly define ``BUILD_SHARED_LIBS`` or not when defining something like ``-o "*:shared=True"``, as the workspace packages having the ``shared`` option information is discarded when the workspace packages are collapsed in the dependency graph to model the super-project.
119
238
239
+
120
240
**packages options**
121
241
122
-
The second alternative is to collect the ``options`` of the workspace packages that have been collapsed. Recall that in the final dependency graph, the workspace packages are no longer represented, as they are no longer individual packages but part as the current super-build. The way to access their options information is via the ``workspace_packages_options``, and that information can be used in the ``generate()`` method to do any desired action at the super-build project level.
242
+
The second alternative is to collect the ``options`` of the workspace packages that have been collapsed. Recall that in the final dependency graph, the workspace packages are no longer represented, as they are no longer individual packages but part as the current super-build. The way to access their options information is via the ``workspace_packages``, and that information can be used in the ``generate()`` method to do any desired action at the super-build project level.
123
243
124
244
125
245
So let's say that a workspace containing a ``dep/0.1`` package that contains the standard ``shared`` options defines the following super-build ``ConanFile``:
@@ -130,9 +250,9 @@ So let's say that a workspace containing a ``dep/0.1`` package that contains the
130
250
131
251
classMyWs(ConanFile):
132
252
defgenerate(self):
133
-
for pkg, optionsinself.workspace_packages_options.items():
134
-
for k, v in options.items():
135
-
self.output.info(f"Generating with opt {pkg}:{k}={v}!!!!")
253
+
for pkg, depinself.workspace_packages.items():
254
+
for k, v indep.options.items():
255
+
self.output.info(f"Generating with opt {pkg}:{k}={v}!!!!")
0 commit comments