A few years ago we realized that having a package manager for the
SPARK community would be a game changer. Since then, AdaCore has been sponsoring and contributing to the
Alire project created by Alejandro Mosteo from the Centro Universitario de la Defensa de Zaragoza. With this blog post I want to introduce
Alire and explain why this project is important for the
What is a package manager? #
There are many different kinds of package managers,
Alire is a source-based package manager focused on the
SPARK programming language.
This means that the goal of
Alire is to provide an easy way to get, build and use
SPARK projects in source form. It is a tool for developers, as opposed to binary package managers which are providing ready to use applications for end-users. It is comparable to
opam for the
OCaml ecosystem, or
What are the benefits of Alire for the Ada/SPARK ecosystem? #
In my opinion, the main benefit of a package manager is to improve the collaboration within a community of developers.
This is achieved in multiple ways:
Alireis a central place to look for existing projects. If you are looking for a library to provide a given feature in your project, a quick search on the alire.ada.dev website will tell you if someone from the community already implemented it.
The corollary is that
Alireis a central place to contribute projects and make them available to other developers in the community.
Alireprovides a common and easy way to integrate projects from the community in your own projects.
What does it mean in practice? #
Let’s take a simple scenario from personal experience: I am writing an application in
Ada, and I want my application to produce PDF reports.
We will look at different steps of this scenario and compare how to achieve them without and with
Alire. I will use the
alr command line tool from the
1st step: finding an Ada PDF library #
Alire: I will search the web for a project that matches my needs. Search engines are pretty powerful so if there is something out there (on GitHub, SourceForge, GitLab, or elsewhere) I will likely find it. “Ada PDF” doesn’t yield good results, but “Ada PDF library” does the job.
Alire: A simple search on the alire.ada.dev website gives me a list of Ada/SPARK projects available right now matching the PDF keyword: https://alire.ada.dev/search/?q=pdf Or on the command line:
$ alr list | grep pdf
2nd step: use APDF in my project #
Alire: Once I have found the
APDFproject (https://apdf.sourceforge.io/) I can either get the source from tarball or checkout the repository. From that I have to understand how to use the source code in my project. Maybe I have to set the
GPR_PROJECT_PATH, maybe I have to build and install the library.
$ alr with apdf
alr withcommand automatically fetches the latest version of
APDFand makes it available in my project.
3rd step: updating APDF when new releases are available #
Alire: I have no automated way to know if a new version of
APDFis available. I can follow forums and mailing lists in hope of catching the information, but this is not very reliable. If I do get the information that a new version of
APDFis available, I have to redo the 2nd step (download tarball, extract, set project path, etc.).
$ alr update
Alirewill let me know if new versions of my dependencies are available and automatically update them for me, if I wish to do so.
4th step: Other developers want to build my project #
Alire: I have to document in the README file all the steps to get and set up my dependencies (download tarball, extract, set project path, etc). Anyone interested in compiling my project has to follow all the steps, and do so transitively for all dependencies.
$ alr get my_project
If I contributed my project to the
Alireindex, anyone can get the project and its dependencies with a simple command. Otherwise, one can checkout the repository and use
alr updateto fetch the dependencies.
5th step: publishing my project for others to use in their projects #
Alire: I have to document how to integrate my project in another project. I can then announce the project on an Ada/SPARK community forum like Reddit r/ada and hope that this or the repository will show up in a Web search when people need my project.
$ alr publish
Alireprovides a command to help publishing projects in the
Alireindex. Once my project is in the index, a dedicated page will be created on the alire.ada.dev website and my project will be available for
Alireusers. Of course it is still a good idea to announce it in the forums.
How many projects are available in
As of October 2020, there are 130 projects (“crates” in the
Alire vocabulary) available. You can browse through the list on the website: alire.ada.dev/crates.
There is also a network graph view of the Alire ecosystem: here.
How do I start? #
The first beta release of
Alire was published a few days ago. Go to alire.ada.dev for instructions on how to install and use the tool.