How do you make an Ada package available both for people who use Alire and people who do not?

I’ve written an Ada package that I may eventually want to publish, and as a first step I’ve started making an Alire crate of it. However, Alire really really wants you to use its config project file in the config subdirectory, which it regenerates from the alire.toml, which makes it hard for people who don’t want to use Alire to use the library.

Does anyone have any good approaches to handling this?

I could keep a repo with the my original non-alire gpr files, and have a makefile target that basically checks for differences and exports the changed files into another repo with alire-specific stuff, but that’s a pain.

I suspect that if I just used a simpler gpr file that ignored the alire stuff it would break alire in non-obvious ways.

I suppose I could just keep everything in one repo and set things up so the alire gpr file includes the simpler non-alire gpr file, but then those two have to have different filenames, and there is the confusing situtation where there are two gpr files.

1 Like

I do something that may be over the top to accomplish it, but I wanted it so that if someone didn’t want to use alire, they could delete the alire.toml and the alire subfolder and just use the gpr file as is. I also want commands like alr build --release to still work in the setup I accomplished that by pointing alire to an aggregate project file. See my example here:

Basically, I create the alire subfolder myself, and place an alire_default.gpr file in there that is an aggregate project that calls my actual project file. So take a look at alire.toml, alire/alire_default.gpr and bullfrog.gpr for the setup.

It may be overkill, but I don’t know how all the things work honestly.

2 Likes

Well, that looks interesting. I can’t try it out right now, but I’ll definitely give it a try soon. Thanks!

There’s no requirement to use the config files that are generated by Alire; they’re just there as a convenience. You’re free to modify your GPR file to remove the dependency on the generated config file and set your own compiler switches etc. You can also tell Alire not to generate GPR/Ada/C config files by adding these to your alire.toml:

[configuration]
generate_ada = false
generate_gpr = false
generate_c = false
2 Likes

One option is to just include the config directory under configuration control. In order to avoid having modified files whenever you change any Alire option, you can do that only at a final step in which you create a release branch, run alr build --release and add the files only on that branch. Then you direct non-alire users to build from the latest release branch, requiring them to provide all the dependencies and configure GPR_PROJECT_PATH accordingly. The same can be done if you provide a downloadable ZIP containing sources.

Git should have a way to command it to include files under configuration control but ignoring any modification you might do to them, but, as far as I know, that option does not exist.