Skip to content
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

get gpr file from alire.toml via command line #1151

Open
stephe-ada-guru opened this issue Aug 20, 2022 · 9 comments
Open

get gpr file from alire.toml via command line #1151

stephe-ada-guru opened this issue Aug 20, 2022 · 9 comments
Labels
type: feature New feature or request
Milestone

Comments

@stephe-ada-guru
Copy link

I'm writing an interface to Alire for Emacs. One thing I need to do is use 'gnat ls' to get the source path from the gpr file; to do that I need the name of the gpr file. Currently I'd have to parse the toml file myself to get that.

One possible implementation is to add GPR_PROJECT_FILE to the output of 'alr printenv'.

@mosteo
Copy link
Member

mosteo commented Aug 22, 2022

Is this GPR_PROJECT_FILE standard? Or do you mean it as a custom list export of the closure of project files?

@stephe-ada-guru
Copy link
Author

It's not standard.

Another possible implementation would be a separate command "alr list-project-files" or similar.

I don't need the closure of project files, which I assume to mean the list of all project files included by "with", transitively; just the top project file. Alire supports more than one top project file, so it's still a list, so the name should be GPR_PROJECT_FILES. I have not considered how to support that in Emacs ada-mode. One of my crates has two project files; one for a library and another for the executables. So I'll have to figure this out.

@mosteo
Copy link
Member

mosteo commented Oct 10, 2022

Your assumptions are correct. Alright, so a list of the top-level project files, with relative paths from the crate root.

@mosteo mosteo added the type: feature New feature or request label Oct 10, 2022
@mosteo
Copy link
Member

mosteo commented Oct 10, 2022

Ideally, we could export all properties in a parsable format (JSON?), including implicit ones, to achieve maximum generality. Although this would require quite some internal refactoring. That could be a long-term goal though, what you need is much simpler.

@mosteo mosteo added this to the 1.3 milestone Oct 10, 2022
@Fabien-Chouteau
Copy link
Member

Could this be part of alr show?

@mosteo
Copy link
Member

mosteo commented Oct 10, 2022

Could this be part of alr show?

That's where I'd put it, yes.

@stephe-ada-guru
Copy link
Author

I just discovered the -P option to "alr exec". So this gives me the project file:

$ alr exec -P -- echo
-P alr.gpr

This does raise the question of which project file does "alr exec -P" use if there is more than one? Testing in my crate with more than one:

$ alr exec -P -- echo
error: More than 1 project file declared for this crate.

So that doesn't work. Perhaps "alr exec -P" needs a mechanism to select the project file as well? That means the user would have to be aware of the multiple project files, and what they are for, so they can just as easily specify the project file directly in their command.

Similarly, it is convenient in my Emacs application to allow the user to choose which top level gpr file to use, so having the user read the toml file and pick one is not a big problem.

@Fabien-Chouteau
Copy link
Member

So that doesn't work. Perhaps "alr exec -P" needs a mechanism to select the project file as well?

Yes that's something we can add to exec at some point.

@mgrojo
Copy link
Contributor

mgrojo commented Mar 19, 2023

cargo metadata can work as inspiration for the feature.

@mosteo mosteo modified the milestones: 1.3, 2.0 Sep 12, 2023
@mosteo mosteo modified the milestones: 2.0, 2.1 Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants