comp.lang.ada
 help / color / mirror / Atom feed
* Using GNAT project files and libraries
@ 2008-03-07 22:37 Maciej Sobczak
  2008-03-08 11:59 ` Tero Koskinen
  2008-03-08 17:33 ` Simon Wright
  0 siblings, 2 replies; 7+ messages in thread
From: Maciej Sobczak @ 2008-03-07 22:37 UTC (permalink / raw)


Hi,

I have a library composed of two packages: the root library package,
which is empty (pure), and one child containing Some_Procedure. Let's
say the packages are named L and L.Child. The library is compiled and
resides in the following directories:

src: l.ads, l-child.ads, l-child.adb
lib: l.ali, l-child.ali, libl.a

There is also a sibling test directory with the following a.adb:

with L.Child;
procedure A is
begin
   L.Child.Some_Procedure;
end A;

Now I try to figure out how to write A.gpr project file.
I have the following:

project A is

    for Source_Files use ("a.adb");

    package Compiler is
        for Default_Switches ("Ada") use ("-I../src");
    end Compiler;

end A;

This is enough to get the a.adb file compiled, but after that gnatmake
exits with:

gnatmake: "l.ads" not found

I tried similar entries for Binder and Builder packages (with
different combinations of -aI, -aL, -aO, etc.), but to no avail.

How should I write the complete A.gpr project file so that my a.adb
can use the L library?

Note that the following:

$ gnatmake a -I../src -L../lib -largs -ll

creates a working executable, but does *not* do it the way I want - it
seems to compile ../src/l-child.adb, which I guess can be avoided
(the ../lib/libl.a has some purpose, after all).

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using GNAT project files and libraries
  2008-03-07 22:37 Using GNAT project files and libraries Maciej Sobczak
@ 2008-03-08 11:59 ` Tero Koskinen
  2008-03-08 17:33 ` Simon Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Tero Koskinen @ 2008-03-08 11:59 UTC (permalink / raw)


On Fri, 7 Mar 2008 14:37:15 -0800 (PST) Maciej Sobczak wrote:

> Hi,
> 
> I have a library composed of two packages: the root library package,
> which is empty (pure), and one child containing Some_Procedure. Let's
> say the packages are named L and L.Child. 
[snip]
> 
> How should I write the complete A.gpr project file so that my a.adb
> can use the L library?

My unit testing library at http://svn.gna.org/viewcvs/ahven/trunk/
contains some examples. I have  library sources in 'src'. The
executable is in the 'test' directory. And there is another executable
in the 'examples' directory.

You probably also need to make .ali files read-only to avoid unnecessary
(re)compilations.

-- 
Tero Koskinen - http://iki.fi/tero.koskinen/



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using GNAT project files and libraries
  2008-03-07 22:37 Using GNAT project files and libraries Maciej Sobczak
  2008-03-08 11:59 ` Tero Koskinen
@ 2008-03-08 17:33 ` Simon Wright
  2008-03-08 20:46   ` Maciej Sobczak
  1 sibling, 1 reply; 7+ messages in thread
From: Simon Wright @ 2008-03-08 17:33 UTC (permalink / raw)


Maciej Sobczak <see.my.homepage@gmail.com> writes:

> I have a library composed of two packages: the root library package,
> which is empty (pure), and one child containing Some_Procedure. Let's
> say the packages are named L and L.Child. The library is compiled and
> resides in the following directories:
>
> src: l.ads, l-child.ads, l-child.adb
> lib: l.ali, l-child.ali, libl.a
>
> There is also a sibling test directory with the following a.adb:
>
> with L.Child;
> procedure A is
> begin
>    L.Child.Some_Procedure;
> end A;
>
> Now I try to figure out how to write A.gpr project file.
> I have the following:
>
> project A is
>
>     for Source_Files use ("a.adb");
>
>     package Compiler is
>         for Default_Switches ("Ada") use ("-I../src");
>     end Compiler;
>
> end A;

You need l.gpr. I think it would live in the parent directory (up one
from src/, lib/ and test/). Assuming you have one, a.gpr (in test/ I
suppose) would say

   with "../l";
   project A is
      for Source_Files use ("a.adb");
   end A;

OK, now for l.gpr ..

   project L is
     for Source_Dirs use ("src");
     for Object_Dir use "lib";
   end L;

Note this is *not* capable of creating the library. A different .gpr
is needed for this (especially if you're going for a static library).



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using GNAT project files and libraries
  2008-03-08 17:33 ` Simon Wright
@ 2008-03-08 20:46   ` Maciej Sobczak
  2008-03-08 22:17     ` Simon Wright
  0 siblings, 1 reply; 7+ messages in thread
From: Maciej Sobczak @ 2008-03-08 20:46 UTC (permalink / raw)


On 8 Mar, 18:33, Simon Wright <simon.j.wri...@mac.com> wrote:

> You need l.gpr.

Good point. I actually already have it, because the library was also
made with GNAT project files.
So, a.gpr:

with "../l.gpr";
project A is

    for Source_Files use ("a.adb");
    for Main use ("a");

end A;

That's it.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using GNAT project files and libraries
  2008-03-08 20:46   ` Maciej Sobczak
@ 2008-03-08 22:17     ` Simon Wright
  2008-03-09 13:15       ` Maciej Sobczak
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Wright @ 2008-03-08 22:17 UTC (permalink / raw)


Maciej Sobczak <see.my.homepage@gmail.com> writes:

> On 8 Mar, 18:33, Simon Wright <simon.j.wri...@mac.com> wrote:
>
>> You need l.gpr.
>
> Good point. I actually already have it, because the library was also
> made with GNAT project files.

Is your l.gpr like the simplified version I posted or the full one
used to create the library? I thought they had to be different .. I
suppose that wouldn't be completely desirable.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using GNAT project files and libraries
  2008-03-08 22:17     ` Simon Wright
@ 2008-03-09 13:15       ` Maciej Sobczak
  2008-03-09 19:03         ` Simon Wright
  0 siblings, 1 reply; 7+ messages in thread
From: Maciej Sobczak @ 2008-03-09 13:15 UTC (permalink / raw)


On 8 Mar, 23:17, Simon Wright <simon.j.wri...@mac.com> wrote:

> >> You need l.gpr.
>
> > Good point. I actually already have it, because the library was also
> > made with GNAT project files.
>
> Is your l.gpr like the simplified version I posted or the full one
> used to create the library?

The full one - it was used to compile and archive the library itself.

> I thought they had to be different...

That would be unfortunate. I'm happy that it works with the minimal
set of project files and I would not like to write additional project
files just to be able to use the library (but I accept the fact that I
might need to write trivial project files for third-party libraries
that don't come with their own project files).

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using GNAT project files and libraries
  2008-03-09 13:15       ` Maciej Sobczak
@ 2008-03-09 19:03         ` Simon Wright
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2008-03-09 19:03 UTC (permalink / raw)


Maciej Sobczak <see.my.homepage@gmail.com> writes:

> On 8 Mar, 23:17, Simon Wright <simon.j.wri...@mac.com> wrote:
>
>> >> You need l.gpr.
>>
>> > Good point. I actually already have it, because the library was also
>> > made with GNAT project files.
>>
>> Is your l.gpr like the simplified version I posted or the full one
>> used to create the library?
>
> The full one - it was used to compile and archive the library itself.

When I tried (GNAT-GPL), the static library build didn't seem to work
so well (the .ali files weren't read-only, and the source include
directory wasn't built). I've just tried again and it all works
perfectly. I suspect I may have been using 2006 (I only built 2007 for
the Powerbook recently).

I think there's something to be said for the cut down use-only version
(eg, if distributing a library in built form). But for one's own use,
your way will certainly cut down the work!



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-03-09 19:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-07 22:37 Using GNAT project files and libraries Maciej Sobczak
2008-03-08 11:59 ` Tero Koskinen
2008-03-08 17:33 ` Simon Wright
2008-03-08 20:46   ` Maciej Sobczak
2008-03-08 22:17     ` Simon Wright
2008-03-09 13:15       ` Maciej Sobczak
2008-03-09 19:03         ` Simon Wright

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