From fb475d3d89bea1e9ad977803d11f916494500e32 Mon Sep 17 00:00:00 2001 From: Luis Date: Tue, 28 Jun 2022 15:35:19 +0200 Subject: [PATCH] self.info.header_only() replaced with self.info.clear() --- .../define_abi_compatibility.rst | 8 +++--- extending/template_system/command_new.rst | 4 +-- howtos/header_only.rst | 4 +-- migrating_to_2.0/recipes.rst | 25 ++++++++++++++++--- reference/conanfile/methods.rst | 6 ++--- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/creating_packages/define_abi_compatibility.rst b/creating_packages/define_abi_compatibility.rst index d6c9d4f902b..c03a5a3f67e 100644 --- a/creating_packages/define_abi_compatibility.rst +++ b/creating_packages/define_abi_compatibility.rst @@ -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() @@ -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`` diff --git a/extending/template_system/command_new.rst b/extending/template_system/command_new.rst index 5cf77d90200..b2742b5915b 100644 --- a/extending/template_system/command_new.rst +++ b/extending/template_system/command_new.rst @@ -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 ------------------ @@ -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: diff --git a/howtos/header_only.rst b/howtos/header_only.rst index d61eb6dcecb..24598e548e7 100644 --- a/howtos/header_only.rst +++ b/howtos/header_only.rst @@ -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: @@ -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:: diff --git a/migrating_to_2.0/recipes.rst b/migrating_to_2.0/recipes.rst index cd7a4f82f8b..e7b66fb32ee 100644 --- a/migrating_to_2.0/recipes.rst +++ b/migrating_to_2.0/recipes.rst @@ -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 ------------------- @@ -289,7 +287,6 @@ to mimic the same behavior: Please **check the full example** on the :ref:`conan.tools.scm.Git section `. - The generate() method --------------------- @@ -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 diff --git a/reference/conanfile/methods.rst b/reference/conanfile/methods.rst index c6b9061966f..45aa4356bd6 100644 --- a/reference/conanfile/methods.rst +++ b/reference/conanfile/methods.rst @@ -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()