Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self.info.header_only() replaced with self.info.clear() #2612

Merged
merged 1 commit into from Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions creating_packages/define_abi_compatibility.rst
Expand Up @@ -693,7 +693,7 @@ as default in *conan.conf*, but if a recipe declare that it is header-only, with
.. code-block:: python

def package_id(self):
self.info.header_only() # clears requires, but also settings if existing
self.info.clear() # clears requires, but also settings if existing
# or if there are no settings/options, this would be equivalent
self.info.requires.clear() # or self.info.requires.unrelated_mode()

Expand Down Expand Up @@ -734,17 +734,17 @@ Enabling full transitivity in package_id modes


When a package declares in its ``package_id()`` method that it is not affected by its dependencies, that will propagate down
to the indirect consumers of that package. There are several ways this can be done, ``self.info.header_only()``, ``self.info.requires.clear()``,
to the indirect consumers of that package. There are several ways this can be done, ``self.info.clear()``, ``self.info.requires.clear()``,
``self.info.requires.remove["dep"]`` and ``self.info.requires.unrelated_mode()``, for example.

Let's assume for the discussion that it is a header only library, using the ``self.info.header_only()`` helper. This header only package has
Let's assume for the discussion that it is a header only library, using the ``self.info.clear()`` helper. This header only package has
a single dependency, which is a static library. Then, downstream
consumers of the header only library that uses a package mode different from the default, should be also affected by the upstream
transitivity dependency. Lets say that we have the following scenario:

- ``app/1.0`` depends on ``pkgc/1.0`` and ``pkga/1.0``
- ``pkgc/1.0`` depends only on ``pkgb/1.0``
- ``pkgb/1.0`` depends on ``pkga/1.0``, and defines ``self.info.header_only()`` in its ``package_id()``
- ``pkgb/1.0`` depends on ``pkga/1.0``, and defines ``self.info.clear()`` in its ``package_id()``
- We are using ``full_version_mode``
- Now we create a new ``pkga/2.0`` that has some changes in its header, that would require to rebuild ``pkgc/1.0`` against it.
- ``app/1.0`` now depends on ```pkgc/1.0`` and ``pkga/2.0``
Expand Down
4 changes: 2 additions & 2 deletions extending/template_system/command_new.rst
Expand Up @@ -95,7 +95,7 @@ This is a very simple example for a header only library:
self.copy("LICENSE.txt", dst="licenses")

def package_id(self):
self.info.header_only()
self.info.clear()

Custom definitions
------------------
Expand Down Expand Up @@ -123,7 +123,7 @@ it's desired to have ``description`` and ``homepage`` to be templated as well:
self.copy("LICENSE.txt", dst="licenses")

def package_id(self):
self.info.header_only()
self.info.clear()

With the above template it's now easy to overwrite such extra keywords with values from the command line:

Expand Down
4 changes: 2 additions & 2 deletions howtos/header_only.rst
Expand Up @@ -39,7 +39,7 @@ instead of the ``exports_sources`` fields.
.. code-block:: python

def package_id(self):
self.info.header_only()
self.info.clear()

Package is created with:

Expand Down Expand Up @@ -73,7 +73,7 @@ If you want to run the library unit test while packaging, you would need this re
self.copy("*.h")

def package_id(self):
self.info.header_only()
self.info.clear()


.. tip::
Expand Down
25 changes: 22 additions & 3 deletions migrating_to_2.0/recipes.rst
Expand Up @@ -140,8 +140,6 @@ The definition of the ``default_options`` attribute has changed when referring t
default_options = {"pkg/*:some_option": "value"}




The layout() method
-------------------

Expand Down Expand Up @@ -289,7 +287,6 @@ to mimic the same behavior:
Please **check the full example** on the :ref:`conan.tools.scm.Git section <conan_tools_scm_git>`.



The generate() method
---------------------

Expand Down Expand Up @@ -533,6 +530,28 @@ To be prepared for Conan 2.0:
- Instead of appending new values to the default list, assign it: ``self.cpp_info.builddirs = ["cmake"]``


The package_id() method
-----------------------

The ``self.info.header_only()`` method has been replaced with ``self.info.clear()``


.. code-block:: python
:caption: **From:**

def package_id(self):
self.info.header_only()


.. code-block:: python
:caption: **To:**

def package_id(self):
self.info.clear()




.. _conanv2_properties_model:

New properties model
Expand Down
6 changes: 3 additions & 3 deletions reference/conanfile/methods.rst
Expand Up @@ -984,15 +984,15 @@ any setting or option:
del self.info.settings.compiler
del self.info.options.shared

self.info.header_only()
^^^^^^^^^^^^^^^^^^^^^^^
self.info.clear()
^^^^^^^^^^^^^^^^^

The package will always be the same, irrespective of the settings (OS, compiler or architecture), options and dependencies.

.. code-block:: python

def package_id(self):
self.info.header_only()
self.info.clear()


self.info.shared_library_package_id()
Expand Down