conan icon indicating copy to clipboard operation
conan copied to clipboard

[develop2] [feature] Considering embedding the ``--build-require`` in the recipe itself

Open memsharded opened this issue 3 years ago • 2 comments

There is a difference in the UX:

  • When a package recipe has a test_package, and it defines self.build_requires(self.tested_reference_str), when doing conan create it will be evaluated as a build-require, in the build context with the build profile
  • But conan create without test_package requires the --build-require argument 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?

memsharded avatar Aug 22 '22 13:08 memsharded

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?

lasote avatar Sep 09 '22 06:09 lasote

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

memsharded avatar Sep 09 '22 11:09 memsharded

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?

memsharded avatar Nov 06 '22 22:11 memsharded