1.2 🎼 Alire - JulTob/Ada GitHub Wiki

The Alire project is a full environment to compile Ada files accessing libraries from many creators.

Once installed in your OS, you can use it to compile and run your own Ada code easily. Here’s how to get started with your own project:

Create a New Ada Project

If you don’t already have an Ada project, you can create one using Alire:

alr init my_project --bin
  • my_project is the name of your project folder.
  • --bin tells Alire that this is a binary (executable) project. This creates a new directory (my_project) with the necessary files and project structure.

Navigate to Your Project Folder

Move into the project directory:

cd my_project

Inside, you’ll see a few files:

  • my_project.adb – Your Ada main source file.
  • my_project.gpr – The project configuration file.
  • alr.toml – The Alire package file.

Edit the Main Ada File

Open src/my_project.adb in a text editor and modify it if needed. By default, it looks something like this:

with Ada.Text_IO; use Ada.Text_IO;

procedure My_Project is
   begin
       Put_Line("Hello, Ada!");
   end My_Project;

Build the Project

To compile your program, run:

alr build

This compiles all Ada source files in the src/ directory and generates an executable in the bin/ folder.

Run Your Ada Program

After building, you can run it with:

alr run

This executes the compiled binary. If your program simply prints "Hello, Ada!", you should see that output in your terminal.

Adding More Source Files

If you want to add more Ada files to your project:

  1. Create new files inside the src/ directory.
  2. Modify your *.adb and *.ads files as needed.
  3. Run alr build again to compile everything.