Alire
Introduction
Alire serves as a package manager tailored for the Ada and SPARK programming languages.
Within Alire, the building blocks of projects, libraries, and programs are referred to as crates
. These crates can establish dependencies on other crates, which in turn can have their dependencies.
It's important to note that a single crate may have multiple dependencies. Alire efficiently handles the retrieval, compilation, and maintenance of crates within the entire dependency graph automatically.
The primary interface for working with Alire is the alr command-line utility.
This section is meant to explain the basics of using the Alire package manager, for more extensive documentation please refer to Alire's official documentation.
Installing Alire
To ensure a smooth installation process and avoid potential conflicts later when installing the toolchains, it is crucial to fully uninstall GNAT Community 2021 from your computer before proceeding.
- Windows
- Linux
- macOS
- Get the Alire installer from the official website.
- Run the installer executable and complete the setup process.
- During the installation process, you will be asked if you want to install
msys2
. It is recommended to do so as it will automatically install missing tools such asgit
ormake
. - You're done!
- Get the Alire installer from the official website.
- Extract the contents of the archive.
- Move the
alr
binary to a location in your PATH (e.g., /usr/bin/ or ~/.local/bin/). - You're done!
- Get the Alire installer from the official website.
- Extract the contents of the archive.
- Move the
alr
binary to a location in your PATH (e.g., /usr/bin/ or ~/.local/bin/) or add the location of the binary to your ~/.bash_profile. - If you get a popup saying
"alr" cannot be opened because the developer cannot be verified
when you runalr
, then runxattr -d com.apple.quarantine bin/alr
to remove the quarantine attribute on the binary. - You're done!
Creating a New Crate
When using Alire to create a crate, it is important that the name does not contain capitalizations and uses the snake_case format.
Initial Configuration
The first time you run the alr init
command, Alire will prompt you for the following information.
GitHub Login
: used to identify the maintainer of the crate.Full Name
: name of the author of the crate.Email Address
: email of the author of the crate.
Executables
To create an executable with Alire, you can use the following command:
alr init --bin <crate_name>
Libraries
To create a library with Alire, you can use the following command:
alr init --lib <crate_name>
Building and Running the Crate
After creating your crate using Alire, you can compile and run it easily. Here are the steps to run your Alire project:
Navigate to your crate directory using the command line.
cd <crate_name>
To build your crate, use the following command:
alr build
This command will compile your crate and generate the necessary binaries.
Once the build process is complete, you can run your crate by executing the generated binary. For executable crates, this is typically the same as your project name:
./<project_name>
To build & run your crate in one step, use the following command:
alr run
For library crates, you will need to integrate the library into your application or project.
Using the Space Concordia Alire Index
In order to let Alire find crates managed by Space Concordia, you may use the following command:
alr index --add git+https://github.com/scs-cdh/alire-index.git#stable-1.2.1 --name scs_cdh
This will add the Space Concordia index to your Alire installation. As an example, this will allow you to add a dependency to projects such as astrocore
.