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
compatible_pkg.settings.compiler.version = version
196
196
self.compatible_packages.append(compatible_pkg)
197
197
198
198
Note that if the input configuration is ``gcc 4.8``, it will not try to fallback to binaries of ``gcc 4.7`` as the
199
199
condition is not met.
200
200
201
-
The ``CompatiblePackage()`` copies the values of ``settings``, ``options`` and ``requires`` from the current instance of the recipe so they can be modified to model the compatibility.
201
+
The ``self.info.clone()`` method copies the values of ``settings``, ``options`` and ``requires`` from the current instance of
202
+
the recipe so they can be modified to model the compatibility.
202
203
203
204
It is the responsibility of the developer to guarantee that such binaries are indeed compatible. For example in:
204
205
@@ -211,7 +212,7 @@ It is the responsibility of the developer to guarantee that such binaries are in
211
212
default_options = {"optimized": 1}
212
213
defpackage_id(self):
213
214
for optimized inrange(int(self.options.optimized), 0, -1):
214
-
compatible_pkg =CompatiblePackage(self)
215
+
compatible_pkg =self.info.clone()
215
216
compatible_pkg.options.optimized = optimized
216
217
self.compatible_packages.append(compatible_pkg)
217
218
@@ -226,6 +227,88 @@ the ``optimized`` option to conditionally require different dependencies, that w
226
227
step is processed after the whole dependency graph has been built, so it is not possible to define how dependencies are resolved
227
228
based on this compatibility model, it only applies to use-cases where the binaries can be *interchanged*.
228
229
230
+
Check the :ref:`Compatible Compilers<compatible_compilers>` section to see another example of how to take benefit of compatible packages.
231
+
232
+
233
+
.. _compatible_compilers:
234
+
235
+
Compatible Compilers
236
+
--------------------
237
+
238
+
Some compilers make use of a base compiler to operate, for example, the ``intel`` compiler uses
239
+
the ``Visual Studio`` compiler in Windows environments and ``gcc`` in Linux environments.
240
+
241
+
The ``intel`` compiler is declared this way in the :ref:`settings.yml<settings_yml>`:
Remember, you can :ref:`extend Conan<extending>` to support other compilers.
256
+
257
+
258
+
You can use the ``package_id()`` method to define the compatibility between the packages generated by the ``base`` compiler and the ``parent`` one.
259
+
You can use the following helpers together with the :ref:`compatible packages<compatible_packages>` feature to:
260
+
261
+
- Consume native ``Visual Studio`` packages when the input compiler in the profile is ``intel`` (if no ``intel`` package is available).
262
+
- The opposite, consume an ``intel`` compiler package when a consumer profile specifies ``Visual Studio`` as the input compiler (if no
263
+
``Visual Studio`` package is available).
264
+
265
+
- ``base_compatible()``: This function will transform the settings used to calculate the package ID into the "base" compiler.
266
+
267
+
.. code-block:: python
268
+
269
+
defpackage_id(self):
270
+
271
+
ifself.settings.compiler =="intel":
272
+
p =self.info.clone()
273
+
p.base_compatible()
274
+
self.compatible_packages.append(p)
275
+
276
+
Using the above ``package_id()`` method, if a consumer specifies a profile with a intel profile (**-s compiler=="intel"**) and there is no binary available, it will resolve to a
277
+
Visual Studio package ID corresponding to the base compiler.
278
+
279
+
280
+
- ``parent_compatible(compiler="compiler", version="version")``: This function transforms the settings of a compiler into the settings of a
281
+
parent one using the specified one as the base compiler. As the details of the "parent" compatible cannot be guessed, you have to provide them as **keyword args** to the
282
+
function. The "compiler" argument is mandatory, the rest of keyword arguments will be used to initialize the ``info.settings.compiler.XXX`` objects
0 commit comments