comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nick.roberts@acm.org>
Subject: Re: GNAT and GNU build system
Date: Tue, 10 Aug 2004 17:18:02 +0100
Date: 2004-08-10T17:18:02+01:00	[thread overview]
Message-ID: <opscix8cbkp4pfvb@bram-2> (raw)
In-Reply-To: 87n0157kp0.fsf@insalien.org

On Sun, 08 Aug 2004 16:45:15 +0200, Ludovic Brenta  
<ludovic.brenta@insalien.org> wrote:

> The usual way to do configuration management in Ada in these
> situations is to have several bodies for a single spec, and choose
> one body when configuring.  This can be done in several ways.  The
> GNAT way is to symlink the file containing the particular body to
> the canonical name.  For example, one body is "5msystem.ads" and it
> is symlinked to "system.ads" before building.  This however is done
> from the Makefile and does not, per se, require a configure script.

I think I might be repeating what someone has already said, but Ada
itself provides a way of doing this, via renamings (which is what
a symlink is, in essence).

If your program has a set of packages (say My.Foo, My.Bar, and My.Hum)
which all have different bodies corresponding to three different
configurations (say A, B, and C), then you could write nine packages
(My.Foo_for_A, My.Foo_for_B, ..., My.Hum_for_C), and put three
renamings into each of three files (named, say, "config_x.ada") as
part of the library for configuration x as follows:

    package My.Foo renames My.Foo_for_x;
    package My.Bar renames My.Bar_for_x;
    package My.Hum renames My.Hum_for_x;

and then all other source text in the program can simply refer to
My.Foo, My.Bar, and My.Hum.

To recompile with a different configuration, you only have to change
one file in the compilation. I'm sure a simple script could automate
this job.

Alternatively, a more sophisticated script could generate the
sequence of renamings according to a complicated set of configuration
requirements or environment characteristics). A Unix program called
'm4' could be useful for this purpose.

Note that this technique permits the package specifications to vary
between configurations, as well as the body. It is sometimes useful to
be able to do this (for example, there may be differences in the
private parts).

-- 
Nick Roberts



  reply	other threads:[~2004-08-10 16:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-03 19:36 GNAT and GNU build system Tapio Kelloniemi
2004-08-03 20:12 ` Jerome Hugues
2004-08-04  2:05 ` Lutz Donnerhacke
2004-08-04  7:49   ` Tapio Kelloniemi
2004-08-04 13:33     ` Mark H Johnson
2004-08-04 16:04       ` Georg Bauhaus
2004-08-04 19:21         ` Ludovic Brenta
2004-08-04 20:29         ` Tapio Kelloniemi
2004-08-05  2:15           ` Georg Bauhaus
2004-08-06 10:26             ` Stephen Leake
2004-08-06 15:36               ` Georg Bauhaus
2004-08-14  6:00                 ` Tapio Kelloniemi
2004-08-14 11:32                   ` Ludovic Brenta
2004-08-14 14:41                   ` Georg Bauhaus
2004-08-04 20:06       ` Tapio Kelloniemi
2004-08-04 20:34         ` Ludovic Brenta
2004-08-04 22:11           ` Stephen Leake
2004-08-05  8:50             ` Tapio Kelloniemi
2004-08-08 14:45               ` Ludovic Brenta
2004-08-10 16:18                 ` Nick Roberts [this message]
2004-08-12 13:56   ` Florian Weimer
2004-08-13 15:52     ` Lutz Donnerhacke
2004-08-04 22:06 ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox