Configure toolchain per project in Alire

Hello,

I have created two Alire projects which require different compilers and am trying to apply that using the alr toolchain --select command but that seems to have a global effect. I am using the same gprbuild version for both projects but when I set the compiler to (say) gnat_arm_elf on the first project then that brakes the compilation in the second project which requires gnat_native and vice-versa.

The Alire docs seem to mention only this way of setting a toolchain (unless I’ve missed some other section). The Note about cross-compilation section also mentions that a Targetattribute needs to be specified for cross targets in the gpr file and I am specifying one for that project indeed.

I was under the impression that toolchain selection is applied on a local basis for the specific project this is run against but it looks like it is applied on a global basis? :thinking:

Is that the case and if so what would be the typical way of configuring different toolchains for different projects in Alire?

Any input would be greatly appreciated, thanks!

You need to create two crates, with corresponding dependencies.

PS. See Snake game as an example. It targets native GtkAda and bare board.

hmm..does alr init not create a crate? I’ve run this command for both the projects but then, as mentioned, when I do alr toolchain --select that gets applied globally so, to both projects.

Or do you mean something else? :thinking:

Would you mind sharing a link to the Snake game, please?

Thanks

alr init creates initial content of the crate. If you use it two times, you shold have two alire.toml files, and add dependency for necesssry complier in each (it might be not needed for native).

I don’t use alr toolchain --select for years, Alire do its work excellent.

Source code of Snake game, see snake_* directories.

Nice, that worked, thank you! Following through the Alire docs I was lead to believe the alire toolchain --select is the way to set a toolchain.

Need to read upon a bit more on the alire.toml available options..

Yes, you can have a per-crate toolchain with `alr toolchain --local --select`. Otherwise, as you saw, you’re selecting the default toolchain for all your development.

1 Like

You can also have isolated Alire configurations by exporting the `ALIRE_SETTINGS_DIR` variable, see here: Alire - Settings

You can see your current situation with `alr version` and `alr settings`.

1 Like