conan.tools.build¶
Building¶
conan.tools.build.build_jobs()¶
- 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
.- Returns:
int
with the number of jobs
conan.tools.build.cross_building()¶
- cross_building(conanfile=None, skip_x64_x86=False)¶
Check if we are cross building comparing the build and host settings. Returns
True
in the case that we are cross-building.- Parameters:
conanfile – The current recipe object. Always use
self
.skip_x64_x86 – Do not consider cross building when building to 32 bits from 64 bits: x86_64 to x86, sparcv9 to sparc or ppc64 to ppc32
- Returns:
bool
value fromtools.build.cross_building:cross_build
if exists, otherwise, it returnsTrue
if we are cross-building, else,False
.
conan.tools.build.can_run()¶
- can_run(conanfile)¶
Validates whether is possible to run a non-native app on the same architecture. It’s a useful feature for the case your architecture can run more than one target. For instance, Mac M1 machines can run both armv8 and x86_64.
- Parameters:
conanfile – The current recipe object. Always use
self
.- Returns:
bool
value fromtools.build.cross_building:can_run
if exists, otherwise, it returnsFalse
if we are cross-building, else,True
.
Cppstd¶
conan.tools.build.check_min_cppstd()¶
- check_min_cppstd(conanfile, cppstd, gnu_extensions=False)¶
Check if current cppstd fits the minimal version required.
In case the current cppstd doesn’t fit the minimal version required by cppstd, a ConanInvalidConfiguration exception will be raised.
If settings.compiler.cppstd, the tool will use settings.compiler.cppstd to compare
It not settings.compiler.cppstd, the tool will use compiler to compare (reading the default from cppstd_default)
If not settings.compiler is present (not declared in settings) will raise because it cannot compare.
If can not detect the default cppstd for settings.compiler, a exception will be raised.
- Parameters:
conanfile – The current recipe object. Always use
self
.cppstd – Minimal cppstd version required
gnu_extensions – GNU extension is required (e.g gnu17)
conan.tools.build.check_max_cppstd()¶
- check_max_cppstd(conanfile, cppstd, gnu_extensions=False)¶
Check if current cppstd fits the maximum version required.
In case the current cppstd doesn’t fit the maximum version required by cppstd, a ConanInvalidConfiguration exception will be raised.
If settings.compiler.cppstd, the tool will use settings.compiler.cppstd to compare
It not settings.compiler.cppstd, the tool will use compiler to compare (reading the default from cppstd_default)
If not settings.compiler is present (not declared in settings) will raise because it cannot compare.
If can not detect the default cppstd for settings.compiler, a exception will be raised.
- Parameters:
conanfile – The current recipe object. Always use
self
.cppstd – Maximum cppstd version required
gnu_extensions – GNU extension is required (e.g gnu17)
conan.tools.build.valid_min_cppstd()¶
- valid_min_cppstd(conanfile, cppstd, gnu_extensions=False)¶
Validate if current cppstd fits the minimal version required.
- Parameters:
conanfile – The current recipe object. Always use
self
.cppstd – Minimal cppstd version required
gnu_extensions – GNU extension is required (e.g gnu17). This option ONLY works on Linux.
- Returns:
True, if current cppstd matches the required cppstd version. Otherwise, False.
conan.tools.build.valid_max_cppstd()¶
- valid_max_cppstd(conanfile, cppstd, gnu_extensions=False)¶
Validate if current cppstd fits the maximum version required.
- Parameters:
conanfile – The current recipe object. Always use
self
.cppstd – Maximum cppstd version required
gnu_extensions – GNU extension is required (e.g gnu17). This option ONLY works on Linux.
- Returns:
True, if current cppstd matches the required cppstd version. Otherwise, False.
conan.tools.build.default_cppstd()¶
- default_cppstd(conanfile, compiler=None, compiler_version=None)¶
Get the default
compiler.cppstd
for the “conanfile.settings.compiler” and “conanfile settings.compiler_version” or for the parameters “compiler” and “compiler_version” if specified.- 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
- Returns:
The default
compiler.cppstd
for the specified compiler
conan.tools.build.supported_cppstd()¶
- supported_cppstd(conanfile, compiler=None, compiler_version=None)¶
Get a list of supported
compiler.cppstd
for the “conanfile.settings.compiler” and “conanfile.settings.compiler_version” or for the parameters “compiler” and “compiler_version” if specified.- 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
- Returns:
a list of supported
cppstd
values.