[Emacs-ada-mode] Using GNAT Project (*.gpr) files with Ada Mode
Stephen Leake
Stephe.Leake at nasa.gov
Fri Aug 15 16:55:50 PDT 2008
deadlyhead <deadlyhead at deadlyhead.com> writes:
> So, let me get this straight. Rather than using a *.adp file, and
> simply using -Psome_file.gpr with gnatmake, Ada Mode will now allow GNAT
> Project files to be used? Y'know, I thought I'd read that, but I
> must've skipped over it when re-reading the documentation. This is
> exactly what I'm hoping for.
There are actually two ways to use .gpr files to set Emacs Ada mode
project variables.
You can specify a .gpr file directly as the Emacs Ada mode project
file, or you can specify a .gpr file as part of an Emacs Ada mode
project file.
I use the later, because it lets me also specify capitialization
exceptions, and other source directories to search, such as for
Makefiles.
> It's not that functionality is missing. The issue that I have is that
> it's unreasonable to require users to use Emacs to compile an Ada
> program that I wrote.
I think I figured this out; you _can_ specify all compiler options
using Emacs Ada mode files, rather than GNAT .gpr files. I've never
done that.
Yes, that would require the user to use Emacs to build your project,
and is therefore not a good idea.
> Ideally, the user would be familiar with GNAT and its toolchain, so
> having them type `gnatmake -Pproject_name.gpr' should be a
> no-brainer.
Right.
> More likely, though, the user would like to use the `configure make
> make install' method because its standard.
"standard" is a fuzzy word here; it's standard on Gnu systems, not on
others.
> This can, of course, be used with GNAT pretty easily as all the
> configure script is is a preprocessor for the Makefiles, which are
> wrappers for the GNAT toolchain.
I prefer to simply provide a .gpr file, and tell users to include it
they way they include their own .gpr files.
In the Ada packages I provide, there is no need to "install" the
package separately; the user just compiles it as part of their
project.
> The fact that Ada Mode uses its own form of
> project files means that as I'm developing in Emacs, I am maintaining
> *.adp files for my own benefit. However, for distribution I have to
> maintain another set of project files, *.gpr files, for the users'
> benefit.
If you set compiler options in the .adp file, yes.
Which is a large part of the rationale for having Emacs Ada mode
understand .gpr files, instead.
> Of course, if I can just tell Ada Mode that my projects are defined
> using *.gpr files and GNAT Project syntax with all the bells and
> whistles, I only have to maintain one set of files for myself as well as
> for the users. That's a pretty significant benefit, whether it provides
> extra functionality or not.
Right.
>> I do this all the time; the .gpr files are tested by using them with
>> GNAT to compile the Ada code.
>>
> Well, yes. I mean, that does test them, but if I have to use a shell to
> run gnatmake so I can use my *.gpr files, then I don't get all the
> features of Ada Mode, such as jumping to the lines an error occurs on.
With the current Emacs Ada mode, you get this, when you run the
compilation via M-x compile, or one of the Emacs Ada mode 'build'
commands.
> Maybe ``organize itself'' was not the best choice of words. What I'd
> like is to have Ada Mode base all of its compilation commands off of the
> .gpr files, no .adp files needed.
That is possible.
> Basically, using .gpr files exactly as it uses .adp files (in the
> version of ada-*.el that I have). I guess that would mean that it'd
> just call gnatmake -Psomething.gpr from the correct directory
> whenever it does a build. Unfortunately, I tried setting this switch
> in my *.adp file, and it tells me that it can't find the file. Guess
> I'm doing it wrong.
There is a tutorial in the current Emacs Ada mode manual; please try
it and see if it makes things clearer.
--
-- Stephe
More information about the Emacs-ada-mode
mailing list