Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Export cppstd_flag as public tool #15710

Merged
merged 7 commits into from
Feb 21, 2024

Conversation

uilianries
Copy link
Member

@uilianries uilianries commented Feb 20, 2024

This PR exposes the cppstd_flag method from flags.py to builds:

from conan import ConanFile
from conan.tools.build import cppstd_flag

class FooConanFile(ConanFile):

    def build(self):
        compiler_flag = cppstd_flag(self)
        self.run(f"gcc ... {compiler_flag}")

Changelog: Feature: Make cppstd_flag public to return the corresponding C++ standard flag based on the settings.
Docs: conan-io/docs#3599

closes #12603

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries uilianries added this to the 2.2.0 milestone Feb 21, 2024
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@@ -7,6 +6,7 @@ def architecture_flag(settings):
returns flags specific to the target architecture and compiler
Used by CMakeToolchain and AutotoolsToolchain
"""
from conan.tools.apple.apple import _to_apple_arch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lazy import is to avoid a cyclic import error.

@memsharded memsharded merged commit caf137e into conan-io:develop2 Feb 21, 2024
2 checks passed
@memsharded
Copy link
Member

Thanks!

Will you backport it to Conan 1.X, to achieve recipe compatibility in 1.64?

@uilianries
Copy link
Member Author

Will you backport it to Conan 1.X, to achieve recipe compatibility in 1.64?

That's an excellent idea actually, otherwise, we will not be able to use it in CCI. I'll open a second PR.

@uilianries
Copy link
Member Author

Thanks!

Will you backport it to Conan 1.X, to achieve recipe compatibility in 1.64?

Done, the PR #15731 has the backport implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] conan v2 tools: Expose cppstd_flag function
2 participants