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: expose cppstd_flag tool #6744

Merged
merged 1 commit into from Mar 30, 2020

Conversation

SSE4
Copy link
Contributor

@SSE4 SSE4 commented Mar 26, 2020

Changelog: Feature: Add new tool cppstd_flag to retrieve the compiler flag for the given settings.
Docs: conan-io/docs#1639

related: #5699

/cc @jgsogo

during the work on Intel compiler support, it turns out it's not enough to just pass compiler, compiler.version and cppstd/compiler.cppstd to thecppstd_flag method.
the reason is that Intel compiler (maybe others) has different C++ standard flags dependent on base compiler, so at very least, compiler.base is also required to get proper standard flag.
reference:
https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-std-qstd

  • -std=val if base compiler is GCC or Clang
  • /Qstd=val* if base compiler is Visual Studio
    also, we have noticed, that some recipes (e.g. boost is known example) are already using the cppstd_flag, but it's not currently a part of public api.
    such recipes usually use custom build systems, so they don't use existing build helpers, but they need to deduce the valid C++ standard flag to pass it to the build system.

therefore, this PR has the following changes:

  • expose cppstd_flag and cppstd_default to the conans.tools namespace (which is public API)

  • now cppstd_flag and cppstd_default accept the full settings object, so they have access to all available settings (include compiler.base)

  • 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.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

@SSE4 SSE4 force-pushed the settings_cppstd_flag branch 2 times, most recently from 297db43 to 0fc7f63 Compare Mar 26, 2020
Copy link
Member

@jgsogo jgsogo left a comment

I agree we should expose the cppstd_flag as a conans.tools, but I'd avoid exposing cppstd_default at this moment, we need to think about CPPSTD and everything related to it before providing these tools.

Related, I think we shouldn't test all the ConanExceptions that are being raised because of the settings.yml contents. At least the old ones, I would agree to test the ConanException for new compilers in order to realize that we need to provide the implementation for them. wdyt about this point?

conans/client/build/cppstd_flags.py Outdated Show resolved Hide resolved
conans/client/build/cppstd_flags.py Outdated Show resolved Hide resolved
conans/client/settings_preprocessor.py Outdated Show resolved Hide resolved
conans/tools.py Outdated Show resolved Hide resolved
conans/test/unittests/client/build/cpp_std_flags_test.py Outdated Show resolved Hide resolved
conans/test/unittests/client/build/cpp_std_flags_test.py Outdated Show resolved Hide resolved
conans/test/unittests/client/build/cpp_std_flags_test.py Outdated Show resolved Hide resolved
conans/test/unittests/client/build/cpp_std_flags_test.py Outdated Show resolved Hide resolved
conans/test/unittests/client/build/cpp_std_flags_test.py Outdated Show resolved Hide resolved
conans/client/settings_preprocessor.py Outdated Show resolved Hide resolved
@jgsogo
Copy link
Member

@jgsogo jgsogo commented Mar 26, 2020

About the changelog (and the PR title), here the important thing is that we are adding a new tool, cppstd_flag

@SSE4 SSE4 changed the title Feature: pass settings objects to cppstd_flag Feature: expose cppstd_flag tool Mar 26, 2020
@SSE4 SSE4 force-pushed the settings_cppstd_flag branch 5 times, most recently from 84009a2 to e5f59cf Compare Mar 26, 2020
jgsogo
jgsogo approved these changes Mar 27, 2020
Copy link
Member

@jgsogo jgsogo left a comment

Thanks, @SSE4 🎉

Can you write the docs for this PR?

@jgsogo jgsogo added this to the 1.24 milestone Mar 27, 2020
conans/client/build/autotools_environment.py Outdated Show resolved Hide resolved
conans/client/build/cmake_flags.py Outdated Show resolved Hide resolved
conans/client/build/cppstd_flags.py Show resolved Hide resolved
@SSE4 SSE4 force-pushed the settings_cppstd_flag branch from e5f59cf to 8c7953c Compare Mar 27, 2020
Copy link
Member

@danimtb danimtb left a comment

now I understand better the changes and that this PR will help in the integration of the intel tools

…ns.tools)

Signed-off-by: SSE4 <tomskside@gmail.com>
@SSE4
Copy link
Contributor Author

@SSE4 SSE4 commented Mar 30, 2020

docs: conan-io/docs#1639

jgsogo
jgsogo approved these changes Mar 30, 2020
@memsharded memsharded merged commit a1086d3 into conan-io:develop Mar 30, 2020
2 checks passed
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.

None yet

6 participants