Conan: Add custom command [suggestion]

Created on 26 Sep 2019  路  3Comments  路  Source: conan-io/conan

To help us debug your issue please explain:

  • [ x ] I've read the CONTRIBUTING guide.
  • [ x ] I've specified the Conan version, operating system version and any tool that can be relevant.
  • [ x ] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.

I try to integrate multiple libraries with conan. Therefore I have created a conan python package with a base conan class which I include in my conanfiles by using python_requires.

It would be great to be able to add additional custom commands to those packages e.g. to be able to easily load huge amount of testing data, which may be required by those libraries.
So now you may ask why not just load those data manually. The idea is that those data may differ depending on the library and it is possible to compute what files are necessary by parsing the parameters of the conan file.

To avoid cluttering your namespace I would propose something like to force a certain prefix for such a function, e.g. each function has to start with custom_. This may look like the following:

class ConanSomething(ConanBaseFile):
# standard recipe stuff
def custom_load_artefacts(self): ....

And a conan call could look like:
conan custom load_artefacts

This way if there would be some decision in the future to add a function load_artefacts to the standard conan it would not interfere with the custom load_artefacts call defined here.

high medium feature look into

Most helpful comment

@lasote I feel like the question here is about project orchestration, in the same manner as npm run command, for example.

It's a pretty broad and a complex topic, but a worthwhile one to think about in the long term for the Development Workflow. But in my opinion, any work in that domain must absolutely cover the current one such as conan build which works only for very simple projects.

Advantages of orchestration:

  • Conan can be used to ship different (less popular) build tools and custom commands could make a convenient interface for developers of a project to use them (conan run lint, conan run format).
  • Conan can be used as an abstraction layer over build-systems. Developers clone a project and starts working with common commands such as conan run configure, conan run build and conan run test.
  • Having conventional commands could allow better integration of Conan and Conan-related build tools into IDEs.

All 3 comments

But the "lifecycle" of a package creation is always the same, source, build, package, so why don't call that code from any of these methods?

@lasote I feel like the question here is about project orchestration, in the same manner as npm run command, for example.

It's a pretty broad and a complex topic, but a worthwhile one to think about in the long term for the Development Workflow. But in my opinion, any work in that domain must absolutely cover the current one such as conan build which works only for very simple projects.

Advantages of orchestration:

  • Conan can be used to ship different (less popular) build tools and custom commands could make a convenient interface for developers of a project to use them (conan run lint, conan run format).
  • Conan can be used as an abstraction layer over build-systems. Developers clone a project and starts working with common commands such as conan run configure, conan run build and conan run test.
  • Having conventional commands could allow better integration of Conan and Conan-related build tools into IDEs.

Yes exactly. Of course some or even all of this commands may be also called automatically in one of the standard steps source, build, package. But especially code checker / analyser tools you may want to be able to also call separatly without directly invoking an additional tool with maybe another complex command line syntax.

Was this page helpful?
0 / 5 - 0 ratings