Alire beginer questions

Hello there,
I’m giving a try at Alire but I fail understanding a few things…
So, I have created a small library which I would like to use in a small application.
Hence I have created a crate with my lib and a crate with my application withing the lib.
I can build the crate lib just fine but I cannot add the lib dependency to the application crate. It says that my lib is not found in index.
Of course, before publishing anything to some community repository I would like to learn and test things locally.
Does Alire allow a local use ? How ?
I want to push my stuff to GitLab since I am not a big fan of GitHub.
Is it a problem when using Alire ?
When I have created the crate library it has also created a .gitignore file which ignores the config folder but the gpr file needs that folder and the gpr file in it in order to build the crate.
So user of the source code cannot build it.
Maybe I have missed important notions in the documentation.
Any hint and suggestion welcome.
Thanks in advance,
Stéphane

This happened to me once, too! :grin: and someone happily pointed me to Alire’s pinning capability. I’m pretty sure that’s what you want.

.gitignore only affects git status, not git add. You can include a version of the configr gpr file in Git, but it’s better to ignore the changes performed by alr when you ask for different build profiles.

I may be misunderstanding what you mean but git add does respect gitignore files by default unless you specifically make it not respect them. I use this to my advantage all the time.

I’ll do a git add . and it will grab everything but what the gitignore file specifies to ignore

I don’t know how beginner friendly the process is but alire does have options to specify a different index which could be a gitlab site. I’ve not done it myself but there’s a way to set that up

When you run the alire build or alire run commands they generate the config folder and the contents there so you shouldn’t need to have that in your repo if using alire unless you are doing something custom in the config folder.

My formulation wasn’t very precise. What I meant is that you can add ignored files without any problem (you have to include -f to git add invocation, though).

This is what Alire recommends for crates that want to be buildable without having Alire installed. See, for example, Moving ./config inside ./alire? · alire-project/alire · Discussion #812 · GitHub, although this is what I’ve found now; I remember another, more explicit, mention.

Gotcha! I went through this myself. I ended up taking it a step farther.:

  1. My alire.toml specifies the configuration folder inside the alire folder as indicated by that github post:
[configuration]
output_dir = "alire/config"
  1. I have the alire.toml also specify a different gpr file than my standard one (both exist):
project-files = ["alire/alire_default.gpr"] 

That gpr file acts as a bridge between the generated alire config gpr and my projects GPR in such a way that I can compile the project with our without alire

with "config/bullfrog_ada_compiler_config.gpr";

aggregate project Alire_Default is

   Build_Profile := Bullfrog_Ada_Compiler_config.Build_Profile;

   for Project_Files use ("../default.gpr");

   case Build_Profile is
      when "release" => for External("BUILD") use "release";
      when others    => for External("BUILD") use "development";
   end case;

end Alire_Default;

Then I have the option of either running:
gprbuild
gprbuild -XBUILD=release
alr build
alr build --release

Additionally the alire.toml and the alire folder can be deleted and someone can just use the first two commands if they don’t want to use alire at all. It does mean I add the alire folder and the alire_default.gpr file to my repo, but it gives me some flexibility.

Though it does mean that all the switches now have to be defined in my default.gpr file, but I wanted that anyways as the ones alire generates are a bit too thorough for my taste.

Full example in this toy (not serious) project: GitHub - jere-software/bullfrog-ada-compiler: A for play project for learning. Not meant to be a finished or working project

It looks like you can use GitLab just fine. Here’s a sample project of someone else doing that.

Hi there,
Thank you all for suggestions.
I have managed to do what I wanted reading the alr online help which is very helpful. Once I’ve got started I could create a local alr repository with my lib crate pointing to the GitLab repository and an application crate using it.
Well, just the start of my Alire adventure !

Thanks again.
Best regards,
Stéphane

2 Likes