From 14c6921ed380a71247e2a079345487c1401699a5 Mon Sep 17 00:00:00 2001 From: Luis Date: Tue, 28 Jun 2022 16:54:30 +0200 Subject: [PATCH 1/2] cppstd ported tools --- reference/conanfile/tools/build.rst | 89 ++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/reference/conanfile/tools/build.rst b/reference/conanfile/tools/build.rst index 1f597c56c09..5ecc32dd16e 100644 --- a/reference/conanfile/tools/build.rst +++ b/reference/conanfile/tools/build.rst @@ -23,7 +23,7 @@ Parameters: conan.tools.build.can_run() ----------------------------------- +--------------------------- .. code-block:: python @@ -38,3 +38,90 @@ It's an useful feature for the case your architecture can run more than one targ Parameters: - **conanfile**: Conanfile object, use always ``self``. + + +conan.tools.build.check_min_cppstd +---------------------------------- + + +.. code-block:: python + + def 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. + + 1. If settings.compiler.cppstd, the tool will use settings.compiler.cppstd to compare + 2. It not settings.compiler.cppstd, the tool will use compiler to compare (reading the + default from cppstd_default) + 3. If not settings.compiler is present (not declared in settings) will raise because it + cannot compare. + 4. 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.valid_min_cppstd +---------------------------------- + + +.. code-block:: python + + def valid_min_cppstd(conanfile, cppstd, gnu_extensions=False) + + +Validate if current cppstd fits the minimal version required. Return ``True``, if current cppstd matches the required +cppstd version. Otherwise, ``False``. + +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. + + +conan.tools.build.default_cppstd +---------------------------------- + +.. code-block:: python + + def 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. +Returns the default ``compiler.cppstd`` for the specified compiler. + +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.supported_cppstd +---------------------------------- + +.. code-block:: python + + def supported_cppstd(conanfile, compiler=None, compiler_version=None): + + + +Get the 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. Returns a list of supported ``cppstd`` values. + + +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 From aa9c6552481015ba2e211f0b7a751f91ceee31c9 Mon Sep 17 00:00:00 2001 From: Luis Date: Wed, 29 Jun 2022 08:49:00 +0200 Subject: [PATCH 2/2] Review --- reference/conanfile/tools/build.rst | 31 ++--------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/reference/conanfile/tools/build.rst b/reference/conanfile/tools/build.rst index 5ecc32dd16e..14fc7e763ea 100644 --- a/reference/conanfile/tools/build.rst +++ b/reference/conanfile/tools/build.rst @@ -49,16 +49,8 @@ conan.tools.build.check_min_cppstd def 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. - - 1. If settings.compiler.cppstd, the tool will use settings.compiler.cppstd to compare - 2. It not settings.compiler.cppstd, the tool will use compiler to compare (reading the - default from cppstd_default) - 3. If not settings.compiler is present (not declared in settings) will raise because it - cannot compare. - 4. If can not detect the default cppstd for settings.compiler, a exception will be raised. +Check if provided ``conanfile.settings.compiler.cppstd`` fits the minimal version required (specified in the argument ``cppstd``). +In case it doesn't, a ``ConanInvalidConfiguration`` exception will be raised. Parameters: @@ -67,25 +59,6 @@ Parameters: - **gnu_extensions**: GNU extension is required (e.g gnu17). -conan.tools.build.valid_min_cppstd ----------------------------------- - - -.. code-block:: python - - def valid_min_cppstd(conanfile, cppstd, gnu_extensions=False) - - -Validate if current cppstd fits the minimal version required. Return ``True``, if current cppstd matches the required -cppstd version. Otherwise, ``False``. - -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. - - conan.tools.build.default_cppstd ----------------------------------