conan
conan copied to clipboard
[develop2] [feature] Considering embedding the ``--build-require`` in the recipe itself
There is a difference in the UX:
- When a package recipe has a
test_package, and it definesself.build_requires(self.tested_reference_str), when doingconan createit will be evaluated as a build-require, in the build context with the build profile - But
conan createwithouttest_packagerequires the--build-requireargument to achieve the same behavior, and receiving the same build and host settings as the above. - Other commands like
conan install,conan graph info, etc doesn't have this way for local development, so user needs basically to provide the "build" context as host (and for exceptional cases that need the "target" context, it will be lost).
Maybe adding a explicit i_am_tool_require=True or i_am_build_context=True in recipes directly allows to make this more homogenous and predictable?
Some questions to discuss:
So if a package has a regular "require" (with build=False) to another with i_am_build_context =True Conan should fail? or this would affect only when the consumer is "virtual"? In this latest case, could be more like a default_build_context=True?
What about fixing these local commands (conan install..etc) to add the --build-require? it makes indeed more verbose the commands, including the conan create with a build require as we saw in your PR about the decoupling of the test_package but not fully convinced about the interface.
As this would be an attribute describing somehow the package like maybe the language or the package_type, should we unify/think about the naming?
I did a try in https://github.com/conan-io/conan/pull/12046/commits/baa6b8fd71bb429ca978dfb26a8aed12b705eb13, it seemed to work, but we decided to simplify first while rolling the changes in test_package
This feature does not address the case of some recipes (protobuf and similar), that need to be built both as regular "host" requires and as "build" tool_requires. So probably not worth implementing and leaving just 1 way to do it, which would be the current cli arg?