Monday 6 February 2023

Alire on Mac

Once you’ve downloaded Alire and begun the Getting Started tutorial, how do you go about actually writing Ada?

The problem with editing source in an Alire crate is that alr build runs in the environment that Alire has set up for the crate, not the environment that you’d normally use for stand-alone projects. As an example, consider a manifest (alire.toml) containing

[gpr-set-externals.'case(os)']
windows = { TASH_PLATFORM = "windows" }
linux = { TASH_PLATFORM = "linux" }
macos = { TASH_PLATFORM = "macos" }

You need to run your editor in the environment set up by Alire, so that running a build from the editor uses that environment.

The way to handle this is to use alr edit.

On other operating systems, the default will start GNATstudio with the Alire build environment set up, but as people will be aware the last version available for macOS was the GPS provided in the GNAT Community 2019 edition, and in any case, on macOS, that won’t be on the PATH.

Emacs

Some of us like Emacs with ada-mode, but how to get alr edit to run Emacs?

The answer is to use alr config:

alr config --global --set editor.cmd 'open -a emacs ${GPR_FILE}'

This opens the GPR file, but we’re left with the clumsiness that to set it as the project file in ada-mode you have to be in an Ada source file, so you have to open one of your Ada sources first. If you’ve used a Wisi project file (.prj), for example to set casing exceptions, you might be able to use that.

GNATStudio

It’s still (24 Jan 2023) possible to download AdaCore’s GNAT Programming Studio (GPS), in the 2019 Community Edition, but it won’t run well on recent versions of macOS (the ones that no longer provide Python 2.7; you might be able to download and install a working version on Intel silicon, but this is likely to be problematic on Apple silicon (M1 etc)).

A GNATStudio build for macOS Monterey is available here from the GNU Ada project on SourceForge.

Assuming you have it installed in /Applications, say

alr config --global --set editor.cmd 'open -n -a gnatstudio -- ${GPR_FILE}'

which will open a new GNATStudio at each invocation.

No comments:

Post a Comment