Skip to content

Commit 3a934a2

Browse files
memshardedAbrilRBS
andauthored
languages and cstd support (#3757)
* languages and cstd support * Update reference/extensions/profile_plugin.rst Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es> --------- Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
1 parent 920bcf3 commit 3a934a2

File tree

6 files changed

+91
-4
lines changed

6 files changed

+91
-4
lines changed

reference/conanfile/attributes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ extension_properties
237237
The ``extensions_properties`` attribute is a dictionary intended to define and pass information from the
238238
recipes to the Conan extensions.
239239

240-
At the moment, the only defined property is ``compatibility_cppstd``, that allows disabling the behavior
240+
At the moment, the only defined properties are ``compatibility_cppstd`` and ``compatibility_cstd``, that allows disabling the behavior
241241
of :ref:`the default compatibility.py extension <reference_extensions_binary_compatibility>`, that considers
242-
binaries built with different ``compiler.cppstd`` values ABI-compatible among them.
242+
binaries built with different ``compiler.cppstd`` and ``compiler.cstd`` values ABI-compatible among them.
243243
To disable this behavior for the current package, it is possible to do it with:
244244

245245
.. code-block:: python

reference/conanfile/attributes/binary_model.inc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,33 @@ For example:
331331
"option2": "Describe the purpose and functionality of 'option2'. ",
332332
}
333333
334+
languages
335+
---------
336+
337+
.. include:: ../../common/experimental_warning.inc
338+
339+
340+
From Conan 2.4, the ``conanfile.py`` recipe attribute ``languages`` can be used to define the programming languages
341+
involved in this package. At the moment the ``C`` and ``C++`` languages are the possible values. For example a
342+
pure C package would define something as:
343+
344+
.. code-block:: python
345+
346+
class ZLib(ConanFile):
347+
languages = "C"
348+
349+
350+
It is possible to define more than one language, for example ``languages = "C", "C++"`` is the correct definition when
351+
a package is built from both C and C++ sources.
352+
353+
Regarding ``languages`` definition, the following will happen:
354+
355+
- If no ``languages`` is defined or ``C`` is not a declared language, ``compiler.cstd`` subsetting will be automatically removed
356+
at package ``configure()`` time (to achieve backward compatibility).
357+
- If ``languages`` is defined, but it doesn't contain ``C++``, ``compiler.cppstd`` and ``compiler.libcxx`` subsettings will be
358+
automatically removed at package ``configure()`` time.
359+
360+
334361
info
335362
----
336363

reference/conanfile/methods/configure.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ recipe to remove them so they are not used in the recipe:
2929
# No need to delete those settings here, they were already deleted
3030
pass
3131
32+
.. note::
33+
34+
From Conan 2.4, the above ``configure()`` is not necessary if defined ``languages = "C"`` recipe
35+
attribute (experimental).
36+
37+
3238
For packages where you want to remove every subsetting of a setting, you can use the ``rm_safe`` method
3339
with a wildcard:
3440

reference/extensions/binary_compatibility.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ The following would be valid syntax (but not an useful or working one, as it wil
2424
2525
2626
Conan provides a default ``compatibility.py`` implementation that implements binary compatibility for
27-
different ``compiler.cppstd`` values. That is, by default it assumes that binaries built with different ``cppstd``
28-
values (for the same compiler and compiler version) are binary compatible, and can be linked together
27+
different ``compiler.cppstd`` and ``compiler.cstd`` values. That is, by default it assumes that binaries built with different ``cppstd``
28+
and ``cstd`` values (for the same compiler and compiler version) are binary compatible, and can be linked together
2929
without issues.
3030

3131
The ``compiler.cppstd`` must be defined in profiles in most C++ scenarios. If a binary for a given
@@ -35,6 +35,9 @@ It is possible to disable this behavior for any specific package, adding to the
3535
recipe the ``extension_properties = {"compatibility_cppstd": False}`` attribute, read the
3636
:ref:`extension_properties docs<conan_conanfile_attributes_extension_properties>`.
3737

38+
From Conan 2.4, the ``compiler.cstd`` setting is available. It will only be taken into account in the computation of
39+
packages ``package_id`` when their recipes explicitly declare the ``languages = "C"`` attribute.
40+
3841
Some important rules:
3942

4043
- The built-in ``compatibility.py`` is subject to changes in future releases. To avoid being updated

reference/extensions/profile_plugin.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This ``profile.py`` contains a default implementation that does:
1414
That allow users to let it undefined in profiles, and switch it conveniently in command line just with ``-s build_type=Debug``
1515
- Will check the ``compiler.cppstd`` value if defined to validate if the current compiler version has support for it. For example, if a developer
1616
tries to use ``-s compiler=gcc -s compiler.version=5 -s compiler.cppstd=20``, it will raise an error.
17+
- Even though the ``profile.py`` plugin has some provision to handle ``compiler.cstd`` checks, they are not implemented yet, so the plugin will be permissive
18+
regarding definition errors, please make sure the ``compiler.cstd`` is actually supported by your compiler version.
1719

1820

1921

reference/tools/build.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,52 @@ conan.tools.build.cppstd_flag()
9696
.. currentmodule:: conan.tools.build.flags
9797

9898
.. autofunction:: cppstd_flag
99+
100+
101+
cstd
102+
^^^^
103+
104+
.. include:: ../../common/experimental_warning.inc
105+
106+
.. _conan_tools_build_check_min_cstd:
107+
108+
conan.tools.build.check_min_cstd()
109+
""""""""""""""""""""""""""""""""""""
110+
111+
.. currentmodule:: conan.tools.build.cstd
112+
113+
.. autofunction:: check_min_cstd
114+
115+
116+
.. _conan_tools_build_check_max_cstd:
117+
118+
conan.tools.build.check_max_cstd()
119+
""""""""""""""""""""""""""""""""""""
120+
121+
.. currentmodule:: conan.tools.build.cstd
122+
123+
.. autofunction:: check_max_cstd
124+
125+
126+
conan.tools.build.valid_min_cstd()
127+
""""""""""""""""""""""""""""""""""""
128+
129+
.. currentmodule:: conan.tools.build.cstd
130+
131+
.. autofunction:: valid_min_cstd
132+
133+
134+
conan.tools.build.valid_max_cstd()
135+
""""""""""""""""""""""""""""""""""""
136+
137+
.. currentmodule:: conan.tools.build.cstd
138+
139+
.. autofunction:: valid_max_cstd
140+
141+
142+
conan.tools.build.supported_cstd()
143+
""""""""""""""""""""""""""""""""""""
144+
145+
.. currentmodule:: conan.tools.build.cstd
146+
147+
.. autofunction:: supported_cstd

0 commit comments

Comments
 (0)