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
msvc_runtime_flag should not break when expecting a string value #10424
msvc_runtime_flag should not break when expecting a string value #10424
Conversation
Signed-off-by: Uilian Ries <uilianries@gmail.com>
The check should be in any case My concern here is why a recipe needs to check the flag at that low level. This utility was intended to return the flags for usage, not for checking the runtime, for that you typically check the settings instead. Can you give some example of this usage? I am fine accepting this, no problem, I mostly wonder if we are missing something and I would like recipes to be as clear as possible and seeing |
Conan Center Index is good example, when some project doesn't support MT and you need to raise ConanInvalidConfiguration. Some real cases: https://github.com/conan-io/conan-center-index/blob/28846bc318db1c670689c430eaaad1c2d90a72f2/recipes/fast-cdr/all/conanfile.py#L51 |
Yes, this is exactly what I mean, that those checks should be higher level, something like: if msvc_static_runtime(self):
raise ... Furthermore, those checks seems to be not specific to those recipes, but a general thing. Recipes shouldn't protect against every possible misconfiguration, the So:
|
True, but if we don't apply those filters, they will fail on CI.
It's a possibility indeed. I can create a new PR providing such helper. The helper |
That is a failure of C3i. It shouldn't be generating configurations of shared + static runtime if that is not a valid configuration. It is still not the responsibility of the recipe to handle these cases. |
C3i can not guess it, it need to be informed by ConanInvalidConfiguration. That's the only exception which is not considered an error and won't break the CI flow. But anyway, I think the better approach will be |
It depends. If this is an error for all recipes, it is an invalid configuration in general, then recipes shouldn't handle it. C3i can totally exclude this profile from generation completely. |
Signed-off-by: Uilian Ries <uilianries@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be merged, is correct.
But lets keep an eye on the recipes and ConanCenter:
- If every recipe in ConanCenter should include a
validate()
check for a shared-MT combination, that is a big smell, that such profile should be excluded from generation completely, shouldn't be a recipe thing - If a helper
is_msvc_runtime_static()
helps, we can certainly add it.
Only few projects. As you may know, Conan does a good work finding configurations which are not tested/supported by upstreams. Usually they build a single configuration on Windows and Linux, and that's it. We explore all possibilities, so this kind of situation is expected. |
Changelog: Fix:
msvc_runtime_flag
returns empty string instead ofNone
.Docs: conan-io/docs#2363
The helper
msvc_runtime_flag
works fine when running on Windows, but it returns None when something is not expected, so the follow condition is fragile:On Windows it can work, but for any other OS/compiler it will result:
The possible solution is an extra validation, but it makes the code more polluted and can result in prone error sometimes:
If we return an empty string, it be avoided on Linux/Mac/other compiler.
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.