AdaCore / libadalang-tools

Libadalang-based tools
GNU General Public License v3.0
16 stars 13 forks source link

How to build gnatpp for usage in another Alire crate? #21

Closed pjljvandelaar closed 2 years ago

pjljvandelaar commented 2 years ago

Dear LibAdaLang_Tools developers,

We have written a library and tool to analyse and manipulate Ada code. After manipulation, we typically want to run gnatpp to ensure that the code is readable and adheres to the desired style.

Some of our users might not have gnatpp installed yet. As a service to our users, we would like to specify that we depend on libadalang-tools. And we want to build gnatpp as one of our own build steps.

However, on the website we can't find any information how you build gnatpp within alire, even though LibAdaLang_Tools is an Alire crate.

Could you please extend the documentation to describe how other crates can build and use the tools that you make available within libadalang-tools?

Thanks in advance!

Pierre

Fabien-Chouteau commented 2 years ago

Hello @pjljvandelaar

$ alr get --build libadalang_tools

Will get you gnatpp built within Alire.

pjljvandelaar commented 2 years ago

Dear Fabien,

Thanks for the answer. I still have some questions:

  1. Where should I run this command? Running it inside my alire project I get: ERROR: Cannot get a release inside another alr release, stopping.
  2. Why are these tools not installed in a default location, such as <user>/.alire/bin or <user>/AppData/Roaming/local/bin/ ? Putting this directory on your path would enable running all tools installed with alire.
  3. I would like to execute this command from my alire crate. How do I do that? Or do I have to instruct my users to install gnatpp and then put it on the path such that I can call it?

Thanks once again for your answers!

Pierre

Fabien-Chouteau commented 2 years ago
1. Where should I run this command? Running it inside my alire project I get: `ERROR: Cannot get a release inside another alr release, stopping.`

You cannot "get" a crate inside another crate, that would override the code. If you just want to use the tools then do alr get --build libadalang_tools in a place that is convenient for you and then set the PATH environment variable. See below.

2. Why are these tools not installed in a default location,
   such as `<user>/.alire/bin` or `<user>/AppData/Roaming/local/bin/` ?
   Putting this directory on your path would enable running all tools installed with alire.

Alire is not able to do that yet. The tools are in the bin/ directory libadalang_tools_22.0.0_c9028428/.

3. I would like to execute this command from my alire crate. How do I do that?

You want gnatpp as part of the development workflow? Or is the crate using gnatpp directly?

Or do I have to instruct my users to install gnatpp and then put it on the path such that I can call it?

For the moment yes.

pjljvandelaar commented 2 years ago

To answer: You want gnatpp as part of the development workflow? Or is the crate using gnatpp directly?

As you can see on https://github.com/TNO/Rejuvenation-Ada/blob/973345cebd123d4088628058b7a58ca8ce99a71f/src/rejuvenation-pretty_print.adb#L77

The library crate calls gnatpp to realize the pretty printing (since we would be stupid to build a new one ;-) )

So I want that all crates that depend on this library crate also will have gnatpp on their path / location that is known to our library crate.

Fabien-Chouteau commented 2 years ago

Ok so you have to add libadalang_tools as a dependency of your library. That being said I am not sure Alire is yet able to do the right thing and add gnatpp in PATH.