Skip to content

Commit e0373da

Browse files
memshardedczoido
authored andcommitted
Review for multiple missing items (#4065)
* adding proxies confs information * adding information of CMakeToolchain find_paths block * deployer-package negations * adding system_requirements() section for build-time * clarify auto_generate=True argument for VirtualBuildEnv * add package-type for header-only libraries * adding transitive_headers in the tutorial
1 parent 79cc1b7 commit e0373da

File tree

9 files changed

+158
-35
lines changed

9 files changed

+158
-35
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Documentation for Conan C/C++ package manager: https://conan.io
22

3-
[![Build Status](https://travis-ci.org/conan-io/docs.svg?branch=master)](https://travis-ci.org/conan-io/docs)
4-
53
How to build
64
============
75

reference/commands/install.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,11 @@ It is possible to also invoke the package recipes ``deploy()`` method with the `
145145
.. code-block:: bash
146146
147147
# Execute deploy() method of every recipe that defines it
148-
$ conan install --requires=pkg/0.1 --deployer-package=*
148+
$ conan install --requires=pkg/0.1 --deployer-package="*"
149149
# Execute deploy() method only for "pkg" (any version) recipes
150-
$ conan install --requires=pkg/0.1 --deployer-package=pkg/*
150+
$ conan install --requires=pkg/0.1 --deployer-package="pkg/*"
151+
# Execute deploy() method for all packages except the "zlib" (transitive dep) one
152+
$ conan install --requires=pkg/0.1 --deployer-package="*" --deployer-package="~zlib/*"
151153
152154
The ``--deployer-package`` argument is a pattern and accepts multiple values, all package references matching any of the defined patterns will execute its ``deploy()`` method.
153155
This includes negated patterns, where for example ``--deployer-package=~pkg/*`` will execute the ``deploy()`` method for all packages except for that of the ``pkg`` recipe.

reference/conanfile/methods/requirements.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ when we want to use different versions of the same package during the build.
8888
transitive_headers
8989
~~~~~~~~~~~~~~~~~~
9090

91-
If ``True`` the headers of the dependency will be visible downstream.
91+
If ``True`` the headers of the dependency will be visible downstream.
92+
Read more about this trait in the :ref:`tutorial for headers transitivity<tutorial_create_packages_headers_transitivity>`.
9293

9394
transitive_libs
9495
~~~~~~~~~~~~~~~

reference/conanfile/methods/system_requirements.rst

+14
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,17 @@ On the other hand, the ``report-installed`` mode will do a check if the package
101101
]
102102
}
103103
}
104+
105+
106+
Build time system requirements
107+
------------------------------
108+
109+
In some scenarios, it might be possible that some system-requirements are only necessary exclusively at
110+
build time. For those scenarios, there are 2 possibilities:
111+
112+
- Add the logic that install the build-time system requirements in a different method, like the ``build()``
113+
method or the ``generate()`` method.
114+
- Wrap the installation and logic for the build-time system requirement in its own package recipe, and use
115+
that recipe as a ``tool_requires``.
116+
117+
There are examples :ref:`for build-time system requirements in this section <examples_tools_system_consuming_system_packages>`

reference/config_files/global_conf.rst

+59-30
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,6 @@ To list all the possible configurations available, run :command:`conan config li
3333
:command: conan config list
3434

3535

36-
Description of configurations
37-
+++++++++++++++++++++++++++++
38-
39-
core.cache:storage_path
40-
^^^^^^^^^^^^^^^^^^^^^^^
41-
42-
Absolute path to a folder where the Conan packages and the database of the packages will be stored.
43-
This folder will be the heaviest Conan storage folder, as it stores the binary packages downloaded or created.
44-
45-
.. code-block:: text
46-
:caption: *global.conf*
47-
48-
core.cache:storage_path = C:\Users\danielm\my_conan_storage_folder
49-
50-
**Default value:** ``<CONAN_HOME>/p``
51-
52-
core.download:download_cache
53-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54-
55-
Absolute path to a folder where the Conan packages will be stored *compressed*.
56-
This is useful to avoid recurrent downloads of the same packages, especially in CI.
57-
58-
.. code-block:: text
59-
:caption: *global.conf*
60-
61-
core.download:download_cache = C:\Users\danielm\my_download_cache
62-
63-
**Default value:** Not defined.
64-
65-
6636
User/Tools configurations
6737
-------------------------
6838

@@ -244,6 +214,65 @@ For instance:
244214
(And even then, properly scoping the conf to only the required recipes is a good idea)
245215
or if you are using it for development purposes
246216

217+
Proxies
218+
+++++++
219+
220+
There are 3 ``confs`` that can define proxies information:
221+
222+
.. code-block:: bash
223+
224+
$ conan config list proxies
225+
core.net.http:clean_system_proxy: If defined, the proxies system env-vars will be discarded
226+
core.net.http:no_proxy_match: List of urls to skip from proxies configuration
227+
core.net.http:proxies: Dictionary containing the proxy configuration
228+
229+
The ``core.net.http:proxies`` dictionary is passed to the underlying ``python-requests`` library, to the "proxies" argument
230+
as described in the `python-requests documentation <https://requests.readthedocs.io/en/latest/user/advanced/#proxies>`_
231+
232+
The ``core.net:no_proxy_match`` is a list of URL patterns, like:
233+
234+
.. code-block:: ini
235+
236+
core.net.http:no_proxy_match = ["http://someurl.com/*"]
237+
238+
239+
for URLs to be excluded from the ``proxies`` configuration. That means that all URLs that are referenced that matches any
240+
of those patterns will not receive the ``proxies`` definition. Note the ``*`` in the pattern is necessary for the match.
241+
242+
If ``core.net.http:clean_system_proxy`` is ``True``, then the environment variables ``"http_proxy", "https_proxy", "ftp_proxy", "all_proxy", "no_proxy"``,
243+
will be temporary removed from the environment, so they are not taken into account when resolving proxies.
244+
245+
246+
247+
Storage configurations
248+
----------------------
249+
250+
core.cache:storage_path
251+
+++++++++++++++++++++++
252+
253+
Absolute path to a folder where the Conan packages and the database of the packages will be stored.
254+
This folder will be the heaviest Conan storage folder, as it stores the binary packages downloaded or created.
255+
256+
.. code-block:: text
257+
:caption: *global.conf*
258+
259+
core.cache:storage_path = C:\Users\danielm\my_conan_storage_folder
260+
261+
**Default value:** ``<CONAN_HOME>/p``
262+
263+
core.download:download_cache
264+
++++++++++++++++++++++++++++
265+
266+
Absolute path to a folder where the Conan packages will be stored *compressed*.
267+
This is useful to avoid recurrent downloads of the same packages, especially in CI.
268+
269+
.. code-block:: text
270+
:caption: *global.conf*
271+
272+
core.download:download_cache = C:\Users\danielm\my_download_cache
273+
274+
**Default value:** Not defined.
275+
247276

248277
UX confs
249278
--------

reference/tools/cmake/cmaketoolchain.rst

+14
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,20 @@ dependencies can be found. For this case, it should be possible to do something
638638
639639
For more information about these blocks, please have a look at the source code.
640640

641+
Finding dependencies paths
642+
--------------------------
643+
644+
The generated ``conan_toolchain.cmake`` contains information in its ``find_paths`` block for variables such as
645+
``CMAKE_PROGRAM_PATH``, ``CMAKE_LIBRARY_PATH``, ``CMAKE_INCLUDE_PATH`` and others, that allow CMake to run
646+
``find_program()``, ``find_file()`` and other special "finder" routines that find artifacts without a explicit
647+
package and targets definition via the overall recommended ``find_package()``.
648+
649+
With the new incubating ``CMakeConfigDeps``, the ``conan_toolchain.cmake`` block ``find_paths`` no longer
650+
defines the information itself, but it just loads a new file generated by the ``CMakeConfigDeps`` generator, the
651+
``conan_cmakedeps_paths.cmake`` file. This way, the responsibility for creating information about dependencies is
652+
the ``CMakeConfigDeps`` generator, and that new file can be used in some scenarios in which passing a toolchain
653+
is not possible.
654+
641655

642656
Cross building
643657
--------------

reference/tools/env/virtualbuildenv.rst

+24
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,30 @@ And it can also be fully instantiated in the conanfile ``generate()`` method:
4242
ms.generate()
4343
4444
45+
Note that instantiating the ``VirtualBuildEnv()`` generator without later calling the ``generate()`` method,
46+
which is intended only for the ``generate()`` recipe method, will inhibit the creation of environment files.
47+
48+
So something like:
49+
50+
.. code-block:: python
51+
52+
ms = VirtualBuildEnv(self)
53+
my_env_var = ms.vars().get("MY_ENV_VAR")
54+
# does not create conanbuildenv.sh|.bat files
55+
56+
57+
will stop creating the ``conanbuild.sh|.bat`` and ``conanbuildenv.sh|.bat`` files that are created by default,
58+
even when ``VirtualBuildEnv`` is not instantiated.
59+
60+
In order to keep creating those files, the ``auto_generate=True`` argument can be passed to the constructor, as:
61+
62+
.. code-block:: python
63+
64+
ms = VirtualBuildEnv(self, auto_generate=True)
65+
my_env_var = ms.vars().get("MY_ENV_VAR")
66+
# does create conanbuildenv.sh|.bat files
67+
68+
4569
4670
Generated files
4771
---------------

tutorial/creating_packages/add_dependencies_to_packages.rst

+37
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,43 @@ colour now:
117117
hello/1.0: __clang_minor__ 1
118118
hello/1.0: __apple_build_version__ 13160021
119119
120+
.. _tutorial_create_packages_headers_transitivity:
121+
122+
Headers transitivity
123+
--------------------
124+
125+
By default, Conan assumes that the required dependency headers are an implementation detail of the current package,
126+
to promote good software engineering practices like low coupling and encapsulation. In the example above, ``fmt``
127+
is purely an implementation detail in the ``hello/1.0`` package. Consumers of ``hello/1.0`` will not know anything
128+
about ``fmt``, or has access to its headers, if a consumer of ``hello/1.0`` would try to add a ``#include <fmt/color.h>``,
129+
it will fail, not being able to find that headers.
130+
131+
But if the public headers of the ``hello/1.0`` package have the ``#include`` to ``fmt`` headers, that means that such
132+
headers must be propagated down to allow consumers of ``hello/1.0`` to be compiled successfully. As this is not the
133+
default expected behavior, recipes must declare it as:
134+
135+
.. code-block:: python
136+
137+
class helloRecipe(ConanFile):
138+
name = "hello"
139+
version = "1.0"
140+
141+
def requirements(self):
142+
self.requires("fmt/8.1.1", transitive_headers=True)
143+
144+
145+
That will propagate the necessary compilation flags and headers ``includedirs`` to the consumers of ``hello/1.0``.
146+
147+
.. note::
148+
149+
**Best practices**
150+
151+
If a consumer of ``hello/1.0`` had a direct inclusion to ``fmt`` headers such as ``#include <fmt/color.h>``, then,
152+
such a consumer should declare its own ``self.requires("fmt/8.1.1")`` requirement, as that is a direct requirement.
153+
In other words, even if the dependency to ``hello/1.0`` was removed from that consumer, it would still depend on ``fmt``,
154+
and consequently it cannot abouse the transitivity of the ``fmt`` headers from ``hello``, but declare them explicitly.
155+
156+
120157
.. seealso::
121158

122159
- :ref:`Reference for requirements() method <reference_conanfile_methods_requirements>`.

tutorial/creating_packages/other_types_of_packages/header_only_packages.rst

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ This is a basic recipe for a header-only recipe:
3939
exports_sources = "include/*"
4040
# We can avoid copying the sources to the build folder in the cache
4141
no_copy_source = True
42+
# Important, define the package_type
43+
package_type = "header-library"
4244
4345
def package(self):
4446
# This will also copy the "include" folder
@@ -160,6 +162,8 @@ We have the same header-only library that sums two numbers, but now we have this
160162
exports_sources = "include/*", "test/*"
161163
no_copy_source = True
162164
generators = "CMakeToolchain", "CMakeDeps"
165+
# Important, define the package_type
166+
package_type = "header-library"
163167
164168
def requirements(self):
165169
self.test_requires("gtest/1.11.0")

0 commit comments

Comments
 (0)