Skip to content

Commit

Permalink
Document the conan.tools.build.build_jobs() function (#2658)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaMozgunova committed Jul 27, 2022
1 parent 0384c39 commit 050f570
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions reference/conanfile/tools/build.rst
Expand Up @@ -98,3 +98,30 @@ Parameters:
- **conanfile**: The current recipe object. Always use ``self``.
- **compiler**: Name of the compiler e.g: gcc
- **compiler_version**: Version of the compiler e.g: 12


conan.tools.build.build_jobs()
------------------------------

.. code-block:: python
def build_jobs(conanfile):
Returns the number of CPUs available for parallel builds.
It returns the configuration value for ``tools.build:jobs`` if exists, otherwise,
it defaults to the helper function ``_cpu_count()``.
``_cpu_count()`` reads cgroup to detect the configured number of CPUs.
Currently, there are two versions of cgroup available.

In the case of cgroup v1, if the data in cgroup is invalid, processor detection comes into play.
Whenever processor detection is not enabled, ``build_jobs()`` will safely return 1.

In the case of cgroup v2, if no limit is set, processor detection is used. When the limit is set,
the behavior is as described in cgroup v1.


Parameters:

- **conanfile**: The current recipe object. Always use ``self``.

0 comments on commit 050f570

Please sign in to comment.